New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8273360: [lworld] Invoking a reflection-generated constructor for primitive class gives InstantiationError #546
8273360: [lworld] Invoking a reflection-generated constructor for primitive class gives InstantiationError #546
Conversation
…ass gives InstantiationError
|
@jespersm This change now passes all automated pre-integration checks. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 8 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@mlchung) but any other Committer may sponsor as well.
|
Webrevs
|
/solves 8273360 |
@jespersm The primary solved issue for a PR is set through the PR title. Since the current title does not contain an issue reference, it will now be updated. |
@@ -49,7 +49,7 @@ public short getLength() { | |||
public void emitMagicAndVersion() { | |||
emitInt(0xCAFEBABE); | |||
emitShort((short) 0); | |||
emitShort((short) 49); | |||
emitShort((short) 62); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This old bytecode generator does not support stack map and so these reflection classes would need to stay in version 49. JEP 416 changes the core reflection implementation to build on top of method handles and no longer depends on this old bytecode generator.
this.isConstructingPrimitive = isConstructor && declaringClass.isPrimitiveClass(); | ||
if (this.isConstructingPrimitive ) { | ||
returnType = declaringClass.asValueType(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, this method can take an additional isStaticFactory
parameter. generateConstructor
will determine if the declaring class is a primitive class and then call the static factory with the return type argument rather than Void.TYPE
.
for (int i = 0; i < 20; ++i) { | ||
Object o = ctor.newInstance(); | ||
assertTrue(o.getClass() == PRIMITIVE_TYPE.asPrimaryType()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to replace this change with @run testng/othervm -Dsun.reflect.noInflation=true StaticFactoryTest
so that other test cases will also verify when it's run with the generated bytecode.
Looks good. You can integrate once you update the StaticFactoryTest.java
.
Run both variations Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Thanks for reviewing, @mlchung ! /integrate |
/sponsor |
Going to push as commit 1303571.
Your commit was automatically rebased without conflicts. |
Update constructor accessor code generation to invoke static factory method.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/valhalla pull/546/head:pull/546
$ git checkout pull/546
Update a local copy of the PR:
$ git checkout pull/546
$ git pull https://git.openjdk.java.net/valhalla pull/546/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 546
View PR using the GUI difftool:
$ git pr show -t 546
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/valhalla/pull/546.diff