Creating JVM
Sparse Way
support at sparseway.com
Sun Mar 3 01:24:53 UTC 2019
Hello,
How does the JVM locate and load java base classes during its creation process?
Since JVM exits at call_initPhase2(TRAPS) in Threads::create_vm without a stack trace or an exception.
hotspot/src/share/vm/runtime/thread.cpp:
...
// Phase 2. Module system initialization
// This will initialize the module system. Only java.base classes
// can be loaded until phase 2 completes.
//
// Call System.initPhase2 after the compiler initialization and jsr292
// classes get initialized because module initialization runs a lot of java
// code, that for performance reasons, should be compiled. Also, this will
// enable the startup code to use lambda and other language features in this
// phase and onward.
//
// After phase 2, The VM will begin search classes from -Xbootclasspath/a.
static void call_initPhase2(TRAPS) {
TraceTime timer("Phase2 initialization", TRACETIME_LOG(Info, module, startuptime));
Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), true, CHECK);
instanceKlassHandle klass (THREAD, k);
JavaValue result(T_INT);
JavaCallArguments args;
args.push_int(DisplayVMOutputToStderr);
args.push_int(log_is_enabled(Debug, init)); // print stack trace if exception thrown
JavaCalls::call_static(&result, klass, vmSymbols::initPhase2_name(),
vmSymbols::boolean_boolean_int_signature(), &args, CHECK);
if (result.get_jint() != JNI_OK) {
vm_exit_during_initialization(); // no message or exception
}
universe_post_module_init();
}
...
Specifically when calling java.lang.System.initPhase2(boolean printToStderr, boolean printStackTrace) statically.
JVM options: "-Djava.home=" + jre,
"--patch-module=" + ext + "java.base=src"
Replacing --patch-module with -Xbootclasspath/a will not help.
I am not sure if base classes are loaded in the first place.
Best regards
More information about the mobile-dev
mailing list