Call graph for some key methods in JVM startup:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
main()  [src/java.base/share/native/launcher/main.c]

└─▶ JLI_Launch() [src/java.base/share/native/libjli/java.c]

├─▶ LoadJavaVM(jvmpath, &ifn) // dlopen libjvm; bind JNI functions

├─▶ ParseArguments() // Parse args; populate options[]

└─▶ JVMInit(&ifn, ...) // [src/java.base/unix/native/libjli/java_md.c]

└─▶ ContinueInNewThread()

└─▶ CallJavaMainInNewThread() // Create thread for JavaMain

└─▶ JavaMain(void* _args) [src/java.base/share/native/libjli/java.c]

├─▶ InitializeJVM() // Calls ifn->CreateJavaVM
│ │
│ └─▶ Threads::create_vm() [src/hotspot/share/runtime/threads.cpp]
│ ├─▶ init_globals() // JIT, GC, modules, CDS
│ └─▶ VMThread::create()

├─▶ LoadMainClass()


└─▶ invokeStaticMainWithArgs()

└─▶ (*env)->CallStaticVoidMethod

Files involved:

  • src/java.base/share/native/launcher/main.c

    The entry point of the launcher. As the filename suggests, this contains the main function.

  • src/java.base/share/native/libjli/java.c

    The platform-independent portion of the JVM startup sequence. This orchestrates argument parsing, VM initialization, and eventually calling into Java.

  • src/java.base/unix/native/libjli/java_md.c

    The platform-specific layer supporting java.c. It implements OS-dependent functionality such as thread creation and process setup on Unix-like systems.

  • src/hotspot/share/runtime/threads.cpp

    The VM-internal logic for creating and managing various JVM threads, including the JIT compiler threads, GC threads, and the VM thread itself.