RFR (S): 8197844: JVMTI GetLoadedClasses should use the Access API

Erik Österlund erik.osterlund at oracle.com
Thu Feb 15 10:04:09 UTC 2018


Hi,

The JVMTI GetLoadedClasses function retrieves, as the name suggests, all 
loaded classes. However, to be able to safely return their mirrors in 
handles during potential concurrent marking, G1 requires an SATB enqueue 
barrier to shade these mirrors grey that were not part of the snapshot 
at the beginning, to prevent the classes from being unloaded.

The current solution is to explicitly SATB enqueue the mirror of the 
retrieved classes with the usual #ifdef blah if (UseG1GC) jazz.

My proposed solution is to instead use the Access API to make the code 
more modular. In the Access API, this operation corresponds to loading 
the mirror with ON_PHANTOM_OOP_REF. Also, an observation from my part is 
that usually when we keep classes from unloading, we keep the 
klass_holder alive, rather than the mirror. For all Klasses except 
anonymous instanceKlasses, the holder is the class loader. For anonymous 
instanceKlasses, the holder is the mirror. As the rest of the code tends 
to prevent class unloading by keeping the holder alive, I would prefer 
to keep the holder alive instead of the mirror, unless there is a good 
reason to keep the mirror alive instead of the holder.

Bug:
https://bugs.openjdk.java.net/browse/JDK-8197844

Webrev:
http://cr.openjdk.java.net/~eosterlund/8197844/webrev.00/

This change has made it through hs-tier1-5 and jdk-tier1-3.

Thanks,
/Erik


More information about the hotspot-runtime-dev mailing list