Creating JVM
Sparse Way
support at sparseway.com
Sun Mar 3 12:14:54 UTC 2019
JVM is created after removing #if defined(__OpenBSD__) from os::native_java_library().
Best regards
________________________________
From: mobile-dev <mobile-dev-bounces at openjdk.java.net> on behalf of Sparse Way <support at sparseway.com>
Sent: Sunday, March 3, 2019 1:45 PM
To: David Holmes; mobile-dev at openjdk.java.net
Subject: Re: Creating JVM
Hi David,
The library libnet.so is in jre/lib but still reported missing.
03-03 13:07:56.747 6164-6164/? D/JVM: Exception <a 'java/lang/UnsatisfiedLinkError'{0x02c5d010}: /storage/emulated/legacy/jre/lib/libnio.so: dlopen failed: library "libnet.so" not found>
thrown in interpreter method <{method} {0x6b69ae50} 'bindArgumentL' '(ILjava/lang/Object;)Ljava/lang/invoke/BoundMethodHandle;' in 'java/lang/invoke/MethodHandle'>
at bci 6 for thread 0xa05cb81
Arguments::get_dll_dir() returns correct path jre/lib; other libraries are found and loaded:
03-03 13:44:36.847 11824-11824/com.sparseway.example W/linker: libocldvk.so: unused DT entry: type 0x6ffffffe arg 0xa1c
03-03 13:44:36.847 11824-11824/com.sparseway.example W/linker: libocldvk.so: unused DT entry: type 0x6fffffff arg 0x2
03-03 13:44:36.847 11824-11824/com.sparseway.example W/linker: libjvm.so: unused DT entry: type 0x6ffffffe arg 0x4438
03-03 13:44:36.847 11824-11824/com.sparseway.example W/linker: libjvm.so: unused DT entry: type 0x6fffffff arg 0x3
03-03 13:44:36.867 11824-11824/com.sparseway.example W/linker: libverify.so: unused DT entry: type 0x6ffffffe arg 0xbf8
03-03 13:44:36.867 11824-11824/com.sparseway.example W/linker: libverify.so: unused DT entry: type 0x6fffffff arg 0x2
03-03 13:44:36.867 11824-11824/com.sparseway.example W/linker: libjava.so: unused DT entry: type 0x6ffffffe arg 0x6880
03-03 13:44:36.867 11824-11824/com.sparseway.example W/linker: libjava.so: unused DT entry: type 0x6fffffff arg 0x4
03-03 13:44:36.917 11824-11824/com.sparseway.example W/linker: libzip.so: unused DT entry: type 0x6ffffffe arg 0x10a8
03-03 13:44:36.917 11824-11824/com.sparseway.example W/linker: libzip.so: unused DT entry: type 0x6fffffff arg 0x3
03-03 13:44:36.917 11824-11824/com.sparseway.example W/linker: libjimage.so: unused DT entry: type 0x6ffffffe arg 0x954
03-03 13:44:36.917 11824-11824/com.sparseway.example W/linker: libjimage.so: unused DT entry: type 0x6fffffff arg 0x2
03-03 13:44:37.567 11824-11824/com.sparseway.example W/linker: libnio.so: unused DT entry: type 0x6ffffffe arg 0x4174
03-03 13:44:37.567 11824-11824/com.sparseway.example W/linker: libnio.so: unused DT entry: type 0x6fffffff arg 0x4
There is a workaround in hotspot/src/share/vm/runtime/os.cpp maybe it relates somehow:
void* os::native_java_library() {
...
#if defined(__OpenBSD__)
// Work-around OpenBSD's lack of $ORIGIN support by pre-loading libnet.so
// ignore errors
if (dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(),
"net")) {
dll_load(buffer, ebuf, sizeof(ebuf));
}
#endif
}
return _native_java_library;
}
Best regards
________________________________
From: David Holmes <david.holmes at oracle.com>
Sent: Sunday, March 3, 2019 9:26 AM
To: Sparse Way; mobile-dev at openjdk.java.net
Subject: Re: Creating JVM
Try turning on all logging:
-Xlog:all=trace
and see what it shows.
David
-----
On 3/03/2019 11:24 am, Sparse Way wrote:
> 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