Skip to content
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

Make lazy vals run on non-fallback graal image - remove dynamic reflection #16346

Merged
merged 2 commits into from
Nov 18, 2022

Conversation

szymon-rd
Copy link
Contributor

Fix #13985
I tested it and it seems to fix the issue

}
}
private[this] val unsafe: sun.misc.Unsafe = {
val unsafeField = classOf[sun.misc.Unsafe].getDeclaredField("theUnsafe").nn
Copy link
Member

Choose a reason for hiding this comment

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

This will throw a NoSuchFieldException if it is not there. Previously we got a more explicit "Can't find instance of sun.misc.Unsafe". We should preserve that behavior, IMO.

else throw new ExceptionInInitializerError {
new IllegalStateException("Can't find instance of sun.misc.Unsafe")
}
unsafeField.get(null).asInstanceOf[sun.misc.Unsafe]
Copy link
Member

Choose a reason for hiding this comment

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

Any reason that the setAccessible is within the if/then/else, but get is after? Consider putting them both in the same code path.

@szymon-rd szymon-rd force-pushed the fix/graalvm-lazy-vals branch from 3913572 to 57a04cd Compare November 18, 2022 13:03
@szymon-rd szymon-rd merged commit bf83641 into scala:main Nov 18, 2022
@Kordyjan Kordyjan added this to the 3.3.0 milestone Aug 2, 2023
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.

GraalVM Native Image Requires Config for lazy vals
3 participants