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

Upgrade to Guice 5 (for java 15 compatibility) #2494

Closed
altmind opened this issue Jan 6, 2022 · 1 comment
Closed

Upgrade to Guice 5 (for java 15 compatibility) #2494

altmind opened this issue Jan 6, 2022 · 1 comment
Labels
dependencies Pull requests that update a dependency file
Milestone

Comments

@altmind
Copy link

altmind commented Jan 6, 2022

Guice 4-branch is incompatible with java modules system, please consider upgrading jooby-guice to version 5 https://github.com/google/guice/wiki/Guice501

When using jooby-guice 2.12.0, adoptopenjdk 11.0.12.7 this results in a warning:

Click to expand! WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (jar:file:/C:/Users/user/.m2/repository/com/google/inject/guice/4.2.3/guice-4.2.3.jar!/) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release

I think this warning became an error in java15.

When using jooby-guice 2.12.0, adoptopenjdk 17.0.1.12 this results in a runtime error:

Click to expand! com.google.common.util.concurrent.UncheckedExecutionException: java.lang.IllegalStateException: Unable to load cache item ... Caused by: com.google.inject.internal.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 @6d5de79a at myproj//com.google.inject.internal.cglib.core.$ReflectUtils.defineClass(ReflectUtils.java:464) at myproj//com.google.inject.internal.cglib.core.$AbstractClassGenerator.generate(AbstractClassGenerator.java:339) at myproj//com.google.inject.internal.cglib.core.$AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:96) at myproj//com.google.inject.internal.cglib.core.$AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:94) at myproj//com.google.inject.internal.cglib.core.internal.$LoadingCache$2.call(LoadingCache.java:54) at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java) at myproj//com.google.inject.internal.cglib.core.internal.$LoadingCache.createEntry(LoadingCache.java:61) at myproj//com.google.inject.internal.cglib.core.internal.$LoadingCache.get(LoadingCache.java:34) at myproj//com.google.inject.internal.cglib.core.$AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:119) at myproj//com.google.inject.internal.cglib.core.$AbstractClassGenerator.create(AbstractClassGenerator.java:294) at myproj//com.google.inject.internal.cglib.core.$KeyFactory$Generator.create(KeyFactory.java:221) at myproj//com.google.inject.internal.cglib.core.$KeyFactory.create(KeyFactory.java:174) at myproj//com.google.inject.internal.cglib.core.$KeyFactory.create(KeyFactory.java:157) at myproj//com.google.inject.internal.cglib.core.$KeyFactory.create(KeyFactory.java:149) at myproj//com.google.inject.internal.cglib.core.$KeyFactory.create(KeyFactory.java:145) at myproj//com.google.inject.internal.cglib.core.$MethodWrapper.(MethodWrapper.java:23) ... 93 common frames omitted 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 @6d5de79a at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354) 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 myproj//com.google.inject.internal.cglib.core.$ReflectUtils$1.run(ReflectUtils.java:61) at java.base/java.security.AccessController.doPrivileged(AccessController.java:569) at myproj//com.google.inject.internal.cglib.core.$ReflectUtils.(ReflectUtils.java:52) at myproj//com.google.inject.internal.cglib.reflect.$FastClassEmitter.(FastClassEmitter.java:67) ... 90 common frames omitted

A stopgap solution is to add jvm argument: --add-opens java.base/java.lang=ALL-UNNAMED

Referencing similar issues:
eclipse/xtext-core#506 google/guice#1133

@jknack jknack added this to the 2.12.1 milestone Jan 6, 2022
@jknack jknack added the dependencies Pull requests that update a dependency file label Jan 6, 2022
jknack added a commit that referenced this issue Jan 6, 2022
- Guice 5 works with Java 11/15
- This is major upgrade

Fix #2267 #2494
@jknack
Copy link
Member

jknack commented Jan 16, 2022

released in 2.13.0

@jknack jknack closed this as completed Jan 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

No branches or pull requests

2 participants