JDK-8315719 : Adapt AOTClassLinking test case for dynamic CDS archive
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: repo-leyden
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-09-05
  • Updated: 2025-05-08
  • Resolved: 2025-04-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 25
25 b21Fixed
Related Reports
Relates :  
Description
The handling of -XX:+AOTClassLinking with the dynamic CDS archive is different than the static CDS archive. In particular:
- AOT resolution of method CP entries is not supported (JDK-XXXXXXX)
- AOT resolution of indy CP entries is not supported (because this requires archived heap objects, which is not supported for dynamic archive

We have some AOTClassLinking test cases that only test again the static CDS archive. As a sanity check, we should run them with the dynamic archive as well, to ensure that the JVM still functions properly.

In particular, the following was a crash that was found in the Leyden repo related to AOT resolution of indy CP entries using "old" classes. Such a scenario is covered by the test case https://github.com/openjdk/jdk/blob/ed604038ffc4ca64113984324dde71c07f046b52/test/hotspot/jtreg/runtime/cds/appcds/resolvedConstants/ResolvedConstants.java . We should adapt this test case for dynamic CDS archive.



=============== Original bug report from repo-leyden:
In JDK mainline, linked old classes are excluded from the CDS archive (see JDK-8309074 for the reason)
In leyden-premain, -XX:+ArchiveInvokeDynamic can create archived heap objects (MethodType) that reference linked old classes.

As a result, we get an error like this when running 'java -Xshare:dump -XX:ArchiveInvokeDynamic"

#  Internal Error (/jdk3/le3/open/src/hotspot/share/cds/archiveBuilder.hpp:300), pid=3992961, tid=3993274
#  assert(is_in_buffer_space(obj)) failed: must be

Stack: [0x00007fffd89d3000,0x00007fffd8ad3000],  sp=0x00007fffd8ad1110,  free space=1016k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x5e7ec8]  unsigned char* ArchiveBuilder::to_requested<unsigned char*>(unsigned char*) const+0x50  (archiveBuilder.hpp:300)
V  [libjvm.so+0x5f8447]  ArchiveHeapWriter::compute_ptrmap(ArchiveHeapInfo*)+0x279  (archiveHeapWriter.cpp:692)
V  [libjvm.so+0x5f7ed2]  ArchiveHeapWriter::relocate_embedded_oops(GrowableArrayCHeap<oopDesc*, (MEMFLAGS)13>*, ArchiveHeapInfo*, GrowableArray<unsigned long>*, int)+0x25e  (archiveHeapWriter.cpp:592)
V  [libjvm.so+0x5f6476]  ArchiveHeapWriter::write(GrowableArrayCHeap<oopDesc*, (MEMFLAGS)13>*, ArchiveHeapInfo*)+0xda  (archiveHeapWriter.cpp:112)
V  [libjvm.so+0xd03eaa]  HeapShared::archive_objects(ArchiveHeapInfo*)+0x168  (heapShared.cpp:680)

Comments
Changeset: 5db62abb Branch: master Author: Ioi Lam <iklam@openjdk.org> Date: 2025-04-25 20:58:40 +0000 URL: https://git.openjdk.org/jdk/commit/5db62abb4216a0618d6ea59d292828907572d542
25-04-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/24866 Date: 2025-04-25 04:25:05 +0000
25-04-2025

Need to check if this issue is still valid in JDK mainline
17-04-2025

This will be addressed in JDK-8317269 - Preload all verification dependencies for archived classes.
28-09-2023