JDK-8066670 : -XX:+PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 8u40,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2014-12-04
  • Updated: 2015-06-03
  • Resolved: 2014-12-05
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 8 JDK 9
8u40Fixed 9 b44Fixed
Related Reports
Relates :  
Description
When JDK-8046070 was integrated to JDK9 and 8u40, a merge error cause incorrect handling of -XX:+PrintSharedArchiveAndExit.

If the archive is valid, the JVM quits immediately after checking the validity of the archive. This is expected behavior.

However, if the archive is invalid, after checking the validity of the archive, the JVM would continue executing with CDS disabled. The expected behavior is that the JVM should quit immediately.

$ /tmp/8u40/bin/java -version
java version "1.8.0_40-ea"
Java(TM) SE Runtime Environment (build 1.8.0_40-ea-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b21, mixed mode)
$ chmod a+w /tmp/8u40/jre/lib/amd64/server/
$ /tmp/8u40/bin/java -Xshare:dump
Allocated shared space: 37871616 bytes at 0x0000000800000000
Loading classes to share ...
Preload Warning: Cannot find java/lang/UNIXProcess$2
Preload Warning: Cannot find java/lang/UNIXProcess$3
Preload Warning: Cannot find java/lang/UNIXProcess$4
Preload Warning: Cannot find java/lang/UNIXProcess$ProcessReaperThreadFactory
Preload Warning: Cannot find java/lang/UNIXProcess$ProcessReaperThreadFactory$1
Preload Warning: Cannot find javax/swing/JComponent$2
Preload Warning: Cannot find javax/swing/plaf/metal/MetalLookAndFeel$MetalLazyValue
Preload Warning: Cannot find javax/swing/plaf/metal/MetalLookAndFeel$MetalLazyValue$1
Preload Warning: Cannot find javax/swing/text/AbstractDocument$InsertStringResult
Preload Warning: Cannot find sun/awt/X11/XErrorHandler$XErrorHandlerWithFlag
Preload Warning: Cannot find sun/awt/X11/XErrorHandler$XShmAttachHandler
Preload Warning: Cannot find sun/awt/X11/XToolkit$2$1
Preload Warning: Cannot find sun/java2d/Disposer$2
Loading classes to share: done.
Rewriting and linking classes ...
Rewriting and linking classes: done
Number of classes 2454
    instance classes   =  2440
    obj array classes  =     6
    type array classes =     8
Calculating fingerprints ... done. 
Removing unshareable information ... done. 
Shared Lookup Cache Table Buckets = 8216 bytes
Shared Lookup Cache Table Body = 65240 bytes
ro space:   6991720 [ 36.2% of total] out of  16777216 bytes [41.7% used] at 0x0000000800000000
rw space:  10720624 [ 55.4% of total] out of  16777216 bytes [63.9% used] at 0x0000000801000000
md space:   1591504 [  8.2% of total] out of   4194304 bytes [37.9% used] at 0x0000000802000000
mc space:     34053 [  0.2% of total] out of    122880 bytes [27.7% used] at 0x0000000802400000
total   :  19337901 [100.0% of total] out of  37871616 bytes [51.1% used]

$ /tmp/8u40/bin/java -Xshare:on -version
java version "1.8.0_40-ea"
Java(TM) SE Runtime Environment (build 1.8.0_40-ea-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b21, mixed mode, sharing)


$ /tmp/8u40/bin/java -Xshare:on -XX:+PrintSharedArchiveAndExit -version
[type=BOOT Expecting -Dsun.boot.class.path=/tmp/8u40/jre/lib/resources.jar:/tmp/8u40/jre/lib/rt.jar:/tmp/8u40/jre/lib/sunrsasign.jar:/tmp/8u40/jre/lib/jsse.jar:/tmp/8u40/jre/lib/jce.jar:/tmp/8u40/jre/lib/charsets.jar:/tmp/8u40/jre/lib/jfr.jar:/tmp/8u40/jre/classes]
[ok]
[type=NON_EXIST Expecting that /tmp/8u40/jre/lib/sunrsasign.jar does not exist]
[ok]
[type=NON_EXIST Expecting that /tmp/8u40/jre/classes does not exist]
[ok]
[type=REQUIRED Expecting that file /tmp/8u40/jre/lib/meta-index must exist and is not altered]
[ok]
[Checking shared classpath entry: /tmp/8u40/jre/lib/resources.jar]
[ok]
[Checking shared classpath entry: /tmp/8u40/jre/lib/rt.jar]
[ok]
[Checking shared classpath entry: /tmp/8u40/jre/lib/jsse.jar]
[ok]
[Checking shared classpath entry: /tmp/8u40/jre/lib/jce.jar]
[ok]
[Checking shared classpath entry: /tmp/8u40/jre/lib/charsets.jar]
[ok]
[Checking shared classpath entry: /tmp/8u40/jre/lib/jfr.jar]
[ok]
archive is valid

^---- NOTE: version info is not printed. This is correct.


# make the archive invalid by changing timestamp of rt.jar
$ touch /tmp/8u40/jre/lib/rt.jar
$ /tmp/8u40/bin/java -Xshare:on -XX:+PrintSharedArchiveAndExit -version
[type=BOOT Expecting -Dsun.boot.class.path=/tmp/8u40/jre/lib/resources.jar:/tmp/8u40/jre/lib/rt.jar:/tmp/8u40/jre/lib/sunrsasign.jar:/tmp/8u40/jre/lib/jsse.jar:/tmp/8u40/jre/lib/jce.jar:/tmp/8u40/jre/lib/charsets.jar:/tmp/8u40/jre/lib/jfr.jar:/tmp/8u40/jre/classes]
[ok]
[type=NON_EXIST Expecting that /tmp/8u40/jre/lib/sunrsasign.jar does not exist]
[ok]
[type=NON_EXIST Expecting that /tmp/8u40/jre/classes does not exist]
[ok]
[type=REQUIRED Expecting that file /tmp/8u40/jre/lib/meta-index must exist and is not altered]
[ok]
[Checking shared classpath entry: /tmp/8u40/jre/lib/resources.jar]
[ok]
[Checking shared classpath entry: /tmp/8u40/jre/lib/rt.jar]
[Timestamp mismatch]
[Checking shared classpath entry: /tmp/8u40/jre/lib/jsse.jar]
[ok]
[Checking shared classpath entry: /tmp/8u40/jre/lib/jce.jar]
[ok]
[Checking shared classpath entry: /tmp/8u40/jre/lib/charsets.jar]
[ok]
[Checking shared classpath entry: /tmp/8u40/jre/lib/jfr.jar]
[ok]
[Opened /tmp/8u40/jre/lib/rt.jar]
java version "1.8.0_40-ea"
Java(TM) SE Runtime Environment (build 1.8.0_40-ea-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b21, mixed mode)

^---- continues to execute after validation, and runs with CDS disabled.