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

Improve warning messages for -XX:+RecordDynamicDumpInfo

    XMLWordPrintable

    Details

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

      Description

      [1] The VM exits with an obscured message when -XX:+RecordDynamicDumpInfo is used with a dynamic archive.

      $ cat > Wait2.java <<END
      public class Wait2 {
          public static void main(String args[]) throws Throwable {
              System.out.println("Type Return to exit");
              System.in.read();
          }
      }
      END
      $ javac Wait2.java
      $ jar cvf Wait2.jar Wait2.class
      $ java -Xlog:cds -cp Wait2.jar -XX:ArchiveClassesAtExit=foo.jsa Wait2

      [this is OK]
      $ java -cp Wait2.jar -XX:SharedArchiveFile=foo.jsa Wait2
      Type Return to exit

      [this fails with obscure message]
      $ java -Xlog:cds -cp Wait2.jar -XX:+RecordDynamicDumpInfo -XX:SharedArchiveFile=foo.jsa Wait2
      [0.031s][info][cds] trying to map foo.jsa
      [0.031s][info][cds] Opened archive foo.jsa.
      [0.031s][info][cds] _magic expected: 0xf00baba2
      [0.031s][info][cds] actual: 0xf00baba8
      [0.031s][info][cds] UseSharedSpaces: The shared archive file has a bad magic number.
      [0.031s][info][cds] UseSharedSpaces: Unable to map shared spaces
      Error occurred during initialization of VM
      DynamicDumpSharedSpaces is unsupported when base CDS archive is not loaded

      ================
      Suggested fix: Print error message "-XX:+RecordDynamicDumpInfo cannot be used when a dynamic archive specified in -XX:SharedArchiveFile: <name of dynamic archive>"




      [2] By default, no reason is printed when -XX:+RecordDynamicDumpInfo is used with -XX:ArchiveClassesAtExit=

      $ java -cp Wait2.jar -XX:+RecordDynamicDumpInfo -XX:ArchiveClassesAtExit=foo.jsa Wait2
      Error: Could not create the Java Virtual Machine.
      Error: A fatal exception has occurred. Program will exit.

      The reason is printed only when -Xlog:cds is enabled:

      $ java -Xlog:cds -cp Wait2.jar -XX:+RecordDynamicDumpInfo -XX:ArchiveClassesAtExit=foo.jsa Wait2
      [0.001s][info][cds] RecordDynamicDumpInfo is for jcmd only, could not set with -XX:ArchiveClassesAtExit.
      Error: Could not create the Java Virtual Machine.
      Error: A fatal exception has occurred. Program will exit.

      ================
      Suggested fix: (use the same style as other checks inside Arguments::finalize_vm_init_args())

          jio_fprintf(defaultStream::output_stream(),
                      "-XX:+RecordDynamicDumpInfo cannot be used with -XX:ArchiveClassesAtExit.\n");




      [3] When -XX:+RecordDynamicDumpInfo is used, unexpected warning is printed at VM exit:

      $ java -cp Wait2.jar -XX:+RecordDynamicDumpInfo Wait2
      Type Return to exit

      [1.478s][warning][cds,dynamic] SharedDynamicArchivePath is not specified
      ================
      Suggested fix: Do try to dump the archive at VM exit when -XX:+RecordDynamicDumpInfo is specified.

        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: