java_md_common.c revision 4680
/*
* 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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"
/*
* "/foo" into buf.
*/
{
const char *execname = GetExecName();
} else {
return JNI_FALSE;
}
buf[0] = '\0';
return JNI_FALSE;
}
buf[0] = '\0';
return JNI_FALSE;
}
buf[0] = '\0';
return JNI_FALSE;
}
return JNI_TRUE;
}
/*
* Return true if the named program exists
*/
static int
ProgramExists(char *name)
{
}
/*
* Find a command in a directory, returning the path.
*/
static char *
{
if (!ProgramExists(name)) return 0;
return real;
}
/*
* Find a path for the executable
*/
char *
FindExecName(char *program)
{
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;
}
void JLI_ReportErrorMessage(const char* fmt, ...) {
}
void JLI_ReportErrorMessageSys(const char* fmt, ...) {
char *emsg;
/*
* TODO: its safer to use strerror_r but is not available on
* Solaris 8. Until then....
*/
}
}
}
/*
* 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.
*/
*cp = '\0';
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
{
const char* progname = GetProgramName();
/*
* Resolve the real path to the directory containing the selected JRE.
*/
exit(1);
}
/*
* Resolve the real path to the currently running launcher.
*/
execname = GetExecName();
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 */
/*
* 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 (JLI_IsTraceLauncher()) {
int i;
printf("ReExec Args:");
printf("\n");
}
JLI_TraceLauncher("TRACER_MARKER:About to EXEC\n");
exit(1);
}
/*
* "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
borrowed_unsetenv(const char *name)
{
long idx; /* index into environ */
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));
}
const char *
return "%lld";
}
IsJavaw()
{
/* noop on UNIX */
return JNI_FALSE;
}
void
{
}
/*
* The implementation for finding classes from the bootstrap
* class loader, refer to java.h
*/
{
if (findBootClass == NULL) {
"JVM_FindClassFromBootLoader");
if (findBootClass == NULL) {
"JVM_FindClassFromBootLoader");
return NULL;
}
}
}