JDK-8265602 : -XX:DumpLoadedClassList should support custom loaders
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2021-04-20
  • Updated: 2021-08-07
  • Resolved: 2021-08-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 18
18 masterFixed
Related Reports
Relates :  
Relates :  
Description
When running a SpringBoot helloworld program with CDS, we found that the start up is faster with a dynamic archive than with a static archive:

https://github.com/iklam/cds-example/blob/e70b80f4f74d2fa45171d7011e44b379dc48656a/Makefile

# make run0   = no CDS (-Xshare:off)
# make run1   = default CDS archive
# make runs   = static CDS archive
# make rund   = dynamic CDS archive
#
# Example timing (with my JDK 17 personal build/20210420)
#
# run0:    1.702895430 seconds time elapsed   ( +-  0.48% )
# run1:    1.573997668 seconds time elapsed   ( +-  0.26% )
# runs:    1.478010901 seconds time elapsed   ( +-  0.52% )
# rund:    1.397676981 seconds time elapsed   ( +-  0.62% )

=========================
The reason is that classes loaded by custom loaders are supported only by the dynamic archive:

[class,load] org.springframework.util.StopWatch$TaskInfo source: shared objects file (top)
[class,load] .... [loader data ... a 'org/springframework/boot/loader/LaunchedURLClassLoader']

Such classes are not stored in the static archive, so they are loaded from the JAR file at runtime:

[info][class,load] org.springframework.util.StopWatch$TaskInfo source: jar:file:/jdk2/cds-example/target/cds-example-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/spring-core-5.3.6.jar!/


Comments
Changeset: e7b6f481 Author: Ioi Lam <iklam@openjdk.org> Date: 2021-08-06 05:58:48 +0000 URL: https://git.openjdk.java.net/jdk/commit/e7b6f48182bb541741cb1465cd676d1749a028f8
06-08-2021

I have implemented this feature. However, it's not applicable for the spring-boot example yet (due to JDK-8271598). Benefits can be seen with the Eclipse IDE: Static Archive Before: 7.31 sec (classlist does not include custom loader classes) Static Archive After: 6.49 sec (classlist includes custom loader classes) Dynamic Archive: 6.62 sec
02-08-2021

This shows the number of classes from "org*" packages that are NOT loaded from "shared objects file" (i.e., CDS archive). There are many more of these when the static archive is used: $ java -Xshare:on -XX:SharedArchiveFile=static.jsa -Xlog:class+load -jar tarcds-example-0.0.1-SNAPSHOT.jar | grep org | grep -v shared.object | wc 1663 6652 335219 $ java -Xshare:on -XX:SharedArchiveFile=dynamic.jsa -Xlog:class+load -jar target/cds-example-0.0.1-SNAPSHOT.jar | grep org | grep -v shared.object | wc 584 2336 115038 Note: due to JDK-8265604 some classes (loaded by custom loaders) are still not archived in the dynamic archive: $ make dynamic.jsa 2>1 | tee dynamic.log $ grep Not.l dynamic.log | wc 278 1390 28237
12-05-2021