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

Automatically generate the CDS archive if necessary

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: In Progress
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 17
    • Fix Version/s: 18
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Understanding:
      Fix Understood

      Description

      Currently, you must explicitly create the CDS archive before using it (with -Xshare:dump or -XX:ArchiveClassesAtExit).

      For example, a program needs to be started by a script like this:

      if test ! -f foo.jsa; then
        java -XX:ArchiveClassesAtExit=foo.jsa -cp foo.jar Foo
      else
        java -XX:ShareArchiveFile=foo.jsa -cp foo.jar Foo
      fi

      However, even this won't handle the case when you upgrade your JDK. So the script will need to do JDK version checking as well. This makes it inconvenient to use CDS.

      To improve usability, we should allow the CDS archive to be automatically generated if necessary (e.g., if the specified archive doesn't exist, or if it's out of date because you have updated the JDK).

      Perhaps we can have a new JVM options like this:

      java -XX:+AutoCreateSharedArchive -XX:SharedArchiveFile=foo.jsa -cp foo.jar Foo

      If foo.jsa doesn't exist, or if it was generated for a different version of the JDK, DynamicDumpSharedSpaces will be enabled automatically, and foo.jsa will be created when the Java process exits. When the app is launched again, it will be able to use foo.jsa.

      This can be built on top of the facilities added by JDK-8259070.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              minqi Yumin Qi
              Reporter:
              iklam Ioi Lam
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated: