JDK-8276787 : Improve warning messages for -XX:+RecordDynamicDumpInfo
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 18
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2021-11-07
  • Updated: 2024-10-04
  • Resolved: 2021-11-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 18
18 b24Fixed
Related Reports
Relates :  
Relates :  
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.

Comments
Changeset: a77d8ddf Author: Ioi Lam <iklam@openjdk.org> Date: 2021-11-16 21:03:33 +0000 URL: https://git.openjdk.java.net/jdk/commit/a77d8ddf11fba33007a4f5c0468d69de23f10f6a
16-11-2021