/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "java.h"
#include <dirent.h>
#include <dlfcn.h>
#include <fcntl.h>
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <unistd.h>
#ifndef GAMMA
#include "manifest_info.h"
#include "version_comp.h"
#endif
#if defined(__linux__) || defined(_ALLBSD_SOURCE)
#include <pthread.h>
#else
#include <thread.h>
#endif
#ifdef __APPLE__
#else
#endif
#ifndef GAMMA /* launcher.make defines ARCH */
/*
* If a processor / os combination has the ability to run binaries of
* models is supported, then DUAL_MODE is defined. When DUAL_MODE is
* defined, the architecture names for the narrow and wide version of
* the architecture are defined in LIBARCH64NAME and LIBARCH32NAME. Currently
* current policy.
*/
#ifndef LIBARCHNAME
# error "The macro LIBARCHNAME was not defined on the compile line"
#endif
#ifdef __sun
# define DUAL_MODE
# ifndef LIBARCH32NAME
# error "The macro LIBARCH32NAME was not defined on the compile line"
# endif
# ifndef LIBARCH64NAME
# error "The macro LIBARCH64NAME was not defined on the compile line"
# endif
# include <sys/systeminfo.h>
# include <stdio.h>
#endif
#endif /* ifndef GAMMA */
/* pointer to environment */
extern char **environ;
#ifndef GAMMA
/*
* A collection of useful strings. One should think of these as #define
* entries, but actual strings can be more efficient (with many compilers).
*/
#ifdef __linux__
#else /* Solaris */
#endif
#endif /* ifndef GAMMA */
/*
* 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
* the exec of the specified launcher version.
*
* Typically, the launcher execs at least once to ensure a suitable
* LD_LIBRARY_PATH is in effect for the process. The first exec
* screens out all the data model options; leaving the choice of data
* model implicit in the binary selected to run. However, in case no
* exec is done, the data model options are screened out before the vm
* is invoked.
*
* incoming argv ------------------------------
* | |
* \|/ |
* CheckJVMType |
* (removes -client, -server, etc.) |
* \|/
* CreateExecutionEnvironment
* (removes -d32 and -d64,
* determines desired data model,
* sets up LD_LIBRARY_PATH,
* and exec's)
* |
* --------------------------------------------
* |
* \|/
* exec child 1 incoming argv -----------------
* | |
* \|/ |
* CheckJVMType |
* (removes -client, -server, etc.) |
* | \|/
* | CreateExecutionEnvironment
* | (verifies desired data model
* | is running and acceptable
* | LD_LIBRARY_PATH;
* | no-op in child)
* |
* \|/
* TranslateDashJArgs...
* (Prepare to pass args to vm)
* |
* |
* |
* \|/
* ParseArguments
* (ignores -d32 and -d64,
* processes version options,
* creates argument list for vm,
* etc.)
*
*/
static char *SetExecname(char **argv);
static char * GetExecname();
#ifndef GAMMA
const char *
GetArch()
{
return LIBARCHNAME;
}
#endif /* ifndef GAMMA */
void
char ***_argvp,
char jrepath[],
char jvmpath[],
char **original_argv) {
/*
* 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. However, if we are not running the desired data model,
* some of the errors should be suppressed since it is more
* informative to issue an error message based on whether or not the
*/
/* Compute the name of the executable */
#ifndef GAMMA
/* Set the LD_LIBRARY_PATH environment variable, check data model
flags, and exec process, if needed */
{
setting */
32 bit vm; LP64 => 64 bit vm */
#ifdef _LP64
64;
#else
32;
#endif
asked for? Current model is
fine unless another model
is asked for */
int newargc = 0;
#ifdef __sun
Solaris only */
#endif
/*
* 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;
/* scan for data model arguments and remove from argument list;
last occurrence determines desired data model */
for (i=1; i < argc; i++) {
wanted = 64;
continue;
}
wanted = 32;
continue;
}
#ifdef JAVA_ARGS
if (argv[i][0] != '-')
continue;
#else
i++;
if (i >= argc) break;
continue;
}
if (argv[i][0] != '-') { i++; break; }
#endif
}
/* copy rest of args [i .. argc) */
while (i < argc) {
}
/*
* newargv has all proper arguments here
*/
}
/* If the data model is not changing, it is an error if the
jvmpath does not exist */
/* Find out where the JRE is that we will be using. */
exit(2);
}
/* Find the specified JVM type */
exit(1);
}
jvmpath[0] = '\0';
exit(4);
}
} else { /* do the same speculatively or exit */
#ifdef DUAL_MODE
/* Find out where the JRE is that we will be using. */
goto EndDataModelSpeculate;
}
/*
* Read in jvm.cfg for target data model and process vm
* selection options.
*/
goto EndDataModelSpeculate;
}
jvmpath[0] = '\0';
/* exec child can do error checking on the existence of the path */
}
EndDataModelSpeculate: /* give up and let other code report error message */
;
#else
exit(1);
#endif
}
/*
* We will set the LD_LIBRARY_PATH as follows:
*
* o $JVMPATH (directory portion only)
* o $JRE/../lib/$LIBARCHNAME
*
* followed by the user's previous effective LD_LIBRARY_PATH, if
* any.
*/
#ifdef __sun
/*
* 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.
*
* 3. LD_LIBRARY_PATH_32 -- overrides and replaces LD_LIBRARY_PATH
* for 32-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:
if(running == 32) {
wanted = 32;
}
else {
wanted = 64;
}
break;
case 32:
break;
case 64:
break;
default:
break;
}
/*
* If dmpath is NULL, the relevant data model specific variable is
* not set and normal LD_LIBRARY_PATH should be used.
*/
}
else {
}
#else
/*
* If not on Solaris, assume only a single LD_LIBRARY_PATH
* variable.
*/
#endif /* __sun */
#if defined(__linux__)
/*
* On linux, if a binary is running as sgid or suid, glibc sets
* LD_LIBRARY_PATH to the empty string for security purposes. (In
* contrast, on Solaris the LD_LIBRARY_PATH variable for a
* privileged binary does not lose its settings; but the dynamic
* linker does apply more scrutiny to the path.) The launcher uses
* the value of LD_LIBRARY_PATH to prevent an exec loop.
* Therefore, if we are running sgid or suid, this function's
* setting of LD_LIBRARY_PATH will be ineffective and we should
* return from the function now. Getting the right libraries to
* be found must be handled through other mechanisms.
*/
return;
}
#elif defined(_ALLBSD_SOURCE)
/*
* On BSD, if a binary is running as sgid or suid, libc sets
* LD_LIBRARY_PATH to the empty string for security purposes. (In
* contrast, on Solaris the LD_LIBRARY_PATH variable for a
* privileged binary does not lose its settings; but the dynamic
* linker does apply more scrutiny to the path.) The launcher uses
* the value of LD_LIBRARY_PATH to prevent an exec loop.
* Therefore, if we are running sgid or suid, this function's
* setting of LD_LIBRARY_PATH will be ineffective and we should
* return from the function now. Getting the right libraries to
* be found must be handled through other mechanisms.
*/
if(issetugid()) {
return;
}
#endif
/* runpath contains current effective LD_LIBRARY_PATH setting */
/*
* Create desired LD_LIBRARY_PATH value for target data model.
*/
{
/* remove the name of the .so from the JVM path */
if (lastslash)
*lastslash = '\0';
/* jvmpath, ((running != wanted)?((wanted==64)?"/"LIBARCH64NAME:"/.."):""), */
"%s:"
"%s/../lib/%s",
#ifdef DUAL_MODE
#else
#endif
);
/*
* Check to make sure that the prefix of the current path is the
* desired environment variable setting.
*/
#ifdef __sun
#endif
) {
return;
}
}
/*
* Place the desired environment setting onto the prefix of
* LD_LIBRARY_PATH. Note that this prevents any possible infinite
* loop of execv() because we test for the prefix, above.
*/
if (runpath != 0) {
}
if( putenv(new_runpath) != 0) {
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 __sun
/*
* If dmpath is not NULL, remove the data model specific string
* in the environment for the exec'ed child.
*/
#endif
{
#ifdef DUAL_MODE
/*
* If the data model is being changed, the path to the
* executable must be updated accordingly; the executable name
* and directory the executable resides in are separate. In the
* case of 32 => 64, the new bits are assumed to reside in, e.g.
* "olddir/LIBARCH64NAME/execname"; in the case of 64 => 32,
* the bits are assumed to be in "olddir/../execname". For example,
*
*
* for Solaris SPARC and Linux amd64, respectively.
*/
*oldbase++ = 0;
}
#endif
perror("execve()");
#ifdef DUAL_MODE
# ifdef __sun
# ifdef __sparc
"(Solaris SPARC 64-bit components must be installed after 32-bit components.)\n" );
# else
# endif
}
# endif
#endif
}
exit(1);
}
#else /* ifndef GAMMA */
/*
* gamma launcher is simpler in that it doesn't handle VM flavors, data
* model, LD_LIBRARY_PATH, etc. Assuming everything is set-up correctly
* all we need to do here is to return correct path names. See also
* GetJVMPath() and GetApplicationHome().
*/
char *p;
exit(2);
}
exit(4);
}
}
#endif /* ifndef GAMMA */
}
/*
* On Solaris VM choosing is done by the launcher (java.c).
*/
static jboolean
{
struct stat s;
#ifndef GAMMA
} else {
}
#else
/*
* For gamma launcher, JVM is either built-in or in the same directory.
* Either way we return "<exe_path>/libjvm.so" where <exe_path> is the
* directory where gamma launcher is located.
*/
char *p;
if (p) {
/* replace executable name with libjvm.so */
} else {
/* this case shouldn't happen */
}
#endif /* ifndef GAMMA */
if (_launcher_debug)
if (_launcher_debug)
printf("yes.\n");
return JNI_TRUE;
} else {
if (_launcher_debug)
printf("no.\n");
return JNI_FALSE;
}
}
/*
* Find path to JRE based on .exe's location or registry settings.
*/
static jboolean
{
/* Is the JRE universal, i.e. no arch dir? */
goto found;
}
/* Is JRE co-located with the application? */
goto found;
}
/* Does the app ship a private JRE in <apphome>/jre directory? */
goto found;
}
}
if (!speculative)
return JNI_FALSE;
if (_launcher_debug)
return JNI_TRUE;
}
{
#ifdef GAMMA
/* JVM is directly linked with gamma launcher; no dlopen() */
return JNI_TRUE;
#else
void *libjvm;
if (_launcher_debug) {
}
int count;
int location;
goto error;
/* read in elf header */
if(count < 1)
goto error;
/*
* Check for running a server vm (compiled with -xarch=v8plus)
* on a stock v8 processor. In this case, the machine type in
* the elf header would not be included the architecture list
* provided by the isalist command, which is turn is gotten from
* sysinfo. This case cannot occur on 64-bit hardware and thus
* does not have to be checked for in binaries with an LP64 data
* model.
*/
page */
long length;
char* location;
if(length > 0) {
return JNI_FALSE;
}
}
}
#endif
goto error;
}
goto error;
goto error;
return JNI_TRUE;
return JNI_FALSE;
#endif /* ifndef GAMMA */
}
/*
* "/foo" into buf.
*/
{
#if defined(__linux__) || defined(_ALLBSD_SOURCE)
if (execname) {
} else {
return JNI_FALSE;
}
#else
return JNI_FALSE;
}
#endif
#ifdef GAMMA
{
if (java_home_var == NULL) {
return JNI_FALSE;
}
}
#else
buf[0] = '\0';
return JNI_FALSE;
}
buf[0] = '\0';
return JNI_FALSE;
}
buf[0] = '\0';
return JNI_FALSE;
}
#endif /* ifndef GAMMA */
return JNI_TRUE;
}
/*
* Return true if the named program exists
*/
static int
{
}
/*
* Find a command in a directory, returning the path.
*/
static char *
{
if (!ProgramExists(name)) return 0;
return real;
}
/*
* Find a path for the executable
*/
static char *
{
char *path;
char *tmp_path;
char *f;
/* absolute path? */
if (*program == FILE_SEPARATOR ||
/* relative path? */
}
/* from search path? */
char *s = f;
while (*f && (*f != PATH_SEPARATOR)) ++f;
if (*f) *f++ = 0;
if (*s == FILE_SEPARATOR)
else {
/* relative path element */
FILE_SEPARATOR, s);
}
if (result != 0) break;
}
return result;
}
/* Store the name of the executable once computed */
/*
* Compute the name of the executable
*
* In order to re-exec securely we need the absolute path of the
* executable. On Solaris getexecname(3c) may not return an absolute
* path so we use dladdr to get the filename of the executable and
* then use realpath to derive an absolute path. From Solaris 9
* onwards the filename returned in DL_info structure from dladdr is
* an absolute pathname so technically realpath isn't required.
* As a fallback, and for platforms other than Solaris and Linux,
* we use FindExecName to compute the executable name.
*/
static char *
{
return (execname);
#if defined(__sun)
{
}
}
}
}
{
if (len >= 0) {
}
}
#else /* !__sun && !__linux */
{
/* Not implemented */
}
#endif
}
return exec_path;
}
/*
* Return the name of the executable. Used in java_md.c to find the JRE area.
*/
static char *
GetExecname() {
return execname;
}
if (always) {
}
}
if (always) {
}
}
}
/*
* Return JNI_TRUE for an option string that has no effect but should
* _not_ be passed on to the vm; return JNI_FALSE otherwise. On
* Solaris SPARC, this screening needs to be done if:
* 1) LD_LIBRARY_PATH does _not_ need to be reset and
* 2) -d32 or -d64 is passed to a binary with a matching data model
* (the exec in SetLibraryPath removes -d<n> options and points the
* exec to the proper binary). When this exec is not done, these options
* would end up getting passed onto the vm.
*/
/*
* Unconditionally remove both -d32 and -d64 options since only
* the last such options has an effect; e.g.
* java -d32 -d64 -d32 -version
* is equivalent to
* java -d32 -version
*/
return JNI_TRUE;
else
return JNI_FALSE;
}
void PrintMachineDependentOptions() {
" -d32 use a 32-bit data model if available\n"
"\n"
" -d64 use a 64-bit data model if available\n");
return;
}
#ifndef GAMMA
/*
* The following methods (down to ServerClassMachine()) answer
* the question about whether a machine is a "server-class"
* machine. A server-class machine is loosely defined as one
* with 2 or more processors and 2 gigabytes or more physical
* memory. The definition of a processor is a physical package,
* not a hyperthreaded chip masquerading as a multi-processor.
* The definition of memory is also somewhat fuzzy, since x86
* machines seem not to report all the memory in their DIMMs, we
* think because of memory mapping of graphics cards, etc.
*
* This code is somewhat more confused with #ifdef's than we'd
* like because this file is used by both Solaris and Linux
* platforms, and so needs to be parameterized for SPARC and
* i586 hardware. The other Linux platforms (amd64 and ia64)
* don't even ask this question, because they only come with
* server JVMs. */
/* Compute physical memory by asking the OS */
physical_memory(void) {
if (_launcher_debug) {
" page_size: " UINT64_FORMAT
}
return result;
}
/* Methods for solaris-sparc: these are easy. */
/* Ask the OS how many processors there are. */
unsigned long
physical_processors(void) {
if (_launcher_debug) {
}
return sys_processors;
}
/* The solaris-sparc version of the "server-class" predicate. */
solaris_sparc_ServerClassMachine(void) {
/* How big is a server class machine? */
/* Is this a server class machine? */
if (actual_memory >= server_memory) {
if (actual_processors >= server_processors) {
}
}
if (_launcher_debug) {
}
return result;
}
#endif /* __sun && __sparc */
/*
* A utility method for asking the CPU about itself.
* There's a corresponding version of linux-i586
* because the compilers are different.
*/
void
#ifdef _LP64
asm(
/* rbx is a callee-saved register */
" movq %rbx, %r11 \n"
/* rdx and rcx are 3rd and 4th argument registers */
" movq %rdx, %r10 \n"
" movq %rcx, %r9 \n"
" movl %edi, %eax \n"
" cpuid \n"
" movl %eax, (%rsi)\n"
" movl %ebx, (%r10)\n"
" movl %ecx, (%r9) \n"
" movl %edx, (%r8) \n"
/* Restore rbx */
" movq %r11, %rbx");
#else
/* EBX is a callee-saved register */
asm(" pushl %ebx");
/* Need ESI for storing through arguments */
asm(" pushl %esi");
asm(" movl 8(%ebp), %eax \n"
" cpuid \n"
" movl 12(%ebp), %esi \n"
" movl %eax, (%esi) \n"
" movl 16(%ebp), %esi \n"
" movl %ebx, (%esi) \n"
" movl 20(%ebp), %esi \n"
" movl %ecx, (%esi) \n"
" movl 24(%ebp), %esi \n"
" movl %edx, (%esi) ");
/* Restore ESI and EBX */
asm(" popl %esi");
/* Restore EBX */
asm(" popl %ebx");
#endif
}
#endif /* __sun && i586 */
/*
* A utility method for asking the CPU about itself.
* There's a corresponding version of solaris-i586
* because the compilers are different.
*/
void
#ifdef _LP64
__asm__ volatile (/* Instructions */
" movl %4, %%eax \n"
" cpuid \n"
" movl %%eax, (%0)\n"
" movl %%ebx, (%1)\n"
" movl %%ecx, (%2)\n"
" movl %%edx, (%3)\n"
: /* Outputs */
: /* Inputs */
"r" (eaxp),
"r" (ebxp),
"r" (ecxp),
"r" (edxp),
"r" (arg)
: /* Clobbers */
"%rax", "%rbx", "%rcx", "%rdx", "memory"
);
#else
uint32_t value_of_eax = 0;
uint32_t value_of_ebx = 0;
uint32_t value_of_ecx = 0;
uint32_t value_of_edx = 0;
__asm__ volatile (/* Instructions */
/* ebx is callee-save, so push it */
" pushl %%ebx \n"
" movl %4, %%eax \n"
" cpuid \n"
" movl %%eax, %0 \n"
" movl %%ebx, %1 \n"
" movl %%ecx, %2 \n"
" movl %%edx, %3 \n"
/* restore ebx */
" popl %%ebx \n"
: /* Outputs */
"=m" (value_of_eax),
"=m" (value_of_ebx),
"=m" (value_of_ecx),
"=m" (value_of_edx)
: /* Inputs */
"m" (arg)
: /* Clobbers */
"%eax", "%ecx", "%edx"
);
*eaxp = value_of_eax;
*ebxp = value_of_ebx;
*ecxp = value_of_ecx;
*edxp = value_of_edx;
#endif
}
#endif /* __linux__ && i586 */
#ifdef i586
/*
* Routines shared by solaris-i586 and linux-i586.
*/
enum HyperThreadingSupport_enum {
hts_too_soon_to_tell = 0,
};
/* Determine if hyperthreading is supported */
hyperthreading_support(void) {
/* Bits 11 through 8 is family processor id */
/* Bits 23 through 20 is extended family processor id */
/* Pentium 4 family processor id */
/* Bit 28 indicates Hyper-Threading Technology support */
/* Yes, this is supposed to be [0], [2], [1] */
if (_launcher_debug) {
printf("vendor: %c %c %c %c %c %c %c %c %c %c %c %c \n",
((vendor_id[0] >> 0) & 0xff),
}
if (_launcher_debug) {
printf("value_of_eax: 0x%x value_of_edx: 0x%x\n",
}
if (_launcher_debug) {
printf("Hyperthreading supported\n");
}
} else {
if (_launcher_debug) {
printf("Hyperthreading not supported\n");
}
}
} else {
if (_launcher_debug) {
printf("Not GenuineIntel\n");
}
}
} else {
if (_launcher_debug) {
printf("not Pentium 4 or extended\n");
}
}
return result;
}
/* Determine how many logical processors there are per CPU */
unsigned int
logical_processors_per_package(void) {
/*
* After CPUID with EAX==1, register EBX bits 23 through 16
* indicate the number of logical processors per package
*/
if (hyperthreading == hts_supported) {
if (_launcher_debug) {
}
}
return result;
}
/* Compute the number of physical processors, not logical processors */
unsigned long
physical_processors(void) {
if (_launcher_debug) {
}
if (sys_processors > 1) {
if (logical_processors > 1) {
}
}
if (_launcher_debug) {
}
return result;
}
#endif /* i586 */
/* The definition of a server-class machine for solaris-i586/amd64 */
solaris_i586_ServerClassMachine(void) {
/* How big is a server class machine? */
/*
* We seem not to get our full complement of memory.
* We allow some part (1/8?) of the memory to be "missing",
* based on the sizes of DIMMs, and maybe graphics cards.
*/
/* Is this a server class machine? */
if (actual_processors >= server_processors) {
}
}
if (_launcher_debug) {
}
return result;
}
#endif /* __sun && i586 */
/* The definition of a server-class machine for linux-i586 */
linux_i586_ServerClassMachine(void) {
/* How big is a server class machine? */
/*
* We seem not to get our full complement of memory.
* We allow some part (1/8?) of the memory to be "missing",
* based on the sizes of DIMMs, and maybe graphics cards.
*/
/* Is this a server class machine? */
if (actual_processors >= server_processors) {
}
}
if (_launcher_debug) {
}
return result;
}
#endif /* __linux__ && i586 */
#if defined(_ALLBSD_SOURCE) && defined(i586)
/* The definition of a server-class machine for bsd-i586 */
bsd_i586_ServerClassMachine(void) {
/* How big is a server class machine? */
/*
* We seem not to get our full complement of memory.
* We allow some part (1/8?) of the memory to be "missing",
* based on the sizes of DIMMs, and maybe graphics cards.
*/
/* Is this a server class machine? */
if (actual_processors >= server_processors) {
}
}
if (_launcher_debug) {
}
return result;
}
#endif /* _ALLBSD_SOURCE && i586 */
/* Dispatch to the platform-specific definition of "server-class" */
ServerClassMachine(void) {
#if defined(NEVER_ACT_AS_SERVER_CLASS_MACHINE)
#elif defined(ALWAYS_ACT_AS_SERVER_CLASS_MACHINE)
#else
if (_launcher_debug) {
printf("ServerClassMachine: returns default value of %s\n",
}
#endif
return result;
}
/*
* Since using the file system as a registry is a bit risky, perform
* additional sanity checks on the identified directory to validate
*
* Return 0 if the tests fail; otherwise return non-zero (true).
*
* Note that checking for anything more than the existence of an
* will break the regression tests.
*/
static int
{
return (0); /* Silently reject "impossibly" long paths */
}
/*
* Determine if there is an acceptable JRE in the directory dirname.
* Upon locating the "best" one, return a fully qualified path to
* it. "Best" is defined as the most advanced JRE meeting the
* constraints contained in the manifest_info. If no JRE in this
* directory meets the constraints, return NULL.
*
* Note that we don't check for errors in reading the directory
* (which would be done by checking errno). This is because it
* doesn't matter if we get an error reading the directory, or
* we just don't find anything interesting in the directory. We
* just return NULL in either case.
*
* The historical names of j2sdk and j2re were changed to jdk and
* jre respecively as part of the 1.5 rebranding effort. Since the
* former names are legacy on Linux, they must be recognized for
* all time. Fortunately, this is a minor cost.
*/
static char
{
int offset;
int best_offset = 0;
return (NULL);
do {
offset = 0;
offset = 3;
offset = 4;
offset = 5;
if (offset > 0) {
}
}
}
return (NULL);
else {
return (ret_str);
}
}
/*
* This is the global entry point. It examines the host for the optimal
* JRE to be used by scanning a set of directories. The set of directories
* is platform dependent and can be overridden by the environment
* variable JAVA_VERSION_PATH.
*
* This routine itself simply determines the set of appropriate
* directories before passing control onto ProcessDir().
*/
char*
{
char *path;
char *home;
char *dp;
char *cp;
/*
* Start by getting JAVA_VERSION_PATH
*/
if (info->jre_restrict_search)
else
} else
/*
* Step through each directory on the path. Terminate the scan with
* the first directory with an acceptable JRE.
*/
break;
dp++;
}
return (target);
}
/*
* Given a path to a jre to execute, this routine checks if this process
* is indeed that jre. If not, it exec's that jre.
*
* We want to actually check the paths rather than just the version string
* built into the executable, so that given version specification (and
* JAVA_VERSION_PATH) will yield the exact same Java environment, regardless
* of the version of the arbitrary launcher we start with.
*/
void
{
char *execname;
char *progname;
/*
* Resolve the real path to the directory containing the selected JRE.
*/
exit(1);
}
/*
* Resolve the real path to the currently running launcher.
*/
exit(1);
}
/*
* If the path to the selected JRE directory is a match to the initial
* portion of the path to the currently executing JRE, we have a winner!
* If so, just return.
*/
return; /* I am the droid you were looking for */
/*
* If this isn't the selected version, exec the selected version.
*/
#ifdef JAVA_ARGS /* javac, jar and friends. */
progname = "java";
#else /* java, oldjava, javaw and friends */
#ifdef PROGNAME
#else
progname = s + 1;
}
#endif /* PROGNAME */
#endif /* JAVA_ARGS */
/*
* This should never happen (because of the selection code in SelectJRE),
* but check for "impossibly" long path names just because buffer overruns
* can be so deadly.
*/
exit(1);
}
/*
* Construct the path and exec it.
*/
if (_launcher_debug) {
int i;
printf("ReExec Args:");
printf("\n");
}
perror("execv()");
exit(1);
}
#endif /* ifndef GAMMA */
/*
* "Borrowed" from Solaris 10 where the unsetenv() function is being added
* to libc thanks to SUSv3 (Standard Unix Specification, version 3). As
* such, in the fullness of time this will appear in libc on all relevant
* time, this stub can be removed.
*
* This implementation removes the environment locking for multithreaded
* applications. (We don't have access to these mutexes within libc and
* the launcher isn't multithreaded.) Note that what remains is platform
* independent, because it only relies on attributes that a POSIX environment
* defines.
*
* Returns 0 on success, -1 on failure.
*
* Also removed was the setting of errno. The only value of errno set
* was EINVAL ("Invalid Argument").
*/
/*
* s1(environ) is name=value
* s2(name) is name(not the form of name=value).
* if names match, return value of 1, else return 0
*/
static int
{
if (*s1++ == '=')
return (1);
}
return (1);
return (0);
}
/*
* added for SUSv3 standard
*
* Delete entry from environ.
* Do not free() memory! Other threads may be using it.
* Keep it around forever.
*/
static int
{
return (-1);
}
break;
}
/* name not found but still a success */
return (0);
}
/* squeeze up one entry */
do {
return (0);
}
/* --- End of "borrowed" code --- */
/*
* Wrapper for unsetenv() function.
*/
int
{
return(borrowed_unsetenv(name));
}
/* --- Splash Screen shared library support --- */
if (!hSplashLib) {
}
if (hSplashLib) {
return sym;
} else {
return NULL;
}
}
void SplashFreeLibrary() {
if (hSplashLib) {
hSplashLib = NULL;
}
}
const char *
return "%lld";
}
/*
* Block current thread and continue execution in a new thread
*/
int
int rslt;
#if defined(__linux__) || defined(_ALLBSD_SOURCE)
if (stack_size > 0) {
}
void * tmp;
} else {
/*
* Continue execution in current thread if for some reason (e.g. out of
* later in continuation as JNI_CreateJavaVM needs to create quite a
* few new threads, anyway, just give it a try..
*/
}
#else
long flags = 0;
void * tmp;
} else {
/* See above. Continue in current thread if thr_create() failed */
}
#endif
return rslt;
}
/* Coarse estimation of number of digits assuming the worst case is a 64-bit pid. */
void SetJavaLauncherPlatformProps() {
/* Linux only */
#ifdef __linux__
#endif
}