-
Notifications
You must be signed in to change notification settings - Fork 396
Fix #3921: Work around JDK-6265952: MethodAccessorImpl NoClassDefError #3928
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
Conversation
Please see #3921 (comment). tl;dr: I think this workaround is fine. |
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.
The commit message should read something like:
"Fix #3921: Work around JDK-6265952: MethodAccessorImpl NoClassDefError"
* https://www.ibm.com/developerworks/community/forums/html/threadTopic?id=77777777-0000-0000-0000-000013894489&ps=25 | ||
* | ||
* So we will delegate the access to sun.* packages to the parent class loader instead of using reflection. | ||
*/ |
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.
Please:
- Put the workaround at the end of the list.
- Adjust the comment as pointed out in Running multiple fastOptJS causes java.lang.NoClassDefFoundError: jdk/internal/reflect/MethodAccessorImpl #3921 (comment)
- Consider only adding the prefix "sun.reflect."
- Also add "jdk.internal.reflect." (judging from the stack trace in Running multiple fastOptJS causes java.lang.NoClassDefFoundError: jdk/internal/reflect/MethodAccessorImpl #3921) or verify this workaround works for the airframe CI.
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.
So on second reading, I think this comment still needs improvement. Notably, the second section doesn't "connect up" to the first one.
Things that at the moment are unclear from the comment IMHO:
- Why is
"sun.reflect."
there as well? - If
java.lang.reflect.Method
becomes invalid, why does this fix it? Why do we not need to recreate a newjlr.Method
? - Its non obvious that the prefixes are implementation details of the relevant JDKs (this is related to the first point). So if somebody sees a
NoClassDefFoundError: moon.reflect.MethodAccessorImpls
missing, this is probably the same issue.
I think point 1 and 3 can be addressed by making it clear that this is an implementation detail and jdk.internal.reflect.MethodAccessorImpl
and sun.reflect.MethodAccessorImpl
are the currently known affected classes.
Point 2 is a bit more tricky: I think we need to either explain the thing in full, or omit explanation of why this happens and simply describe
- trigger (call
invoke
sun.reflect.inflationThreshold
times on sameMethod
instance) - symptom (
NoClassDefFoundError
) - mitigation (add prefix here)
and refer to the bug, letting the reader reconstruct the details by themselves.
Marking "DO NOT MERGE" until #3931 is merged. |
25910a1
to
bad4bf3
Compare
@gzm0 Fixed the PR as suggested. And confirmed this version worked well for building Airframe's js projects all at once! |
bad4bf3
to
707ee85
Compare
oops. Forgot to add a trailing dot to "sun.reflect". Fixed. |
707ee85
to
77e418c
Compare
Fixed the formatting issue too (120 column limit) |
* https://www.ibm.com/developerworks/community/forums/html/threadTopic?id=77777777-0000-0000-0000-000013894489&ps=25 | ||
* | ||
* So we will delegate the access to sun.* packages to the parent class loader instead of using reflection. | ||
*/ |
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.
So on second reading, I think this comment still needs improvement. Notably, the second section doesn't "connect up" to the first one.
Things that at the moment are unclear from the comment IMHO:
- Why is
"sun.reflect."
there as well? - If
java.lang.reflect.Method
becomes invalid, why does this fix it? Why do we not need to recreate a newjlr.Method
? - Its non obvious that the prefixes are implementation details of the relevant JDKs (this is related to the first point). So if somebody sees a
NoClassDefFoundError: moon.reflect.MethodAccessorImpls
missing, this is probably the same issue.
I think point 1 and 3 can be addressed by making it clear that this is an implementation detail and jdk.internal.reflect.MethodAccessorImpl
and sun.reflect.MethodAccessorImpl
are the currently known affected classes.
Point 2 is a bit more tricky: I think we need to either explain the thing in full, or omit explanation of why this happens and simply describe
- trigger (call
invoke
sun.reflect.inflationThreshold
times on sameMethod
instance) - symptom (
NoClassDefFoundError
) - mitigation (add prefix here)
and refer to the bug, letting the reader reconstruct the details by themselves.
@gzm0 Thanks for the comment. I still don't have the full context, including why this workaround can fix the issue, and how the current LinkerImpl works, so I think you are the best person for fixing the comment to address these new questions. Due to the holiday season of US, I'll not be available for 2 or 3 days, so if you are available please fix the comment so that it can be helpful for future readers. I can take a look later, but please understand my knowledge around Scala.js compiler is quite limited at this moment. |
I have done so. Thanks for your contribution! |
@sjrd PTAL a the comment I have edited. |
* The bug is triggered when calling `java.lang.Method#invoke` if both of | ||
* the following conditions are met: | ||
* | ||
* - this call 15th (or later) time `invoke` is called on this instance, |
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 sentence looks broken.
Otherwise LGTM.
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.
:-/ yes. fixed
@gzm0 Thanks for the fix! |
No description provided.