RFR: 8327495: Print more warning with -Xshare:auto when CDS fails to use archive [v3]

Ioi Lam iklam at openjdk.org
Tue Apr 29 00:09:46 UTC 2025


On Mon, 28 Apr 2025 23:58:21 GMT, Ioi Lam <iklam at openjdk.org> wrote:

>> Calvin Cheung has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   @iklam comment
>
> src/hotspot/share/cds/cdsConfig.cpp line 654:
> 
>> 652:     // message from the classlist as it interferes with the default CDS archive creation.
>> 653:     return true;
>> 654:   }
> 
> I check the Makefiles, and the situation you are trying to avoid is this part in make/GenerateLinkOptData.gmk:
> 
> 
> 	$(FIXPATH) $(INTERIM_IMAGE_DIR)/bin/java \
> 	    -cp $(SUPPORT_OUTPUTDIR)/classlist.jar \
> 	    build.tools.classlist.SortClasslist $@.raw.4 > $@
> 
> 
> After adding `-Xlog:cds=/tmp/foo.txt` to the above command, I get the following in the log file:
> 
> 
> [0.004s][info][cds] trying to map /jdk3/bld/tin/support/interim-image/lib/server/classes.jsa
> [0.004s][info][cds] Specified shared archive file not found (/jdk3/bld/tin/support/interim-image/lib/server/classes.jsa)
> [0.004s][info][cds] An error has occurred while processing the shared archive file.
> [0.004s][info][cds] Loading static archive failed.
> [0.004s][error][cds] An error has occurred while processing the shared archive file.
> [0.004s][error][cds] Unable to map shared spaces
> 
> 
> I think the `!is_using_archive()` shouldn't be in this function. Instead it should be in `MetaspaceShared::report_loading_error()`:
> 
> 
> LogStream& ls = (!CDSConfig::is_using_archive()) || CDSConfig::is_using_only_default_archive() ? ls_info : ls_error;

I found that with AOT class linking, we need better diagnostics. E.g.:


$ java -cp HelloWorld.jar -XX:AOTMode=record -XX:AOTConfiguration=hw.aotconfig HelloWorld
Hello World
AOTConfiguration recorded: hw.aotconfig

$ java -cp HelloWorld.jar -XX:AOTMode=create -XX:AOTCache=hw.aot -XX:AOTConfiguration=hw.aotconfig
Reading AOTConfiguration hw.aotconfig and writing AOTCache hw.aot
AOTCache creation is complete: hw.aot 9682944 bytes

$ java --add-modules=java.base -cp HelloWorld.jar -XX:AOTMode=on -XX:AOTCache=hw.aot HelloWorld
[0.005s][error][cds] CDS archive has aot-linked classes. It cannot be used when archived full module graph is not used.
Error occurred during initialization of VM
Unable to use AOT cache.


It's not clear why "full module graph is not used". I added the following patch on to of your PR:

https://github.com/iklam/jdk/commit/a2ca2c01eb340c85f24783969142019bcfcc97f0

Now there's a better explanation:


$ java --add-modules=java.base -cp HelloWorld.jar -XX:AOTMode=on -XX:AOTCache=hw.aot HelloWorld
[0.017s][error][cds] An error has occurred while processing the AOT cache. Run with -Xlog:cds for details.
[0.017s][error][cds] Mismatched values for property jdk.module.addmods: java.base specified during runtime but not during dump time
[0.017s][error][cds] Disabling optimized module handling
[0.017s][error][cds] CDS archive has aot-linked classes. It cannot be used when archived full module graph is not used.
Error occurred during initialization of VM
Unable to use AOT cache.


Could you check other cases where the FMG is disabled and change their error reporting to use `MetaspaceShared::report_loading_error()`

Also, we have a few messages that says: "CDS archive has aot-linked classes ...". I think these should be changed to use `CDSConfig::type_of_archive_being_loaded()`.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/24889#discussion_r2065078518


More information about the hotspot-runtime-dev mailing list