When a CDS archive fails to load, we should print more helpful messages so that the user can diagnose the error more easily. This should be done for both static and dynamic archives.
===========================================
~/tmp/8279366/copied$ java -cp HelloWorld.jar --show-version -XX:SharedArchiveFile=HelloWorld.jsa HelloWorld
[0.028s][warning][cds,dynamic] Unable to use shared archive. The top archive failed to load: HelloWorld.jsa
java 17 2021-09-14 LTS
Java(TM) SE Runtime Environment (build 17+35-LTS-2724)
Java HotSpot(TM) 64-Bit Server VM (build 17+35-LTS-2724, mixed mode, sharing)
Hello World
In the above message, we should also print something like:
Hint: enable -Xlog:class+path=info to diagnose the failure
===========================================
~/tmp/8279366/copied$ java -Xlog:class+path -cp HelloWorld.jar --show-version -XX:SharedArchiveFile=HelloWorld.jsa HelloWorld
[0.002s][info][class,path] bootstrap loader class path=/jdk/official/jdk17/lib/modules
[0.032s][info][class,path] Expecting BOOT path=/jdk/official/jdk17/lib/modules
[0.032s][info][class,path] Expecting -Djava.class.path=
[0.032s][info][class,path] checking shared classpath entry: /jdk/official/jdk17/lib/modules
[0.032s][info][class,path] ok
[0.032s][info][class,path] Expecting BOOT path=/jdk/official/jdk17/lib/modules
[0.032s][info][class,path] Expecting -Djava.class.path=HelloWorld.jar
[0.032s][info][class,path] checking shared classpath entry: /jdk/official/jdk17/lib/modules
[0.032s][info][class,path] ok
[0.032s][info][class,path] checking shared classpath entry: HelloWorld.jar
[0.032s][warning][cds,dynamic] Unable to use shared archive. The top archive failed to load: HelloWorld.jsa
java 17 2021-09-14 LTS
Java(TM) SE Runtime Environment (build 17+35-LTS-2724)
Java HotSpot(TM) 64-Bit Server VM (build 17+35-LTS-2724, mixed mode, sharing)
Hello World
In the above message, we should also print something like:
HelloWorld.jar timestamp has changed