NoClassDefFoundError: Could not initialize, class$ReflectUtils

Stephen Felts stephen.felts at
Mon Sep 19 18:43:29 UTC 2016

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.weiss at] 
Sent: Monday, September 19, 2016 1:02 PM
To: Remi Forax
Cc: jigsaw-dev
Subject: Re: NoClassDefFoundError: Could not initialize, class$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 file or somewhere else, so that you could specify JVM-version-specific options there instead of providing them on command line. Just a thought.




On Mon, Sep 19, 2016 at 3:27 PM, Remi Forax <HYPERLINK "mailto:forax at"forax at> 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" <HYPERLINK "mailto:Alan.Bateman at"Alan.Bateman at>

>> À: "Dawid Weiss" <HYPERLINK "mailto:dawid.weiss at"dawid.weiss at>

>> Cc: "jigsaw-dev" <HYPERLINK "mailto:jigsaw-dev at"jigsaw-dev at>

>> Envoyé: Lundi 19 Septembre 2016 14:47:58

>> Objet: Re: NoClassDefFoundError: Could not initialize,class$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

>>> 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(

>>> at

>>> java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(A

>>> at 

>>> java.base/java.lang.reflect.Method.checkCanSetAccessible(

>>> :192) at 

>>> java.base/java.lang.reflect.Method.setAccessible(

>>> at


>>> at 

>>> java.base/ Method) 

>>> at



>>> at


>>> tectionDomain(

>>> [truncated]


>> I assume running with `--add-exports-private 

>> java.base/java.lang=ALL-UNNAMED` will allow you get past this.


>> -Alan


More information about the jigsaw-dev mailing list