Skip to content

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

Merged
merged 1 commit into from
Jan 20, 2020

Conversation

xerial
Copy link
Contributor

@xerial xerial commented Jan 16, 2020

No description provided.

@gzm0
Copy link
Contributor

gzm0 commented Jan 17, 2020

Higher level (details): I don't think we should release 1.0.0 (or 1.0.0-RC3) with this. So a workaround is not needed as this repo does not suffer from the issue.

Lower level: The reported stack-trace in #3921 suggests that we'll also need to add "jdk." for some jdks.

@gzm0
Copy link
Contributor

gzm0 commented Jan 17, 2020

Please see #3921 (comment). tl;dr: I think this workaround is fine.

Copy link
Contributor

@gzm0 gzm0 left a 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.
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please:

Copy link
Contributor

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:

  1. Why is "sun.reflect." there as well?
  2. If java.lang.reflect.Method becomes invalid, why does this fix it? Why do we not need to recreate a new jlr.Method?
  3. 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 same Method instance)
  • symptom (NoClassDefFoundError)
  • mitigation (add prefix here)

and refer to the bug, letting the reader reconstruct the details by themselves.

@sjrd sjrd changed the title Workaround for MethodAccessorImpl NoClassDefError (#3921) DO NOT MERGE Workaround for MethodAccessorImpl NoClassDefError (#3921) Jan 17, 2020
@sjrd
Copy link
Member

sjrd commented Jan 17, 2020

Marking "DO NOT MERGE" until #3931 is merged.

@xerial
Copy link
Contributor Author

xerial commented Jan 17, 2020

@gzm0 Fixed the PR as suggested. And confirmed this version worked well for building Airframe's js projects all at once!

@sjrd sjrd changed the title DO NOT MERGE Workaround for MethodAccessorImpl NoClassDefError (#3921) Workaround for MethodAccessorImpl NoClassDefError (#3921) Jan 17, 2020
@xerial
Copy link
Contributor Author

xerial commented Jan 17, 2020

oops. Forgot to add a trailing dot to "sun.reflect". Fixed.

@xerial
Copy link
Contributor Author

xerial commented Jan 17, 2020

Fixed the formatting issue too (120 column limit)

@xerial xerial requested a review from gzm0 January 18, 2020 06:49
* 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.
*/
Copy link
Contributor

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:

  1. Why is "sun.reflect." there as well?
  2. If java.lang.reflect.Method becomes invalid, why does this fix it? Why do we not need to recreate a new jlr.Method?
  3. 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 same Method instance)
  • symptom (NoClassDefFoundError)
  • mitigation (add prefix here)

and refer to the bug, letting the reader reconstruct the details by themselves.

@xerial
Copy link
Contributor Author

xerial commented Jan 19, 2020

@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.

@gzm0 gzm0 changed the title Workaround for MethodAccessorImpl NoClassDefError (#3921) Fix #3921: Work around JDK-6265952: MethodAccessorImpl NoClassDefError Jan 19, 2020
@gzm0
Copy link
Contributor

gzm0 commented Jan 19, 2020

if you are available please fix the comment so that it can be helpful for future readers.

I have done so. Thanks for your contribution!

@gzm0 gzm0 requested a review from sjrd January 19, 2020 20:01
@gzm0
Copy link
Contributor

gzm0 commented Jan 19, 2020

@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,
Copy link
Member

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:-/ yes. fixed

@gzm0 gzm0 merged commit 5353712 into scala-js:release-v1.0.0 Jan 20, 2020
@xerial
Copy link
Contributor Author

xerial commented Jan 21, 2020

@gzm0 Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants