@@ -24,15 +24,16 @@ To create the archive, two additional JVM flags must be specified:
24
24
* `-Dspring.context.exit=onRefresh`: starts and then immediately exits your Spring
25
25
application as described above
26
26
27
- To create a CDS archive, your JDK must have a base image. If you add the flags above to
27
+ To create a CDS archive, your JDK/JRE must have a base image. If you add the flags above to
28
28
your startup script, you may get a warning that looks like this:
29
29
30
30
[source,shell,indent=0,subs="verbatim"]
31
31
----
32
32
-XX:ArchiveClassesAtExit is unsupported when base CDS archive is not loaded. Run with -Xlog:cds for more info.
33
33
----
34
34
35
- The base CDS archive can be created by issuing the following command:
35
+ The base CDS archive is usually provided out-of-the-box, but can also be created if needed by issuing the following
36
+ command:
36
37
37
38
[source,shell,indent=0,subs="verbatim"]
38
39
----
@@ -44,6 +45,9 @@ The base CDS archive can be created by issuing the following command:
44
45
Once the archive is available, add `-XX:SharedArchiveFile=application.jsa` to your startup
45
46
script to use it, assuming an `application.jsa` file in the working directory.
46
47
48
+ To check if the CDS cache is effective, you can use (for testing purposes only, not in production) `-Xshare:on` which
49
+ prints an error message and exits if CDS can't be enabled.
50
+
47
51
To figure out how effective the cache is, you can enable class loading logs by adding
48
52
an extra attribute: `-Xlog:class+load:file=cds.log`. This creates a `cds.log` with every
49
53
attempt to load a class and its source. Classes that are loaded from the cache should have
@@ -58,8 +62,11 @@ a "shared objects file" source, as shown in the following example:
58
62
[0.065s][info][class,load] org.springframework.context.MessageSource source: shared objects file (top)
59
63
----
60
64
61
- TIP: If you have a large number of classes that are not loaded from the cache, make sure that
62
- the JDK and classpath used by the commands that create the archive and start the application
63
- are identical. Note also that to effectively cache classes, the classpath should be specified
64
- as a list of JARs containing those classes, and avoid the usage of directories and `*`
65
- wildcard characters.
65
+ If CDS can't be enabled or if you have a large number of classes that are not loaded from the cache, make sure that
66
+ the following conditions are fulfilled when creating and using the archive:
67
+
68
+ - The very same JVM must used.
69
+ - The classpath must be specified as a list of JARs, and avoid the usage of directories and `*` wildcard characters.
70
+ - The timestamps of the JARs must be preserved.
71
+ - When using the archive, the classpath must be the same than the one used to create the archive, in the same order.
72
+ Additional JARs or directories can be specified *at the end* (but won't be cached).
0 commit comments