-
Notifications
You must be signed in to change notification settings - Fork 26
java.lang.Class instances
Instances of java/lang/Class (JLC) are well-known to Java developers who use reflection. However, inside the JVM, they have many uses that are not immediately apparent. This page discusses these uses in detail, with occasional explanations of how the details are implemented in Jacobin.
Contrary to the impression the reflection API might convey, JLCs are skinny classes that don't contain metadata on all the fields and methods of a class. Rather they contain a pointer, named _klass, which points back to the class metadata. JLCs also contain all the static fields of a class. (Recall that static fields are unique and shared by all running instances of a class. The JLC is the container holding them.) As a result, the JVM creates the JLC for a given class eagerly. In Jacobin, the JLC is created at the time a class is loaded.