4680N/A * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 4680N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4680N/A * This code is free software; you can redistribute it and/or modify it 4680N/A * under the terms of the GNU General Public License version 2 only, as 4680N/A * published by the Free Software Foundation. Oracle designates this 4680N/A * particular file as subject to the "Classpath" exception as provided 4680N/A * by Oracle in the LICENSE file that accompanied this code. 4680N/A * This code is distributed in the hope that it will be useful, but WITHOUT 4680N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 4680N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 4680N/A * version 2 for more details (a copy is included in the LICENSE file that 4680N/A * You should have received a copy of the GNU General Public License version 4680N/A * 2 along with this work; if not, write to the Free Software Foundation, 4680N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 4680N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 4680N/A * Return true if the named program exists 4680N/A * Find a command in a directory, returning the path. 4680N/A * Find a path for the executable 4680N/A /* relative path element */ 4680N/A * TODO: its safer to use strerror_r but is not available on 4680N/A * Solaris 8. Until then.... 4680N/A * Since using the file system as a registry is a bit risky, perform 4680N/A * additional sanity checks on the identified directory to validate 4680N/A * Return 0 if the tests fail; otherwise return non-zero (true). 4680N/A * Note that checking for anything more than the existence of an 4680N/A * executable object at bin/java relative to the path being checked 4680N/A * will break the regression tests. 4680N/A return (0);
/* Silently reject "impossibly" long paths */ 4680N/A * Determine if there is an acceptable JRE in the directory dirname. 4680N/A * Upon locating the "best" one, return a fully qualified path to 4680N/A * it. "Best" is defined as the most advanced JRE meeting the 4680N/A * constraints contained in the manifest_info. If no JRE in this 4680N/A * directory meets the constraints, return NULL. 4680N/A * Note that we don't check for errors in reading the directory 4680N/A * (which would be done by checking errno). This is because it 4680N/A * doesn't matter if we get an error reading the directory, or 4680N/A * we just don't find anything interesting in the directory. We 4680N/A * just return NULL in either case. 4680N/A * The historical names of j2sdk and j2re were changed to jdk and 4680N/A * jre respecively as part of the 1.5 rebranding effort. Since the 4680N/A * former names are legacy on Linux, they must be recognized for 4680N/A * all time. Fortunately, this is a minor cost. 4680N/A * This is the global entry point. It examines the host for the optimal 4680N/A * JRE to be used by scanning a set of directories. The set of directories 4680N/A * is platform dependent and can be overridden by the environment 4680N/A * variable JAVA_VERSION_PATH. 4680N/A * This routine itself simply determines the set of appropriate 4680N/A * directories before passing control onto ProcessDir(). 4680N/A * Start by getting JAVA_VERSION_PATH 4680N/A * Step through each directory on the path. Terminate the scan with 4680N/A * the first directory with an acceptable JRE. 4680N/A * Given a path to a jre to execute, this routine checks if this process 4680N/A * is indeed that jre. If not, it exec's that jre. 4680N/A * We want to actually check the paths rather than just the version string 4680N/A * built into the executable, so that given version specification (and 4680N/A * JAVA_VERSION_PATH) will yield the exact same Java environment, regardless 4680N/A * of the version of the arbitrary launcher we start with. 4680N/A * Resolve the real path to the directory containing the selected JRE. 4680N/A * Resolve the real path to the currently running launcher. 4680N/A * If the path to the selected JRE directory is a match to the initial 4680N/A * portion of the path to the currently executing JRE, we have a winner! 4680N/A return;
/* I am the droid you were looking for */ 4680N/A * This should never happen (because of the selection code in SelectJRE), 4680N/A * but check for "impossibly" long path names just because buffer overruns 4680N/A * Construct the path and exec it. 4680N/A * "Borrowed" from Solaris 10 where the unsetenv() function is being added 4680N/A * to libc thanks to SUSv3 (Standard Unix Specification, version 3). As 4680N/A * such, in the fullness of time this will appear in libc on all relevant 4680N/A * time, this stub can be removed. 4680N/A * This implementation removes the environment locking for multithreaded 4680N/A * applications. (We don't have access to these mutexes within libc and 4680N/A * the launcher isn't multithreaded.) Note that what remains is platform 4680N/A * independent, because it only relies on attributes that a POSIX environment 4680N/A * Returns 0 on success, -1 on failure. 4680N/A * Also removed was the setting of errno. The only value of errno set 4680N/A * was EINVAL ("Invalid Argument"). 4680N/A * s1(environ) is name=value 4680N/A * s2(name) is name(not the form of name=value). 4680N/A * if names match, return value of 1, else return 0 4680N/A * Delete entry from environ. 4680N/A * Do not free() memory! Other threads may be using it. 4680N/A /* name not found but still a success */ 4680N/A/* --- End of "borrowed" code --- */ 4680N/A * Wrapper for unsetenv() function. 4680N/A * The implementation for finding classes from the bootstrap 4680N/A "JVM_FindClassFromBootLoader");
4680N/A "JVM_FindClassFromBootLoader");