Debug NoClassDefFoundError

Remi Forax forax at univ-mlv.fr
Mon May 17 16:27:42 UTC 2021


----- Mail original -----
> De: "Christian Beikov" <christian.beikov at gmail.com>
> À: "hotspot-dev" <hotspot-dev at openjdk.java.net>
> Envoyé: Lundi 17 Mai 2021 18:19:19
> Objet: Debug NoClassDefFoundError

> Hi,
> 
> not sure if this is the right place to ask, so if I am wrong, please let
> me know where to ask this.
> 
> I have a very strange problem with a generated class defined dynamically
> into a module through `MethodHandles.Lookup.defineClass`. When I try to
> instantiate it, I get a `java.lang.NoClassDefFoundError: Could not
> initialize class ...` without any further context:
> 
> 
>     at
> java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
>     at
> java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>     at
> java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>     at
> java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
> 
> Does anyone know how to further debug this? I was trying to find
> instructions for debugging the JVM itself but couldn't so far.

Usually is an exception inside the static block by example the block static itself not being able to load a class, that is swallowed,
putting a giant try/catch(Throwable) around the static block may help.

> 
> Regards,
> 
> Christian

regards,
Rémi


More information about the hotspot-dev mailing list