Re: NoClassDefFoundError: Could not initialize, class com.google.inject.internal.cglib.core.$ReflectUtils
Yes, the assignment version works on 1.8, 1.9, but it doesn't work on J9 (-XX:+IgnoreUnrecognizedVMOptions isn't implemented). I do have a java version check and conditional logic implemented in the bootstrap script, Alan, I just wanted to point out the issue, I'm not complaining ;) Dawid On Mon, Sep 19, 2016 at 11:06 PM, Alan Bateman wrote: > > On 19/09/2016 12:21, Dawid Weiss wrote: >> >> : >>> >>> jdk1.8-ibm\bin\java -XX:+IgnoreUnrecognizedVMOptions --add-modules >>> jdk.xml.bind,java.activation -version >> >> JVMJ9VM007E Command-line option unrecognised: --add-modules >> Error: Could not create the Java Virtual Machine. >> Error: A fatal exception has occurred. Program will exit. > > The space separator will confuse it, you can you try > `--add-modules=jdk.xml.bind,java.activation`? > > -Alan
Re: NoClassDefFoundError: Could not initialize,class com.google.inject.internal.cglib.core.$ReflectUtils
On 19/09/2016 12:21, Dawid Weiss wrote: : jdk1.8-ibm\bin\java -XX:+IgnoreUnrecognizedVMOptions --add-modules jdk.xml.bind,java.activation -version JVMJ9VM007E Command-line option unrecognised: --add-modules Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. The space separator will confuse it, you can you try `--add-modules=jdk.xml.bind,java.activation`? -Alan
Re: NoClassDefFoundError: Could not initialize, class com.google.inject.internal.cglib.core.$ReflectUtils
> If you specify -XX:+IgnoreUnrecognizedVMOptions then JDK 8/older will ignore > the JDK 9 options that it doesn't recognize. But this only applies to -XX options, doesn't it? I can't quite use the gnu-style options with the above because how would it know what is an option and what is part of command line arguments? > jdk1.9\bin\java --add-modules jdk.xml.bind,java.activation -version java version "9-ea" Java(TM) SE Runtime Environment (build 9-ea+129-jigsaw-nightly-h5343-20160802) Java HotSpot(TM) 64-Bit Server VM (build 9-ea+129-jigsaw-nightly-h5343-20160802, mixed mode) > jdk1.8\bin\java -XX:+IgnoreUnrecognizedVMOptions --add-modules > jdk.xml.bind,java.activation -version Error: Could not find or load main class jdk.xml.bind,java.activation Also, we're can't really restrict our users to OpenJDK (or Oracle's distribution): > jdk1.8-ibm\bin\java -XX:+IgnoreUnrecognizedVMOptions --add-modules > jdk.xml.bind,java.activation -version JVMJ9VM007E Command-line option unrecognised: --add-modules Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. > In the main manifest of the main application JAR then you can put: > > Add-Exports-Private: java.base/java.lang Yup, that's more what I had in mind. Dawid
RE: NoClassDefFoundError: Could not initialize, class com.google.inject.internal.cglib.core.$ReflectUtils
I have raised the issue of command line options several times. I think the summary is the following. 1. I don't always have control of the command line. 2. I don't always own the main. 3. When multiple projects are merged into the same JVM, there is not a good way to merge command line options. 4. Different releases of the JDK require different options. One way to resolve this is to embed versioned command line option information into library jar files. Regarding using command line arguments in argument files: 1. Path names are relative to the current working directory, not the argument file. - To use an argument file from anywhere, you need to have full pathnames. - To generate full pathnames in an argument file, you need to do processing on the argument file (unzip is not sufficient). -Original Message- From: Dawid Weiss [mailto:dawid.we...@gmail.com] Sent: Monday, September 19, 2016 1:02 PM To: Remi Forax Cc: jigsaw-dev Subject: Re: NoClassDefFoundError: Could not initialize, class com.google.inject.internal.cglib.core.$ReflectUtils 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 mailto:fo...@univ-mlv.fr"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" > "mailto:alan.bate...@oracle.com"alan.bate...@oracle.com> >> À: "Dawid Weiss" > "mailto:dawid.we...@gmail.com"dawid.we...@gmail.com> >> Cc: "jigsaw-dev" > "mailto:jigsaw-dev@openjdk.java.net"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,ja >>> va.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.throwInaccessibleObjectExc >>> eption(Reflection.java:414) >>> at >>> java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(A >>> ccessibleObject.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(ReflectUti >>> ls.java:52) at >>> java.base/java.security.AccessController.doPrivileged(Native Method) >>> at >>> com.google.inject.internal.cglib.core.$ReflectUtils.(Reflect >>> Utils.java:42) >>> at >>> com.google.inject.internal.cglib.reflect.$FastClass$Generator.getPro >>> tectionDomain(FastClass.java:73) >>> [truncated] >>> >> I assume running with `--add-exports-private >> java.base/java.lang=ALL-UNNAMED` will allow you get past this. >> >> -Alan
Re: NoClassDefFoundError: Could not initialize, class com.google.inject.internal.cglib.core.$ReflectUtils
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 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" >> À: "Dawid Weiss" >> Cc: "jigsaw-dev" >> 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.(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
Re: NoClassDefFoundError: Could not initialize,class com.google.inject.internal.cglib.core.$ReflectUtils
On 19/09/2016 10:01, Dawid Weiss wrote: 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. If you specify -XX:+IgnoreUnrecognizedVMOptions then JDK 8/older will ignore the JDK 9 options that it doesn't recognize. 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. In the main manifest of the main application JAR then you can put: Add-Exports-Private: java.base/java.lang and it will be the equivalent of `--add-exports-private java.base/java.lang=ALL-UNNAMED` on the command-line. Only the main application JAR can have this attribute (it doesn't make sense for library JARs of course). -Alan
Re: NoClassDefFoundError: Could not initialize,class com.google.inject.internal.cglib.core.$ReflectUtils
I wonder what is the best way to fix the code of Guice ? Use Unsafe.defineAnonymousClass ? cheers, Rémi - Mail original - > De: "Alan Bateman" > À: "Dawid Weiss" > Cc: "jigsaw-dev" > 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.(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
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.(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
Re: NoClassDefFoundError: Could not initialize, class com.google.inject.internal.cglib.core.$ReflectUtils
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.(ReflectUtils.java:42) at com.google.inject.internal.cglib.reflect.$FastClass$Generator.getProtectionDomain(FastClass.java:73) [truncated] D. On Mon, Sep 19, 2016 at 2:12 PM, Alan Bateman wrote: > On 19/09/2016 00:12, Dawid Weiss wrote: > >> Guice 4.1.0 throws an exception from within the embedded cglib with >> this release: >> >>> java -version >> >> java version "9-ea" >> Java(TM) SE Runtime Environment (build >> 9-ea+135-jigsaw-nightly-h5500-20160914) >> Java HotSpot(TM) 64-Bit Server VM (build >> 9-ea+135-jigsaw-nightly-h5500-20160914, mixed mode) >> >>> [apptest] >> >> > Caused by: java.lang.NoClassDefFoundError: Could not initialize >> class com.google.inject.internal.cglib.core.$ReflectUtils >> >at >> com.google.inject.internal.cglib.reflect.$FastClass$Generator.getProtectionDomain(FastClass.java:73) >> >at >> com.google.inject.internal.cglib.core.$AbstractClassGenerator.create(AbstractClassGenerator.java:206) >> >at >> com.google.inject.internal.cglib.reflect.$FastClass$Generator.create(FastClass.java:65) >> >at >> com.google.inject.internal.BytecodeGen.newFastClassForMember(BytecodeGen.java:252) >> >at >> com.google.inject.internal.BytecodeGen.newFastClassForMember(BytecodeGen.java:203) >> >at >> com.google.inject.internal.DefaultConstructionProxyFactory.create(DefaultConstructionProxyFactory.java:53) >> >at >> com.google.inject.internal.ProxyFactory.create(ProxyFactory.java:158) >> >at >> com.google.inject.internal.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:90) >> >at >> com.google.inject.internal.ConstructorInjectorStore.access$000(ConstructorInjectorStore.java:29) >> >at >> com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:37) >> >at >> com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:33) >> >at >> com.google.inject.internal.FailableCache$1.load(FailableCache.java:37) >> >at >> com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3542) >> >at >> com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2323) >> >at >> com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2286) >> >at >> com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2201) >> > Can you run this with -Dsun.reflect.debugModuleAccessChecks=true to see if > there is any exception thrown? > > -Alan
Re: NoClassDefFoundError: Could not initialize,class com.google.inject.internal.cglib.core.$ReflectUtils
On 19/09/2016 00:12, Dawid Weiss wrote: Guice 4.1.0 throws an exception from within the embedded cglib with this release: java -version java version "9-ea" Java(TM) SE Runtime Environment (build 9-ea+135-jigsaw-nightly-h5500-20160914) Java HotSpot(TM) 64-Bit Server VM (build 9-ea+135-jigsaw-nightly-h5500-20160914, mixed mode) [apptest] > Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.google.inject.internal.cglib.core.$ReflectUtils >at com.google.inject.internal.cglib.reflect.$FastClass$Generator.getProtectionDomain(FastClass.java:73) >at com.google.inject.internal.cglib.core.$AbstractClassGenerator.create(AbstractClassGenerator.java:206) >at com.google.inject.internal.cglib.reflect.$FastClass$Generator.create(FastClass.java:65) >at com.google.inject.internal.BytecodeGen.newFastClassForMember(BytecodeGen.java:252) >at com.google.inject.internal.BytecodeGen.newFastClassForMember(BytecodeGen.java:203) >at com.google.inject.internal.DefaultConstructionProxyFactory.create(DefaultConstructionProxyFactory.java:53) >at com.google.inject.internal.ProxyFactory.create(ProxyFactory.java:158) >at com.google.inject.internal.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:90) >at com.google.inject.internal.ConstructorInjectorStore.access$000(ConstructorInjectorStore.java:29) >at com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:37) >at com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:33) >at com.google.inject.internal.FailableCache$1.load(FailableCache.java:37) >at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3542) >at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2323) >at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2286) >at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2201) Can you run this with -Dsun.reflect.debugModuleAccessChecks=true to see if there is any exception thrown? -Alan