jdk/src/windows/bin/java_md.c
changeset 8197 e45f21c2a40b
parent 7256 adb296cc2eae
child 9035 1255eb81cc2f
child 9831 4f307b4eb741
equal deleted inserted replaced
7867:f83cd8bd35c6 8197:e45f21c2a40b
    47  */
    47  */
    48 static jboolean GetPublicJREHome(char *path, jint pathsize);
    48 static jboolean GetPublicJREHome(char *path, jint pathsize);
    49 static jboolean GetJVMPath(const char *jrepath, const char *jvmtype,
    49 static jboolean GetJVMPath(const char *jrepath, const char *jvmtype,
    50                            char *jvmpath, jint jvmpathsize);
    50                            char *jvmpath, jint jvmpathsize);
    51 static jboolean GetJREPath(char *path, jint pathsize);
    51 static jboolean GetJREPath(char *path, jint pathsize);
    52 static void EnsureJreInstallation(const char *jrepath);
       
    53 
    52 
    54 /* We supports warmup for UI stack that is performed in parallel
    53 /* We supports warmup for UI stack that is performed in parallel
    55  * to VM initialization.
    54  * to VM initialization.
    56  * This helps to improve startup of UI application as warmup phase
    55  * This helps to improve startup of UI application as warmup phase
    57  * might be long due to initialization of OS or hardware resources.
    56  * might be long due to initialization of OS or hardware resources.
   198     /* Find out where the JRE is that we will be using. */
   197     /* Find out where the JRE is that we will be using. */
   199     if (!GetJREPath(jrepath, so_jrepath)) {
   198     if (!GetJREPath(jrepath, so_jrepath)) {
   200         JLI_ReportErrorMessage(JRE_ERROR1);
   199         JLI_ReportErrorMessage(JRE_ERROR1);
   201         exit(2);
   200         exit(2);
   202     }
   201     }
   203 
       
   204     /* Do this before we read jvm.cfg and after jrepath is initialized */
       
   205     EnsureJreInstallation(jrepath);
       
   206 
   202 
   207     /* Find the specified JVM type */
   203     /* Find the specified JVM type */
   208     if (ReadKnownVMs(jrepath, (char*)GetArch(), JNI_FALSE) < 1) {
   204     if (ReadKnownVMs(jrepath, (char*)GetArch(), JNI_FALSE) < 1) {
   209         JLI_ReportErrorMessage(CFG_ERROR7);
   205         JLI_ReportErrorMessage(CFG_ERROR7);
   210         exit(1);
   206         exit(1);
   294         loaded = 1;
   290         loaded = 1;
   295     }
   291     }
   296     return JNI_TRUE;
   292     return JNI_TRUE;
   297 }
   293 }
   298 
   294 
   299 /*
       
   300  * The preJVMStart is a function in the jkernel.dll, which
       
   301  * performs the final step of synthesizing back the decomposed
       
   302  * modules  (partial install) to the full JRE. Any tool which
       
   303  * uses the  JRE must peform this step to ensure the complete synthesis.
       
   304  * The EnsureJreInstallation function calls preJVMStart based on
       
   305  * the conditions outlined below, noting that the operation
       
   306  * will fail silently if any of conditions are not met.
       
   307  * NOTE: this call must be made before jvm.dll is loaded, or jvm.cfg
       
   308  * is read, since jvm.cfg will be modified by the preJVMStart.
       
   309  * 1. Are we on a supported platform.
       
   310  * 2. Find the location of the JRE or the Kernel JRE.
       
   311  * 3. check existence of JREHOME/lib/bundles
       
   312  * 4. check jkernel.dll and invoke the entry-point
       
   313  */
       
   314 typedef VOID (WINAPI *PREJVMSTART)();
       
   315 
       
   316 static void
       
   317 EnsureJreInstallation(const char* jrepath)
       
   318 {
       
   319     HINSTANCE handle;
       
   320     char tmpbuf[MAXPATHLEN];
       
   321     PREJVMSTART PreJVMStart;
       
   322     struct stat s;
       
   323 
       
   324     /* Make sure the jrepath contains something */
       
   325     if ((void*)jrepath[0] == NULL) {
       
   326         return;
       
   327     }
       
   328     /* 32 bit windows only please */
       
   329     if (JLI_StrCmp(GetArch(), "i386") != 0 ) {
       
   330         return;
       
   331     }
       
   332     /* Does our bundle directory exist ? */
       
   333     JLI_Snprintf(tmpbuf, sizeof(tmpbuf), "%s\\lib\\bundles", jrepath);
       
   334     JLI_TraceLauncher("EnsureJreInstallation: %s\n", tmpbuf);
       
   335     if (stat(tmpbuf, &s) != 0) {
       
   336         return;
       
   337     }
       
   338     /* Does our jkernel dll exist ? */
       
   339     JLI_Snprintf(tmpbuf, sizeof(tmpbuf), "%s\\bin\\jkernel.dll", jrepath);
       
   340     if (stat(tmpbuf, &s) != 0) {
       
   341         return;
       
   342     }
       
   343     /* The Microsoft C Runtime Library needs to be loaded first. */
       
   344     if (!LoadMSVCRT()) {
       
   345         return;
       
   346     }
       
   347     /* Load the jkernel.dll */
       
   348     if ((handle = LoadLibrary(tmpbuf)) == 0) {
       
   349         return;
       
   350     }
       
   351     /* Get the function address */
       
   352     PreJVMStart = (PREJVMSTART)GetProcAddress(handle, "preJVMStart");
       
   353     if (PreJVMStart == NULL) {
       
   354         FreeLibrary(handle);
       
   355         return;
       
   356     }
       
   357     PreJVMStart();
       
   358     FreeLibrary(handle);
       
   359     return;
       
   360 }
       
   361 
   295 
   362 /*
   296 /*
   363  * Find path to JRE based on .exe's location or registry settings.
   297  * Find path to JRE based on .exe's location or registry settings.
   364  */
   298  */
   365 jboolean
   299 jboolean