Ignore:
Timestamp:
Jul 18, 2012, 9:37:38 PM (13 years ago)
Author:
dmik
Message:

Make sure BEGINLIBPATH is not necessary when loading JVM.

BEGINLIBPATH is not necessary at all now: neither when loading the JVM
with standard launchers (like java.exe) nor when doing JVM.DLL directly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/openjdk/jdk/src/windows/bin/java_md.c

    r390 r395  
    234234#ifdef __WIN32OS2__
    235235    /*
    236      * Native OS/2 LX DLLs support importing functions from other DLLs using
    237      * relocation fixup records which differs from the Win32 PE format that does
    238      * this through the IAT (import address table - a table of function
    239      * pointers). As a result, if DLL_A imports something from DLL_B, then when
    240      * DLL_A is loaded by a process, it will load a particular version of DLL_B
     236     * Native OS/2 LX DLLs import functions from other DLLs using relocation
     237     * fixup records which differs from the Win32 PE format that does this
     238     * through the IAT (import address table - a table of function pointers).
     239     * As a result, if DLL_A imports something from DLL_B then when DLL_A is
     240     * loaded by a process, it will load a particular version of DLL_B
    241241     * to call its functions and all other processes that load DLL_A will get
    242      * the same calls to that particular version of DLL_B (from within DLL_A)
    243      * even though they supply their own version of DLL_B. In case of Java this
    244      * means that if there is a Java process using e.g. server/JVM.DLL and
    245      * another process is requesting client/JVM.DLL, this second process will
    246      * eventually crash because all Java DLLs statically linked to JVM.DLL (e.g.
     242     * the same calls to that particular version of DLL_B even though they
     243     * supply their own version of DLL_B (because relocation only happens once
     244     * and it is system-wide, as opposed to Win32 where IAT tables are per-
     245     * process). In case of Java this means that if there is a Java process
     246     * using e.g. server/JVM.DLL and another process is requesting
     247     * client/JVM.DLL, this second process will eventually crash because all
     248     * Java DLLs statically linked to JVM.DLL through the import table (e.g.
    247249     * JVERIFY.DLL, JZIP.DLL) which it loads later will be calling functions
    248250     * from server/JVM.DLL but that DLL is *not* initialized within this process
    249      * (no surprise, it loaded and initialized client/JVM.DLL instead). In order
    250      * to avoid such crashes we have to give a corresponding error message and
    251      * terminate, there is no other solution so far.
     251     * (no surprise, the process has loaded and initialized client/JVM.DLL
     252     * instead). In order to avoid such crashes we have to give a corresponding
     253     * error message and terminate, there is no other solution so far.
    252254     */
    253255    {
     
    281283            return JNI_FALSE;
    282284    }
    283 
    284     /*
    285      * Add the JRE bin path to BEGINLIBPATH to make sure that other DLLs
    286      * statically linked to the various JRE DLLs (so that they refer to them by
    287      * name in the import tables) are able to find it. This is necessary because
    288      * on OS/2, loading a DLL by full path does NOT make it available to other
    289      * DLLs by name -- a normal procedure of searching it in LIBPATH and
    290      * BEGINLIBPATH/ENDLIBPATH is always performed in this case.
    291      */
    292     if (GetJREPath(crtpath, MAXPATHLEN)) {
    293         char *dir = (char *)malloc(strlen(crtpath) + 4 + 32);
    294         strcpy(dir, crtpath);
    295         strcat(dir, "\\bin;%BEGINLIBPATH%");
    296         if (_launcher_debug) {
    297              printf("Adding %s to BEGINLIBPATH\n", dir);
    298         }
    299         DosSetExtLIBPATH(dir, BEGIN_LIBPATH);
    300         free(dir);
    301     }
    302 
    303     /*
    304      * Do the same for the Java VM DLL which is located in a separate directory.
    305      */
    306     char *jvmdir = (char *)malloc(strlen(jvmpath) + 1 + 32);
    307     strcpy(jvmdir, jvmpath);
    308     char *sep = strrchr(jvmdir, '\\');
    309     if (sep) {
    310         strcpy(sep, ";%BEGINLIBPATH%");
    311         if (_launcher_debug) {
    312              printf("Adding %s to BEGINLIBPATH\n", jvmdir);
    313         }
    314         DosSetExtLIBPATH(jvmdir, BEGIN_LIBPATH);
    315     }
    316     free(jvmdir);
    317285#endif
    318286
Note: See TracChangeset for help on using the changeset viewer.