Lookup.defineAnonymousClass() vs indy

Mandy Chung mandy.chung at oracle.com
Mon Nov 30 20:38:39 UTC 2020



On 11/30/20 12:25 PM, forax at univ-mlv.fr wrote:
> The real question is why the descriptor is not rewritten to replace 
> the owning class by the hidden class when lookup.defineHiddenClass is 
> called, i believe this is the behavior of unsafe.defineAnonymousClass.

JVM does not do any magic for hidden classes which is a feature, not a 
bug.   A hidden class _cannot be named_ in any descriptor.

The only adjustment for hidden classes, compared to normal class, after 
a hidden class C is derived and linked by JVM is that:
(1) During verification, whenever it is necessary to load the class 
named CN, the attempt succeeds, producing class C. No request is made of 
any class loader.
(2) On any attempt to resolve the entry in the run-time constant pool 
indicated by `this_class`, the symbolic reference is considered to be 
resolved to C and resolution always succeeds immediately.


Mandy


More information about the core-libs-dev mailing list