For the Leyden EA, if you dump the CacheDataStore with an incompatible module option, such as --module-path, the dumping operation will continue and *sometimes* mysteriously fail. See JDK-8335735
This fix will quit the VM early and print an explanation message:
$ rm -f hw.cds
$ java --module-path=foo.jar -cp /home/iklam/tmp/HelloWorld.jar -XX:CacheDataStore=hw.cds HelloWorld
[0.000s][warning][cds] optimized module handling/full module graph: disabled due to incompatible property: jdk.module.path=foo.jar
Error occurred during initialization of VM
CacheDataStore cannot be created because PreloadSharedClasses is enabled but full module graph is disabled
or
$ ~/Downloads/ruby/jruby-9.4.8.0/bin/jruby -J-XX:CacheDataStore=jruby.cds -e '10.times { org.jruby.Ruby.newInstance }'
[0.000s][warning][cds] optimized module handling/full module graph: disabled due to incompatible property: jdk.module.addopens=java.base/java.io=org.jruby.dist
Error occurred during initialization of VM
CacheDataStore cannot be created because PreloadSharedClasses is enabled but full module graph is disabled
This fix will quit the VM early and print an explanation message:
$ rm -f hw.cds
$ java --module-path=foo.jar -cp /home/iklam/tmp/HelloWorld.jar -XX:CacheDataStore=hw.cds HelloWorld
[0.000s][warning][cds] optimized module handling/full module graph: disabled due to incompatible property: jdk.module.path=foo.jar
Error occurred during initialization of VM
CacheDataStore cannot be created because PreloadSharedClasses is enabled but full module graph is disabled
or
$ ~/Downloads/ruby/jruby-9.4.8.0/bin/jruby -J-XX:CacheDataStore=jruby.cds -e '10.times { org.jruby.Ruby.newInstance }'
[0.000s][warning][cds] optimized module handling/full module graph: disabled due to incompatible property: jdk.module.addopens=java.base/java.io=org.jruby.dist
Error occurred during initialization of VM
CacheDataStore cannot be created because PreloadSharedClasses is enabled but full module graph is disabled