tags:

views:

84

answers:

2

What are the functions of the JVM? All I know are:

  • JIT compiler
  • GC
  • memory allocator

What are the steps it does when you load a Java application?

I am wondering because if I compare the loading time of a Java application with these steps:

  • InitializeNativeTarget on LLVM
  • some GC initialization
  • some Qt/GTK/whatever init
  • some JIT/ahead compilation of parts of the app
  • the app init itself

It seems to me that the JVM takes much longer to load than it would take to do the steps I listed above. So what does it do in addition to that?

+1  A: 

That's actually a very interesting question - to see for yourself, run a Hello World program giving the option -XX:-TraceClassLoading to the java executable.

Tassos Bassoukos
Also turn on GC logging.
Stephen C
I tried `java -verbose:gc -XX:-TraceClassLoading JavaHelloWorld` but all it outputs is just `Hello World`. Do I miss something?
Albert
@Albert: `-XX:+TraceClassLoading`
Stephen C
Hm, that seems to just show me what classes are loaded by the JVM (which is *a lot*). But what is the JVM itself doing before that? And what could be stripped out of that? Because it seems to me that it does not need almost any of the stuff which shows up there.
Albert
A: 

It bootstraps the whole JVM from scratch. That takes a while.

Thorbjørn Ravn Andersen
How exactly does the bootstrap looks like?
Albert
Use the "-verbose" flag to see each class as it is pulled in by a class loader. You might be surprised...
Thorbjørn Ravn Andersen