NoClassDefFoundError: Could not initialize, class$ReflectUtils

Dawid Weiss dawid.weiss at
Mon Sep 19 17:01:34 UTC 2016

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 <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" <Alan.Bateman at>
>> À: "Dawid Weiss" <dawid.weiss at>
>> Cc: "jigsaw-dev" <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,
>>> 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(
>>> at
>>> java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(
>>> at java.base/java.lang.reflect.Method.checkCanSetAccessible(
>>> at java.base/java.lang.reflect.Method.setAccessible(
>>> at
>>> at java.base/ Method)
>>> at
>>> at
>>> [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