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

CDS should archive only classes allowed by module system

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 17
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b14

      Description

      ClassListParser::load_current_class() tries to archive a boot class from -Xbootclasspath/a into the unnamed package, even if the module system forbids this class from being defined in the unnamed package.

      https://github.com/openjdk/jdk/blob/b482733f94a46f4d0984de7ba55ddb52ad6db34c/src/hotspot/share/classfile/classListParser.cpp#L598

      Such classes, even if archived, won't be usable at runtime anyway. The only test case affected by the above code is test/hotspot/jtreg/runtime/cds/appcds/jigsaw/classpathtests/BootAppendTests.java, which asserts that such class must be archived, but also asserts that such archived classes cannot be used at runtime. So the first assert seems unnecessary and should be removed.

      =======
      Details: BootAppendTests.java tries to archive the class com/sun/tools/javac/MyMain from -Xbootclasspath/a into the unnamed module, but this package is part of the jdk.compiler module, so the module system correctly refuses to load MyMain into the unnamed module. The above referenced line will call into a low level API to force MyMain to be loaded by the boot loader, circumventing the module system.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: