On Tue, 14 Jul 2026 20:25:15 GMT, Ashutosh Mehra <[email protected]> wrote:
> This PR fixes an issue when archiving `sun.util.locale.BaseLocale.CACHE` in > AOTCache or cds archive. `CACHE` is a `LazyConstant` holder for a > `ReferenceKeySet`. If the CACHE has any element added during the assembly > phase, then the `ReferenceKeySet` needs to be prepared for archiving, just > like it is done for `MethodType.internTable` [0]. > > An element is added to the CACHE in `BaseLocale.getInstance` if > `BaseLocale.script` is not empty. Depending on the locale settings, it may or > may not be empty. For example, on my Linux system with locale `en_US`, > `script` is empty. To force script to be non-empty set these system > properties: > `-Duser.language=en -Duser.script=Latn -Duser.country=US` > > Testing: > To reproduce the issue on Linux, run > `runtime/cds/appcds/aotClassLinking/AOTClassLinkingVMOptions.java` with the > above mentioned system properties, as: > > make test > TEST=test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AOTClassLinkingVMOptions.java > CONF=base-fd TEST_OPTS_JAVA_OPTIONS="-Duser.language=en -Duser.script=Latn > -Duser.country=US" > > > It results in following error: > > stdout: [[0.004s][info][cds] Core region alignment: 4096 > [0.131s][info][cds] Loading classes to share ... > [0.131s][info][cds] Parsing > /home/asmehra/data/ashu-mehra/jdk/build/base-fd/images/jdk/lib/classlist > [0.198s][info][cds] Parsing > /home/asmehra/data/ashu-mehra/jdk/build/base-fd/test-support/jtreg_test_hotspot_jtreg_runtime_cds_appcds_aotClassLinking_AOTClassLinkingVMOptions_java/scratch/0/runtime.cds.appcds.aotClassLinking.AOTClassLinkingVMOptions.java-test.classlist > [0.199s][info][cds] Loading classes to share: done. > [0.461s][info][cds] Dumping shared data to file: > /home/asmehra/data/ashu-mehra/jdk/build/base-fd/test-support/jtreg_test_hotspot_jtreg_runtime_cds_appcds_aotClassLinking_AOTClassLinkingVMOptions_java/scratch/0/appcds-14h41m37s070.jsa > [0.461s][info][cds] Gathering all archivable objects ... > [0.478s][info][cds] Skipping jdk/internal/misc/CDS$UnregisteredClassLoader: > used only when dumping CDS archive > [0.478s][info][cds] Skipping > jdk/internal/misc/CDS$UnregisteredClassLoader$Source: used only when dumping > CDS archive > [0.479s][info][cds] Heap range = [0x000000009c000000 - 0x0000000100000000] > [0.535s][error][aot,heap] Cannot archive reference object 0x000000009c012418 > of class jdk.internal.util.SoftReferenceKey > [0.535s][error][aot,heap] referent = 0x000000009c012440, queue = > 0x000000009c012488, next = 0x0000000000000000, discovered = 0x0000000000000000 > [0.535s][error][aot,heap] ... Good. ------------- Marked as reviewed by kvn (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/31902#pullrequestreview-4700430892
