Is it possible to static link jvm?

Bob Vandette bob.vandette at oracle.com
Thu Sep 12 08:43:55 PDT 2013


The hotspot sources do not currently support statically linking.   There are a number
of places in the hotspot sources that would have to be modified in order to support this.

It is only in JDK 8 that we modified the JNI and JVMTI specifications to allow statically linked
JNI libraries.  This is the first step in allowing a completely statically linked VM and Java runtime.

Bob.


On Sep 12, 2013, at 5:17 AM, Isml wrote:

> Hi, everyone!
>     I am reading launcher code(hotspot7u\src\share\tools\launcher etc.) in the hotspot project and see some comments like this(in file hotspot7u\src\os\windows\launcher\java_md.c, line 434):
> 
> jboolean
> LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn)
> {
> #ifdef GAMMA
>    /* JVM is directly linked with gamma launcher; no Loadlibrary() */
>    ifn->CreateJavaVM = JNI_CreateJavaVM;
>    ifn->GetDefaultJavaVMInitArgs = JNI_GetDefaultJavaVMInitArgs;
>    return JNI_TRUE;
> #else
> 
> It seems that jvm could be staticly linked. So I just do some try. After some tiny modifications, I successfully compiled it and link the jvm. But when I run it, it fails with error "unable to find jvm.dll". I debug the code, and find the actual reason why it failes(src\share\vm\runtime\os.cpp, line 385):
> 
> void* os::native_java_library() {
>    dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), "verify");
>    dll_load(buffer, ebuf, sizeof(ebuf));
>     // Load java dll
>    dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), "java");
>    _native_java_library = dll_load(buffer, ebuf, sizeof(ebuf));
> 
> verify.dll and java.dll is designed to be load here, and they all depends on jvm.dll!
> Now I do not how to do, any idea?



More information about the hotspot-dev mailing list