Tom
Tom

Reputation: 8127

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.

Upvotes: 0

Views: 179

Answers (2)

Anon
Anon

Reputation: 71

having read your comments (and accidentally deleted my cookie), all I can say is that JVMTI is pretty much guaranteed to be a much better choice for whatever it is that you're trying to do.

But if you're hell-bent on modifying a JRE class, why not simply add a static boolean variable that will get set during FileWriter initialization?

Upvotes: 0

Anon
Anon

Reputation: 26

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.

Upvotes: 1

Related Questions