[Nestmates] Error message when MemberOfNest is not found

David Holmes david.holmes at oracle.com
Tue Aug 22 02:41:17 UTC 2017

Hi Remi,

On 22/08/2017 12:11 AM, Remi Forax wrote:
> While testing the implementation of nestmates in ASM,
> i've mess up with one of my test and insert the wrong name in MemberOfNest.
> So it get a ClassNotFoundError, that's Ok, but i get an unexpected stacktrace,
> it reference the first line of the main(), which is disturbing.
> Exception in thread "main" java.lang.NoClassDefFoundError: $A
> 	at Foo.main(Foo.java:15)
> Caused by: java.lang.ClassNotFoundException: $A
> 	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
> 	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)
> 	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:495)
> 	... 1 more
> Is it normal ?

In the existing code nestmate validation occurs at link-time, so if your 
class needed to be linked by the start of main then it is as expected.

I'm currently working on a change to only do nestmate validation at the 
time an actual nestmate access is needed. That should put the exception 
at a less surprising place. This allows for more cases where the 
nest-top, I mean nest-host, class may not be present and is not needed.

> Is there a way to improve the error message ?

There is an action item to look at the exceptions that can come from 
nestmate validation and ensure we throw reasonable exceptions at 
reasonable places with reasonable error messages. Currently 
LinkageErrors just propagate and the NCDFE messages can be somewhat 

This is all WIP.


> Rémi

More information about the valhalla-dev mailing list