Debug NoClassDefFoundError
David Holmes
david.holmes at oracle.com
Tue May 18 02:51:17 UTC 2021
On 18/05/2021 2:19 am, Christian Beikov wrote:
> 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:
You get that exception when a class has been placed in the erroneous
state, which means that a previous attempt to initialize the class has
failed. As Remi indicated if you don't see that original exception it is
typically because something else has swallowed it. If the class is
dynamically generated such that there is no source code for you to
modify to debug the static initialization problem, then try running with
-Xlog:exceptions=trace to see if that shows you what the earlier
exception was.
Cheers,
David
>
> 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.
>
> Regards,
>
> Christian
>
>
More information about the hotspot-dev
mailing list