-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Java 11 disallows sun.misc.unsafe access from a module #1317
Comments
Thanks. Can you explain what you mean by "switch to reflective access"? Isn't Class.forName() already reflective access? |
Sorry for being obtuse. You have two strategies for looking at the fields of an object: PreJava9ReflectionAccessor and UnsafeReflectionAccessor. The UnsafeReflectionAccessor will fail in Java 11 if the Gson JAR file is on the module path. This is not fatal because each time it fails, you will fall back to PreJava9ReflectionAccessor. But you might as well do the test once in ReflectionAccessor and be done with it. |
If gson is compiled or deployed as an explicit and it is using sun.misc.Unsafe then it needs |
Might have been fixed by #1993 which added |
Putting the gson JAR on the module path makes the call
fail in Java 11. You might as well check that at the place where you check for version numbers, and switch to reflective access. Users who do put the JAR on the module path should know to open any packages whose classes are being accessed by reflection.
The text was updated successfully, but these errors were encountered: