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

[CRaC] AOT class linking cannot archive jdk.internal.crac.Core$Priority

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • repo-crac
    • repo-crac
    • hotspot
    • None
    • Fix Understood
    • generic
    • generic

      The new CDS feature "Ahead-of-Time Class Loading & Linking" (JEP 483) fails in CRaC JDK (even when CRaC is not used):
      ```
      [0.581s][error][cds,heap] Cannot archive object 0x00000000897046f0 of class java.util.WeakHashMap$Entry
      [0.581s][error][cds,heap] [ 0] {0x00000000897007b8} java.lang.Class (jdk.internal.crac.Core$Priority::FILE_DESCRIPTORS)
      [0.581s][error][cds,heap] [ 1] {0x0000000089700948} jdk.internal.crac.Core$Priority::context (offset = 24)
      [0.581s][error][cds,heap] [ 2] {0x0000000089700e80} jdk.internal.crac.mirror.impl.BlockingOrderedContext::resources (offset = 12)
      [0.581s][error][cds,heap] [ 3] {0x0000000089701000} java.util.WeakHashMap::table (offset = 36)
      [0.581s][error][cds,heap] [ 4] {0x00000000897013f0} [Ljava.util.WeakHashMap$Entry;
      [0.581s][error][cds ] An error has occurred while writing the shared archive file.
      ```

      This happens because of the combination of these facts:
      1. CDS has problems with archiving `Reference` objects: https://github.com/openjdk/jdk/blob/82eb78069ffbaf66ae479d41d850d5999055e0e1/src/hotspot/share/classfile/javaClasses.cpp#L5466
      2. AOT class linking archives enum classes in initialized state: https://bugs.openjdk.org/browse/JDK-8293187
      3. In CRaC JDK `jdk.internal.crac.Core$Priority` enum class always gets initialized during VM init process, its values (contexts) have links to `Reference` objects
      Thus, when AOT class linking creates an archive it always stumbles upon `jdk.internal.crac.Core$Priority` and fails.

      This can be reproduced by dumping a CDS archive with `-XX:+AOTClassLinking` or by running `runtime/cds/appcds` tests (the ones that perform AOT class linking will fail).

      The priority is low because there seems to be no practical reason to use CRaC and AOT class linking together.

            tpushkin Timofei Pushkin
            tpushkin Timofei Pushkin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: