With classic CDS (when the AOTClassLinking VM option is disabled), we allow only a very small group of Java mirror objects (instances of java.lang.Class) to be stored in the archived heap:
https://github.com/openjdk/jdk/blob/b8cdf31a2e52df857df2badb4f365454443dd89d/src/hotspot/share/cds/heapShared.cpp#L1543-L1565
The reason was to prevent Java code from obtaining a mirror object that's not yet ready to be used. However, the existing limitation is too strict and may hamper future development of the Java core library.
(For example, there's one prototype that records the specialized type as an injected Class<?> field into a generic type).
With classic CDS, archived heap objects are provisioned to Java code via calls to the jdk.internal.misc.CDS::initializeFromArchive() API, which returns a group of object called a "subgraph". The current limitation is to disallow storing of Java mirrors other than (1) java.lang.Object, (2) primitive classes, and (3) box classes.
PROPOSAL:
With classic CDS, allow any Java mirrors for classes in the boot loader to be stored in a subgraph. Before the subgraph is returned by initializeFromArchive(), ensure that all of the classes represented by these mirrors are already resolved in the boot loader.
Impact to new AOT workflow
None. We already allows arbitrary Java mirrors from the boot/platform/app loaders to store in the heap region of an AOT cache.
https://github.com/openjdk/jdk/blob/b8cdf31a2e52df857df2badb4f365454443dd89d/src/hotspot/share/cds/heapShared.cpp#L1543-L1565
The reason was to prevent Java code from obtaining a mirror object that's not yet ready to be used. However, the existing limitation is too strict and may hamper future development of the Java core library.
(For example, there's one prototype that records the specialized type as an injected Class<?> field into a generic type).
With classic CDS, archived heap objects are provisioned to Java code via calls to the jdk.internal.misc.CDS::initializeFromArchive() API, which returns a group of object called a "subgraph". The current limitation is to disallow storing of Java mirrors other than (1) java.lang.Object, (2) primitive classes, and (3) box classes.
PROPOSAL:
With classic CDS, allow any Java mirrors for classes in the boot loader to be stored in a subgraph. Before the subgraph is returned by initializeFromArchive(), ensure that all of the classes represented by these mirrors are already resolved in the boot loader.
Impact to new AOT workflow
None. We already allows arbitrary Java mirrors from the boot/platform/app loaders to store in the heap region of an AOT cache.