Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8355662

When creating AOT cache with graalvm-jdk, jdk.internal.vm.ci module should be added

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 24
    • hotspot

      (Original report: https://mail.openjdk.org/pipermail/leyden-dev/2025-April/001959.html )

      An AOT cache created with graalvm-jdk cannot be used:

      $ alias java=/home/iklam/graal/graalvm-jdk-24.0.1+9.1/bin/java
      $ java -XX:AOTMode=record -XX:AOTConfiguration=hw.aotconfig -cp HelloWorld.jar HelloWorld
      Hello World
      $ java -XX:AOTMode=create -XX:AOTConfiguration=hw.aotconfig -XX:AOTCache=hw.aot -cp HelloWorld.jar
      AOTCache creation is complete: hw.aot
      $ java -XX:AOTCache=hw.aot -cp HelloWorld.jar HelloWorld
      [0.005s][error][cds] CDS archive has aot-linked classes. It cannot be used when archived full module graph is not used.
      Hello World

      ====================
      Work around: add "--add-modules=jdk.internal.vm.ci" when creating the AOT cache:

      $ java --add-modules=jdk.internal.vm.ci -XX:AOTMode=create -XX:AOTConfiguration=hw.aotconfig -XX:AOTCache=hw.aot -cp HelloWorld.jar
      AOTCache creation is complete: hw.aot
      $ java -Xlog:cds -XX:AOTCache=hw.aot -cp HelloWorld.jar HelloWorld
      [0.002s][info][cds] trying to map hw.aot
      [0.002s][info][cds] Opened archive hw.aot.
      [0.002s][info][cds] Archive was created with UseCompressedOops = 1, UseCompressedClassPointers = 1, UseCompactObjectHeaders = 0
      [0.002s][info][cds] Core region alignment: 4096
      [0.002s][info][cds] ArchiveRelocationMode == 1: always map archive(s) at an alternative address
      [0.002s][info][cds] Try to map archive(s) at an alternative address
      [0.002s][info][cds] Reserved archive_space_rs [0x00007f767e000000 - 0x00007f767f000000] (16777216) bytes
      [0.003s][info][cds] Reserved class_space_rs [0x00007f767f000000 - 0x00007f76bf000000] (1073741824) bytes
      [0.003s][info][cds] Mapped static region #0 at base 0x00007f767e000000 top 0x00007f767e2f8000 (ReadWrite)
      [0.003s][info][cds] Mapped static region #1 at base 0x00007f767e2f8000 top 0x00007f767e89a000 (ReadOnly)
      [0.003s][info][cds] Mapped static region #2 at base 0x00007f7703fde000 top 0x00007f7704000000 (Bitmap)
      [0.004s][info][cds] _archived_main_module_name (null)
      [0.004s][info][cds] jdk.module.main (null)
      [0.004s][info][cds] optimized module handling: enabled
      [0.004s][info][cds] full module graph: enabled
      [0.004s][info][cds] jdk.module.addmods jdk.internal.vm.ci
      [0.004s][info][cds] optimized module handling: enabled
      [0.004s][info][cds] full module graph: enabled
      [0.004s][info][cds] jdk.module.enable.native.access (null)
      [0.004s][info][cds] optimized module handling: enabled
      [0.004s][info][cds] full module graph: enabled
      [0.004s][info][cds] CDS archive was created with max heap size = 15488M, and the following configuration:
      [0.004s][info][cds] narrow_klass_base at mapping start address, narrow_klass_pointer_bits = 32, narrow_klass_shift = 0
      [0.004s][info][cds] narrow_oop_mode = 1, narrow_oop_base = 0x0000000000000000, narrow_oop_shift = 3
      [0.004s][info][cds] The current max heap size = 15488M, G1HeapRegion::GrainBytes = 8388608
      [0.004s][info][cds] narrow_klass_base = 0x00007f767e000000, arrow_klass_pointer_bits = 32, narrow_klass_shift = 0
      [0.004s][info][cds] narrow_oop_mode = 1, narrow_oop_base = 0x0000000000000000, narrow_oop_shift = 3
      [0.004s][info][cds] heap range = [0x0000000438000000 - 0x0000000800000000]
      [0.004s][info][cds] Preferred address to map heap data (to avoid relocation) is 0x00000007ff800000
      [0.004s][info][cds] Heap data mapped at 0x00000007ff800000, size = 1037008 bytes
      [0.004s][info][cds] CDS heap data relocation delta = 0 bytes
      [0.004s][info][cds] initial optimized module handling: enabled
      [0.004s][info][cds] initial full module graph: enabled
      [0.004s][info][cds] use_full_module_graph = true; java.base = 0x00007f767e2ef3b0
      [0.004s][info][cds] Unmapping region #2 at base 0x00007f7703fde000 (Bitmap)
      [0.004s][info][cds] Using AOT-linked classes: true (static archive: has aot-linked classes)
      Hello World

            Unassigned Unassigned
            iklam Ioi Lam
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: