Java 16 and 17 compatibility
See original GitHub issueUpgrading to Java 16 I receive the following Exception. I tried adding the VM option --add-opens java.base/java.lang=ALL-UNNAMED
which I thought would work around the issue to no avail.
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.example.main(Example.java:10)
Caused by: net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InaccessibleObjectException-->Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @39aeed2f
at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:464)
at net.sf.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:339)
at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:96)
at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:94)
at net.sf.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at net.sf.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61)
at net.sf.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)
at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:119)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:294)
at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:221)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:174)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:153)
at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:73)
... 1 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @39aeed2f
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
at net.sf.cglib.core.ReflectUtils$1.run(ReflectUtils.java:61)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:554)
at net.sf.cglib.core.ReflectUtils.<clinit>(ReflectUtils.java:52)
at net.sf.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:243)
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
at net.sf.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:332)
... 13 more
Issue Analytics
- State:
- Created 2 years ago
- Reactions:10
- Comments:19 (2 by maintainers)
Top Results From Across the Web
Why and How to Upgrade to Java 16 or 17 - InfoQ
It's possible to upgrade from Java 8 to 17 at once. However, if you encounter any issues, it might be difficult to determine...
Read more >JDK 17 Release Notes, Important Changes, and Information
The descriptions also identify potential compatibility issues that you might encounter when migrating to JDK 17. specification. ➜ JEP 409: Sealed Classes.
Read more >Will Java 16 and 17 be supported in SonarQube 8.9 LTS?
Unfortunately, and to answer explicitly your question: No, you won't be able to have the support of Java 16 and Java 17 with...
Read more >Quicker Java and JDK 16 compatibility - Inside Java Newscast ...
#java‑16#vector#java‑17. A walk through language features, APIs, and JDK capabilities that make Java quicker to use with less ceremony and ...
Read more >JDK 17: The new features in Java 17 - InfoWorld
Java 17, a new long-term support (LTS) release of standard Java, is now available for production use. Oracle also announced that LTS ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
FYI all, I added a note to the top-level README about its current state:
IMPORTANT NOTE: cglib is unmaintained and does not work well (or possibly at all?) in newer JDKs, particularly JDK17+. If you need to support newer JDKs, we will accept well-tested well-thought-out patches… but you’ll probably have better luck migrating to something like ByteBuddy.
Instead of layering one hack on top of another, wouldn’t it be better to implement this using public methods that are guaranteed to continue working in the future?