Can't instantiate anonymous class more than 16 times

Rémi Forax forax at univ-mlv.fr
Tue Aug 11 14:28:27 PDT 2009


Le 11/08/2009 21:15, Wei Yin Teo a écrit :
> It doesn't work. :(
>
>
> java.dyn.NoAccessException: receiver must be in caller class: 
> InstanceTest/27271057.<init>()void, from test.AnonymousClassLoading
> at sun.dyn.MemberName.newNoAccessException(MemberName.java:421)
> at java.dyn.MethodHandles.unreflectImpl(MethodHandles.java:496)
> at 
> java.dyn.MethodHandles$Lookup.unreflectConstructor(MethodHandles.java:408)
> at test.AnonymousClassLoading.testLoading(AnonymousClassLoading.java:50)

This is another bug :(
Not your lucky day :)

This one is funny because this is a bug totally in the mind of the 
programmer.
There is a mismatch, the reflection API says "constructor dot invoke"
which for the VM means "call <init>()" but it means create a new instance.
So here, the code tries to just called the <init> method
and failed because you are not in caller class.

To summarize, unreflectConstructor() is currently broken :(

Rémi



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/mlvm-dev/attachments/20090811/abb298ba/attachment.html 


More information about the mlvm-dev mailing list