< prev index next >

src/java.base/unix/native/libjli/java_md_solinux.c

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 60,72 **** /* * Flowchart of launcher execs and options processing on unix * * The selection of the proper vm shared library to open depends on * several classes of command line options, including vm "flavor" ! * options (-client, -server) and the data model options, -d32 and ! * -d64, as well as a version specification which may have come from ! * the command line or from the manifest of an executable jar file. * The vm selection options are not passed to the running * virtual machine; they must be screened out by the launcher. * * The version specification (if any) is processed first by the * platform independent routine SelectVersion. This may result in --- 60,70 ---- /* * Flowchart of launcher execs and options processing on unix * * The selection of the proper vm shared library to open depends on * several classes of command line options, including vm "flavor" ! * options (-client, -server). * The vm selection options are not passed to the running * virtual machine; they must be screened out by the launcher. * * The version specification (if any) is processed first by the * platform independent routine SelectVersion. This may result in
*** 118,155 **** * (Prepare to pass args to vm) * | * | * \|/ * ParseArguments - * (removes -d32 and -d64 if any, - * processes version options, - * creates argument list for vm, - * etc.) * | * | * \|/ * RequiresSetenv * Is LD_LIBRARY_PATH ! * and friends set ? --> NO --> Have Desired Model ? NO --> Error/Exit ! * YES YES --> Continue * | * | * \|/ ! * Path is desired JRE ? YES --> Have Desired Model ? NO --> Error/Exit ! * NO YES --> Continue * | * | * \|/ * Paths have well known ! * jvm paths ? --> NO --> Have Desired Model ? NO --> Error/Exit ! * YES YES --> Continue * | * | * \|/ ! * Does libjvm.so exit ! * in any of them ? --> NO --> Have Desired Model ? NO --> Error/Exit ! * YES YES --> Continue * | * | * \|/ * Set the LD_LIBRARY_PATH * | --- 116,149 ---- * (Prepare to pass args to vm) * | * | * \|/ * ParseArguments * | * | * \|/ * RequiresSetenv * Is LD_LIBRARY_PATH ! * and friends set ? --> NO --> Continue ! * YES * | * | * \|/ ! * Path is desired JRE ? YES --> Continue ! * NO * | * | * \|/ * Paths have well known ! * jvm paths ? --> NO --> Error/Exit ! * YES * | * | * \|/ ! * Does libjvm.so exist ! * in any of them ? --> NO --> Continue ! * YES * | * | * \|/ * Set the LD_LIBRARY_PATH * |
*** 300,409 **** void CreateExecutionEnvironment(int *pargc, char ***pargv, char jrepath[], jint so_jrepath, char jvmpath[], jint so_jvmpath, char jvmcfg[], jint so_jvmcfg) { - /* - * First, determine if we are running the desired data model. If we - * are running the desired data model, all the error messages - * associated with calling GetJREPath, ReadKnownVMs, etc. should be - * output, otherwise we simply exit with an error, as we no longer - * support dual data models. - */ - jboolean jvmpathExists; - /* Compute/set the name of the executable */ - SetExecname(*pargv); - - /* Check data model flags, and exec process, if needed */ - { char * jvmtype = NULL; int argc = *pargc; char **argv = *pargv; ! int running = CURRENT_DATA_MODEL; ! /* ! * As of jdk9, there is no support for dual mode operations, however ! * for legacy error reporting purposes and until -d options are supported ! * we need this. ! */ ! int wanted = running; #ifdef SETENV_REQUIRED jboolean mustsetenv = JNI_FALSE; char *runpath = NULL; /* existing effective LD_LIBRARY_PATH setting */ char* new_runpath = NULL; /* desired new LD_LIBRARY_PATH string */ char* newpath = NULL; /* path on new LD_LIBRARY_PATH */ char* lastslash = NULL; char** newenvp = NULL; /* current environment */ size_t new_runpath_size; - #ifdef __solaris__ - char* dmpath = NULL; /* data model specific LD_LIBRARY_PATH, - Solaris only */ - #endif /* __solaris__ */ #endif /* SETENV_REQUIRED */ ! char** newargv = NULL; ! int newargc = 0; ! /* ! * Starting in 1.5, all unix platforms accept the -d32 and -d64 ! * options. On platforms where only one data-model is supported ! * (e.g. ia-64 Linux), using the flag for the other data model is ! * an error and will terminate the program. ! */ ! ! { /* open new scope to declare local variables */ ! int i; ! ! newargv = (char **)JLI_MemAlloc((argc+1) * sizeof(char*)); ! newargv[newargc++] = argv[0]; ! ! /* scan for data model arguments and remove from argument list; ! last occurrence determines desired data model */ ! for (i=1; i < argc; i++) { ! ! if (JLI_StrCmp(argv[i], "-J-d64") == 0 || JLI_StrCmp(argv[i], "-d64") == 0) { ! wanted = 64; ! continue; ! } ! if (JLI_StrCmp(argv[i], "-J-d32") == 0 || JLI_StrCmp(argv[i], "-d32") == 0) { ! wanted = 32; ! continue; ! } ! newargv[newargc++] = argv[i]; ! ! if (IsJavaArgs()) { ! if (argv[i][0] != '-') continue; ! } else { ! if (JLI_StrCmp(argv[i], "-classpath") == 0 || JLI_StrCmp(argv[i], "-cp") == 0) { ! i++; ! if (i >= argc) break; ! newargv[newargc++] = argv[i]; ! continue; ! } ! if (argv[i][0] != '-') { i++; break; } ! } ! } ! ! /* copy rest of args [i .. argc) */ ! while (i < argc) { ! newargv[newargc++] = argv[i++]; ! } ! newargv[newargc] = NULL; ! ! /* ! * newargv has all proper arguments here ! */ ! ! argc = newargc; ! argv = newargv; ! } ! ! /* If the data model is not changing, it is an error if the ! jvmpath does not exist */ ! if (wanted == running) { /* Find out where the JRE is that we will be using. */ ! if (!GetJREPath(jrepath, so_jrepath, JNI_FALSE) ) { JLI_ReportErrorMessage(JRE_ERROR1); exit(2); } JLI_Snprintf(jvmcfg, so_jvmcfg, "%s%slib%s%sjvm.cfg", jrepath, FILESEP, FILESEP, FILESEP); --- 294,324 ---- void CreateExecutionEnvironment(int *pargc, char ***pargv, char jrepath[], jint so_jrepath, char jvmpath[], jint so_jvmpath, char jvmcfg[], jint so_jvmcfg) { char * jvmtype = NULL; int argc = *pargc; char **argv = *pargv; ! #ifdef SETENV_REQUIRED jboolean mustsetenv = JNI_FALSE; char *runpath = NULL; /* existing effective LD_LIBRARY_PATH setting */ char* new_runpath = NULL; /* desired new LD_LIBRARY_PATH string */ char* newpath = NULL; /* path on new LD_LIBRARY_PATH */ char* lastslash = NULL; char** newenvp = NULL; /* current environment */ size_t new_runpath_size; #endif /* SETENV_REQUIRED */ ! /* Compute/set the name of the executable */ ! SetExecname(*pargv); ! /* Check to see if the jvmpath exists */ /* Find out where the JRE is that we will be using. */ ! if (!GetJREPath(jrepath, so_jrepath, JNI_FALSE)) { JLI_ReportErrorMessage(JRE_ERROR1); exit(2); } JLI_Snprintf(jvmcfg, so_jvmcfg, "%s%slib%s%sjvm.cfg", jrepath, FILESEP, FILESEP, FILESEP);
*** 418,428 **** if (JLI_StrCmp(jvmtype, "ERROR") == 0) { JLI_ReportErrorMessage(CFG_ERROR9); exit(4); } ! if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath, 0 )) { JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath); exit(4); } /* * we seem to have everything we need, so without further ado --- 333,343 ---- if (JLI_StrCmp(jvmtype, "ERROR") == 0) { JLI_ReportErrorMessage(CFG_ERROR9); exit(4); } ! if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath)) { JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath); exit(4); } /* * we seem to have everything we need, so without further ado
*** 431,451 **** #ifdef SETENV_REQUIRED mustsetenv = RequiresSetenv(jvmpath); JLI_TraceLauncher("mustsetenv: %s\n", mustsetenv ? "TRUE" : "FALSE"); if (mustsetenv == JNI_FALSE) { - JLI_MemFree(newargv); return; } #else - JLI_MemFree(newargv); return; #endif /* SETENV_REQUIRED */ ! } else { /* do the same speculatively or exit */ ! JLI_ReportErrorMessage(JRE_ERROR2, wanted); ! exit(1); ! } #ifdef SETENV_REQUIRED if (mustsetenv) { /* * We will set the LD_LIBRARY_PATH as follows: * --- 346,361 ---- #ifdef SETENV_REQUIRED mustsetenv = RequiresSetenv(jvmpath); JLI_TraceLauncher("mustsetenv: %s\n", mustsetenv ? "TRUE" : "FALSE"); if (mustsetenv == JNI_FALSE) { return; } #else return; #endif /* SETENV_REQUIRED */ ! #ifdef SETENV_REQUIRED if (mustsetenv) { /* * We will set the LD_LIBRARY_PATH as follows: *
*** 455,513 **** * * followed by the user's previous effective LD_LIBRARY_PATH, if * any. */ - #ifdef __solaris__ - /* - * Starting in Solaris 7, ld.so.1 supports three LD_LIBRARY_PATH - * variables: - * - * 1. LD_LIBRARY_PATH -- used for 32 and 64 bit searches if - * data-model specific variables are not set. - * - * 2. LD_LIBRARY_PATH_64 -- overrides and replaces LD_LIBRARY_PATH - * for 64-bit binaries. - * The vm uses LD_LIBRARY_PATH to set the java.library.path system - * property. To shield the vm from the complication of multiple - * LD_LIBRARY_PATH variables, if the appropriate data model - * specific variable is set, we will act as if LD_LIBRARY_PATH had - * the value of the data model specific variant and the data model - * specific variant will be unset. Note that the variable for the - * *wanted* data model must be used (if it is set), not simply the - * current running data model. - */ - - switch (wanted) { - case 0: - case 64: - dmpath = getenv("LD_LIBRARY_PATH_64"); - wanted = 64; - break; - - default: - JLI_ReportErrorMessage(JRE_ERROR3, __LINE__); - exit(1); /* unknown value in wanted */ - break; - } - - /* - * If dmpath is NULL, the relevant data model specific variable is - * not set and normal LD_LIBRARY_PATH should be used. - */ - if (dmpath == NULL) { - runpath = getenv("LD_LIBRARY_PATH"); - } else { - runpath = dmpath; - } - #else /* ! __solaris__ */ - /* - * If not on Solaris, assume only a single LD_LIBRARY_PATH - * variable. - */ runpath = getenv(LD_LIBRARY_PATH); - #endif /* __solaris__ */ /* runpath contains current effective LD_LIBRARY_PATH setting */ { /* New scope to declare local variable */ char *new_jvmpath = JLI_StringDup(jvmpath); new_runpath_size = ((runpath != NULL) ? JLI_StrLen(runpath) : 0) + --- 365,375 ----
*** 553,569 **** * checks if the desired runpath exists, this logic does a more * comprehensive check. */ if (runpath != NULL && JLI_StrNCmp(newpath, runpath, JLI_StrLen(newpath)) == 0 && ! (runpath[JLI_StrLen(newpath)] == 0 || runpath[JLI_StrLen(newpath)] == ':') && ! (running == wanted) /* data model does not have to be changed */ ! #ifdef __solaris__ ! && (dmpath == NULL) /* data model specific variables not set */ ! #endif /* __solaris__ */ ! ) { ! JLI_MemFree(newargv); JLI_MemFree(new_runpath); return; } } } --- 415,426 ---- * checks if the desired runpath exists, this logic does a more * comprehensive check. */ if (runpath != NULL && JLI_StrNCmp(newpath, runpath, JLI_StrLen(newpath)) == 0 && ! (runpath[JLI_StrLen(newpath)] == 0 || ! runpath[JLI_StrLen(newpath)] == ':')) { JLI_MemFree(new_runpath); return; } } }
*** 582,610 **** JLI_StrCat(new_runpath, ":"); JLI_StrCat(new_runpath, runpath); } if (putenv(new_runpath) != 0) { ! exit(1); /* problem allocating memory; LD_LIBRARY_PATH not set ! properly */ } /* * Unix systems document that they look at LD_LIBRARY_PATH only * once at startup, so we have to re-exec the current executable * to get the changed environment variable to have an effect. */ - #ifdef __solaris__ - /* - * If dmpath is not NULL, remove the data model specific string - * in the environment for the exec'ed child. - */ - if (dmpath != NULL) - (void)UnsetEnv("LD_LIBRARY_PATH_64"); - #endif /* __solaris */ - newenvp = environ; } #endif /* SETENV_REQUIRED */ { char *newexec = execname; --- 439,458 ---- JLI_StrCat(new_runpath, ":"); JLI_StrCat(new_runpath, runpath); } if (putenv(new_runpath) != 0) { ! /* problem allocating memory; LD_LIBRARY_PATH not set properly */ ! exit(1); } /* * Unix systems document that they look at LD_LIBRARY_PATH only * once at startup, so we have to re-exec the current executable * to get the changed environment variable to have an effect. */ newenvp = environ; } #endif /* SETENV_REQUIRED */ { char *newexec = execname;
*** 621,641 **** execv(newexec, argv); #endif /* SETENV_REQUIRED */ JLI_ReportErrorMessageSys(JRE_ERROR4, newexec); } exit(1); - } } ! /* ! * On Solaris VM choosing is done by the launcher (java.c), ! * bitsWanted is used by MacOSX, on Solaris and Linux this. ! * parameter is unused. ! */ static jboolean GetJVMPath(const char *jrepath, const char *jvmtype, ! char *jvmpath, jint jvmpathsize, int bitsWanted) { struct stat s; if (JLI_StrChr(jvmtype, '/')) { JLI_Snprintf(jvmpath, jvmpathsize, "%s/" JVM_DLL, jvmtype); --- 469,484 ---- execv(newexec, argv); #endif /* SETENV_REQUIRED */ JLI_ReportErrorMessageSys(JRE_ERROR4, newexec); } exit(1); } ! static jboolean GetJVMPath(const char *jrepath, const char *jvmtype, ! char *jvmpath, jint jvmpathsize) { struct stat s; if (JLI_StrChr(jvmtype, '/')) { JLI_Snprintf(jvmpath, jvmpathsize, "%s/" JVM_DLL, jvmtype);
< prev index next >