javabootstrappingruntime-environment

Java: hasJREfinishedInitialization() - how to check if jre has finished loading/initializing all core classes?


Is there a way to check if all boot (core) java classes (belonging to the Java Runtime Environment) have been loaded/initialized for use in Java?

I need to check this in a rare situation where I have have access to the JRE but not to the actual application, so I cannot simply wait for the main application to run and execute from that point on.


Solution

  • The JVM will load classes on an "as-needed" basis, so there's no one point at which "all" of the classes on the bootstrap classpath will have been loaded.

    That said, from 1.5 and onward, the Sun JVMs use "class data sharing" to pre-load a specific set of classes. I don't know which classes get loaded, but would suspect it's limited to those in the java.lang package.

    If you simply want to keep track of when classes get loaded, use the -verbose:class command-line option when starting the JVM.