JDK-8182731 : Odd handling of -XX:-UseAppCDS and -XX:SharedArchiveFile
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2017-06-22
  • Updated: 2019-06-20
  • Resolved: 2018-04-30
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 11
11 b12Fixed
Related Reports
Relates :  
Relates :  
Description
While while testing a thing with AppCDS on/off, I found if you just switch to -XX:-UseAppCDS and leave all the other AppCDS options in place, you get an error about 
Error: VM option 'SharedArchiveFile' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions.

which is weird since you dont need explicit  +UnlockDiagnosticVMOptions to use AppCDS.

$ /tmp/jdk/bin/java  -Xshare:on -XX:+UnlockCommercialFeatures -XX:SharedArchiveFile=Netty.jsa   -XX:+UseAppCDS  --add-modules=java.se.ee --upgrade-module-path /home/eric/views/javax.annotation-api-1.2/target/javax.annotation-api-1.2.jar -jar target/jersey-netty-app-1.0-SNAPSHOT.jar
Jun 22, 2017 4:57:45 PM app.App main
INFO: Prometheus intializing JVM metrics
Jun 22, 2017 4:57:45 PM app.App main
INFO: Netty starting
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by io.netty.util.internal.ReflectionUtil (file:/home/eric/views/ccc-jersey-netty-app/target/jersey-netty-app-1.0-SNAPSHOT.jar) to constructor java.nio.DirectByteBuffer(long,int)
WARNING: Please consider reporting this to the maintainers of io.netty.util.internal.ReflectionUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Jun 22, 2017 4:57:45 PM app.App main
INFO: Netty started

[In the above case the app worked with AppCDS on]


$ /tmp/jdk/bin/java  -Xshare:on -XX:+UnlockCommercialFeatures -XX:SharedArchiveFile=Netty.jsa   -XX:-UseAppCDS  --add-modules=java.se.ee --upgrade-module-path /home/eric/views/javax.annotation-api-1.2/target/javax.annotation-api-1.2.jar -jar target/jersey-netty-app-1.0-SNAPSHOT.jar
Error: VM option 'SharedArchiveFile' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions.
Error: The unlock option must precede 'SharedArchiveFile'.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.



Comments
This RFE is no longer relevant because we are obsoleting the UseAppCDS flag (JDK-8193213).
28-02-2018