Exactly. I reported the problem having the --add-exports-private option in the back of my mind (saw it in a recent thread somewhere), but what I'd be more interested in what Rémi asked about.
As a separate note, having multiple non-compatible options becomes quite a burden to maintain in a complex build. We use shell scripts to launch (command-line) software, so shell scripts have to detect java version first and modify options accordingly (currently adding the missing modules with annotations), maven builds need a separate profile that adds these options to the compilation (and build), etc. Is there any other, more elegant way of doing this that I overlooked? Pardon the example, but Microsoft's executable manifest files come to mind -- something that permits attaching "metadata" options to the program without having to provide it explicitly. Ideally, this metadata could be conditionally specified for a given JVM version. It would be interesting to have "java -jar" have such "metadata" in the manifest.mf file or somewhere else, so that you could specify JVM-version-specific options there instead of providing them on command line. Just a thought. Dawid On Mon, Sep 19, 2016 at 3:27 PM, Remi Forax <fo...@univ-mlv.fr> wrote: > I wonder what is the best way to fix the code of Guice ? > > Use Unsafe.defineAnonymousClass ? > > cheers, > Rémi > > ----- Mail original ----- >> De: "Alan Bateman" <alan.bate...@oracle.com> >> À: "Dawid Weiss" <dawid.we...@gmail.com> >> Cc: "jigsaw-dev" <jigsaw-dev@openjdk.java.net> >> Envoyé: Lundi 19 Septembre 2016 14:47:58 >> Objet: Re: NoClassDefFoundError: Could not initialize,class >> com.google.inject.internal.cglib.core.$ReflectUtils > >> On 19/09/2016 05:35, Dawid Weiss wrote: >> >>> Yes, it prints: >>> >>> 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 "exports private java.lang" to unnamed module @4527468c >>> at >>> java.base/jdk.internal.reflect.Reflection.throwInaccessibleObjectException(Reflection.java:414) >>> at >>> java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:196) >>> at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:192) >>> at java.base/java.lang.reflect.Method.setAccessible(Method.java:186) >>> at >>> com.google.inject.internal.cglib.core.$ReflectUtils$1.run(ReflectUtils.java:52) >>> at java.base/java.security.AccessController.doPrivileged(Native Method) >>> at >>> com.google.inject.internal.cglib.core.$ReflectUtils.<clinit>(ReflectUtils.java:42) >>> at >>> com.google.inject.internal.cglib.reflect.$FastClass$Generator.getProtectionDomain(FastClass.java:73) >>> [truncated] >>> >> I assume running with `--add-exports-private >> java.base/java.lang=ALL-UNNAMED` will allow you get past this. >> >> -Alan