Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Dynamic Class Data Sharing not using the archive file

We are trying to use Dynamic Class Data Sharing (Dynamic CDS) with our spring boot application.

Created the CDS archive using the following command

java -Xlog:cds -XX:DumpLoadedClassList=cds.jsa -jar app-0.0.1-SNAPSHOT.jar

And trying to use the archive using the following command

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

java -Xlog:cds -XX:SharedArchiveFile=cds.jsa -jar app-0.0.1-SNAPSHOT.jar

But getting the following error in the beginning of the application startup

[0.009s][info][cds] trying to map cds.jsa
[0.009s][info][cds] Opened archive cds.jsa.
[0.009s][info][cds] _magic expected: 0xf00baba2
[0.009s][info][cds]          actual: 0x4f4e2023
[0.009s][info][cds] UseSharedSpaces: The shared archive file has a bad magic number.
[0.009s][info][cds] UseSharedSpaces: Unable to map shared spaces

openjdk version "17" 2021-09-14 (build 17+35-2724)
Springboot 2.6.3

>Solution :

The option --XX:DumpLoadedClassList=cds.jsa does not create a CDS archive – it is one step in creating a static CDS Archive File.

To create a Dynamic CDS Archive file you must use

java -Xlog:cds -XX:ArchiveClassesAtExit=cds.jsa -jar app-0.0.1-SNAPSHOT.jar

Source: https://docs.oracle.com/en/java/javase/17/docs/specs/man/java.html#creating-cds-archives

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading