提交 94036782 编写于 作者: K ksrini

6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems

Summary: provided error reporting interfaces to other java subsystems that the launcher uses.
Reviewed-by: darcy
上级 0b15e286
...@@ -113,7 +113,11 @@ ifeq ($(PLATFORM), windows) ...@@ -113,7 +113,11 @@ ifeq ($(PLATFORM), windows)
JAVALIB = JAVALIB =
OTHER_LCF = -export:JLI_Launch \ OTHER_LCF = -export:JLI_Launch \
-export:JLI_ManifestIterate \ -export:JLI_ManifestIterate \
-export:JLI_SetTraceLauncher -export:JLI_SetTraceLauncher \
-export:JLI_ReportErrorMessage \
-export:JLI_ReportErrorMessageSys \
-export:JLI_ReportMessage \
-export:JLI_ReportExceptionDescription
endif endif
......
# #
# Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. # Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -30,6 +30,10 @@ SUNWprivate_1.1 { ...@@ -30,6 +30,10 @@ SUNWprivate_1.1 {
JLI_Launch; JLI_Launch;
JLI_ManifestIterate; JLI_ManifestIterate;
JLI_SetTraceLauncher; JLI_SetTraceLauncher;
JLI_ReportErrorMessage;
JLI_ReportErrorMessageSys;
JLI_ReportMessage;
JLI_ReportExceptionDescription;
local: local:
*; *;
}; };
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
/* /*
* This file primarily consists of all the error and warning messages, that * This file primarily consists of all the error and warning messages, that
* are used in ReportErrorMessage. All message must be defined here, in order * are used in JLI_ReportErrorMessage. All message must be defined here, in
* to help in I18N/L10N the messages. * order to help with localizing the messages.
*/ */
#ifndef _EMESSAGES_H #ifndef _EMESSAGES_H
......
...@@ -148,7 +148,7 @@ static void ShowSplashScreen(); ...@@ -148,7 +148,7 @@ static void ShowSplashScreen();
static jboolean IsWildCardEnabled(); static jboolean IsWildCardEnabled();
#define ARG_CHECK(n, f, a) if (n < 1) { \ #define ARG_CHECK(n, f, a) if (n < 1) { \
ReportErrorMessage(f, a); \ JLI_ReportErrorMessage(f, a); \
printUsage = JNI_TRUE; \ printUsage = JNI_TRUE; \
*pret = 1; \ *pret = 1; \
return JNI_TRUE; \ return JNI_TRUE; \
...@@ -326,15 +326,15 @@ JavaMain(void * _args) ...@@ -326,15 +326,15 @@ JavaMain(void * _args)
start = CounterGet(); start = CounterGet();
if (!InitializeJVM(&vm, &env, &ifn)) { if (!InitializeJVM(&vm, &env, &ifn)) {
ReportErrorMessage(JVM_ERROR1); JLI_ReportErrorMessage(JVM_ERROR1);
exit(1); exit(1);
} }
if (printVersion || showVersion) { if (printVersion || showVersion) {
PrintJavaVersion(env, showVersion); PrintJavaVersion(env, showVersion);
if ((*env)->ExceptionOccurred(env)) { if ((*env)->ExceptionOccurred(env)) {
ReportExceptionDescription(env); JLI_ReportExceptionDescription(env);
ReportErrorMessage(JNI_ERROR); JLI_ReportErrorMessage(JNI_ERROR);
goto leave; goto leave;
} }
if (printVersion) { if (printVersion) {
...@@ -347,8 +347,8 @@ JavaMain(void * _args) ...@@ -347,8 +347,8 @@ JavaMain(void * _args)
if (printXUsage || printUsage || (jarfile == 0 && classname == 0)) { if (printXUsage || printUsage || (jarfile == 0 && classname == 0)) {
PrintUsage(env, printXUsage); PrintUsage(env, printXUsage);
if ((*env)->ExceptionOccurred(env)) { if ((*env)->ExceptionOccurred(env)) {
ReportExceptionDescription(env); JLI_ReportExceptionDescription(env);
ReportErrorMessage(JNI_ERROR); JLI_ReportErrorMessage(JNI_ERROR);
ret=1; ret=1;
} }
goto leave; goto leave;
...@@ -397,43 +397,43 @@ JavaMain(void * _args) ...@@ -397,43 +397,43 @@ JavaMain(void * _args)
if (jarfile != 0) { if (jarfile != 0) {
mainClassName = GetMainClassName(env, jarfile); mainClassName = GetMainClassName(env, jarfile);
if ((*env)->ExceptionOccurred(env)) { if ((*env)->ExceptionOccurred(env)) {
ReportExceptionDescription(env); JLI_ReportExceptionDescription(env);
ReportErrorMessage(JNI_ERROR); JLI_ReportErrorMessage(JNI_ERROR);
goto leave; goto leave;
} }
if (mainClassName == NULL) { if (mainClassName == NULL) {
ReportErrorMessage(JAR_ERROR1,jarfile, GEN_ERROR); JLI_ReportErrorMessage(JAR_ERROR1,jarfile, GEN_ERROR);
goto leave; goto leave;
} }
classname = (char *)(*env)->GetStringUTFChars(env, mainClassName, 0); classname = (char *)(*env)->GetStringUTFChars(env, mainClassName, 0);
if (classname == NULL) { if (classname == NULL) {
ReportExceptionDescription(env); JLI_ReportExceptionDescription(env);
ReportErrorMessage(JNI_ERROR); JLI_ReportErrorMessage(JNI_ERROR);
goto leave; goto leave;
} }
mainClass = LoadClass(env, classname); mainClass = LoadClass(env, classname);
if(mainClass == NULL) { /* exception occured */ if(mainClass == NULL) { /* exception occured */
ReportExceptionDescription(env); JLI_ReportExceptionDescription(env);
ReportErrorMessage(CLS_ERROR1, classname); JLI_ReportErrorMessage(CLS_ERROR1, classname);
goto leave; goto leave;
} }
(*env)->ReleaseStringUTFChars(env, mainClassName, classname); (*env)->ReleaseStringUTFChars(env, mainClassName, classname);
} else { } else {
mainClassName = NewPlatformString(env, classname); mainClassName = NewPlatformString(env, classname);
if (mainClassName == NULL) { if (mainClassName == NULL) {
ReportErrorMessage(CLS_ERROR2, classname, GEN_ERROR); JLI_ReportErrorMessage(CLS_ERROR2, classname, GEN_ERROR);
goto leave; goto leave;
} }
classname = (char *)(*env)->GetStringUTFChars(env, mainClassName, 0); classname = (char *)(*env)->GetStringUTFChars(env, mainClassName, 0);
if (classname == NULL) { if (classname == NULL) {
ReportExceptionDescription(env); JLI_ReportExceptionDescription(env);
ReportErrorMessage(JNI_ERROR); JLI_ReportErrorMessage(JNI_ERROR);
goto leave; goto leave;
} }
mainClass = LoadClass(env, classname); mainClass = LoadClass(env, classname);
if(mainClass == NULL) { /* exception occured */ if(mainClass == NULL) { /* exception occured */
ReportExceptionDescription(env); JLI_ReportExceptionDescription(env);
ReportErrorMessage(CLS_ERROR1, classname); JLI_ReportErrorMessage(CLS_ERROR1, classname);
goto leave; goto leave;
} }
(*env)->ReleaseStringUTFChars(env, mainClassName, classname); (*env)->ReleaseStringUTFChars(env, mainClassName, classname);
...@@ -444,10 +444,10 @@ JavaMain(void * _args) ...@@ -444,10 +444,10 @@ JavaMain(void * _args)
"([Ljava/lang/String;)V"); "([Ljava/lang/String;)V");
if (mainID == NULL) { if (mainID == NULL) {
if ((*env)->ExceptionOccurred(env)) { if ((*env)->ExceptionOccurred(env)) {
ReportExceptionDescription(env); JLI_ReportExceptionDescription(env);
ReportErrorMessage(JNI_ERROR); JLI_ReportErrorMessage(JNI_ERROR);
} else { } else {
ReportErrorMessage(CLS_ERROR3); JLI_ReportErrorMessage(CLS_ERROR3);
} }
goto leave; goto leave;
} }
...@@ -459,8 +459,8 @@ JavaMain(void * _args) ...@@ -459,8 +459,8 @@ JavaMain(void * _args)
mainID, JNI_TRUE); mainID, JNI_TRUE);
if( obj == NULL) { /* exception occurred */ if( obj == NULL) { /* exception occurred */
ReportExceptionDescription(env); JLI_ReportExceptionDescription(env);
ReportErrorMessage(JNI_ERROR); JLI_ReportErrorMessage(JNI_ERROR);
goto leave; goto leave;
} }
...@@ -469,14 +469,14 @@ JavaMain(void * _args) ...@@ -469,14 +469,14 @@ JavaMain(void * _args)
(*env)->GetObjectClass(env, obj), (*env)->GetObjectClass(env, obj),
"getModifiers", "()I"); "getModifiers", "()I");
if ((*env)->ExceptionOccurred(env)) { if ((*env)->ExceptionOccurred(env)) {
ReportExceptionDescription(env); JLI_ReportExceptionDescription(env);
ReportErrorMessage(JNI_ERROR); JLI_ReportErrorMessage(JNI_ERROR);
goto leave; goto leave;
} }
mods = (*env)->CallIntMethod(env, obj, mid); mods = (*env)->CallIntMethod(env, obj, mid);
if ((mods & 1) == 0) { /* if (!Modifier.isPublic(mods)) ... */ if ((mods & 1) == 0) { /* if (!Modifier.isPublic(mods)) ... */
ReportErrorMessage(CLS_ERROR4); JLI_ReportErrorMessage(CLS_ERROR4);
goto leave; goto leave;
} }
} }
...@@ -484,8 +484,8 @@ JavaMain(void * _args) ...@@ -484,8 +484,8 @@ JavaMain(void * _args)
/* Build argument array */ /* Build argument array */
mainArgs = NewPlatformStringArray(env, argv, argc); mainArgs = NewPlatformStringArray(env, argv, argc);
if (mainArgs == NULL) { if (mainArgs == NULL) {
ReportExceptionDescription(env); JLI_ReportExceptionDescription(env);
ReportErrorMessage(JNI_ERROR); JLI_ReportErrorMessage(JNI_ERROR);
goto leave; goto leave;
} }
...@@ -506,7 +506,7 @@ JavaMain(void * _args) ...@@ -506,7 +506,7 @@ JavaMain(void * _args)
* launcher's return code except by calling System.exit. * launcher's return code except by calling System.exit.
*/ */
if ((*vm)->DetachCurrentThread(vm) != 0) { if ((*vm)->DetachCurrentThread(vm) != 0) {
ReportErrorMessage(JVM_ERROR2); JLI_ReportErrorMessage(JVM_ERROR2);
ret = 1; ret = 1;
goto leave; goto leave;
} }
...@@ -635,7 +635,7 @@ CheckJvmType(int *pargc, char ***argv, jboolean speculative) { ...@@ -635,7 +635,7 @@ CheckJvmType(int *pargc, char ***argv, jboolean speculative) {
if (loopCount > knownVMsCount) { if (loopCount > knownVMsCount) {
if (!speculative) { if (!speculative) {
ReportErrorMessage(CFG_ERROR1); JLI_ReportErrorMessage(CFG_ERROR1);
exit(1); exit(1);
} else { } else {
return "ERROR"; return "ERROR";
...@@ -645,7 +645,7 @@ CheckJvmType(int *pargc, char ***argv, jboolean speculative) { ...@@ -645,7 +645,7 @@ CheckJvmType(int *pargc, char ***argv, jboolean speculative) {
if (nextIdx < 0) { if (nextIdx < 0) {
if (!speculative) { if (!speculative) {
ReportErrorMessage(CFG_ERROR2, knownVMs[jvmidx].alias); JLI_ReportErrorMessage(CFG_ERROR2, knownVMs[jvmidx].alias);
exit(1); exit(1);
} else { } else {
return "ERROR"; return "ERROR";
...@@ -660,7 +660,7 @@ CheckJvmType(int *pargc, char ***argv, jboolean speculative) { ...@@ -660,7 +660,7 @@ CheckJvmType(int *pargc, char ***argv, jboolean speculative) {
switch (knownVMs[jvmidx].flag) { switch (knownVMs[jvmidx].flag) {
case VM_WARN: case VM_WARN:
if (!speculative) { if (!speculative) {
ReportErrorMessage(CFG_WARN1, jvmtype, knownVMs[0].name + 1); JLI_ReportErrorMessage(CFG_WARN1, jvmtype, knownVMs[0].name + 1);
} }
/* fall through */ /* fall through */
case VM_IGNORE: case VM_IGNORE:
...@@ -670,7 +670,7 @@ CheckJvmType(int *pargc, char ***argv, jboolean speculative) { ...@@ -670,7 +670,7 @@ CheckJvmType(int *pargc, char ***argv, jboolean speculative) {
break; break;
case VM_ERROR: case VM_ERROR:
if (!speculative) { if (!speculative) {
ReportErrorMessage(CFG_ERROR3, jvmtype); JLI_ReportErrorMessage(CFG_ERROR3, jvmtype);
exit(1); exit(1);
} else { } else {
return "ERROR"; return "ERROR";
...@@ -879,9 +879,9 @@ SelectVersion(int argc, char **argv, char **main_class) ...@@ -879,9 +879,9 @@ SelectVersion(int argc, char **argv, char **main_class)
if (jarflag && operand) { if (jarflag && operand) {
if ((res = JLI_ParseManifest(operand, &info)) != 0) { if ((res = JLI_ParseManifest(operand, &info)) != 0) {
if (res == -1) if (res == -1)
ReportErrorMessage(JAR_ERROR2, operand); JLI_ReportErrorMessage(JAR_ERROR2, operand);
else else
ReportErrorMessage(JAR_ERROR3, operand); JLI_ReportErrorMessage(JAR_ERROR3, operand);
exit(1); exit(1);
} }
...@@ -948,7 +948,7 @@ SelectVersion(int argc, char **argv, char **main_class) ...@@ -948,7 +948,7 @@ SelectVersion(int argc, char **argv, char **main_class)
* Check for correct syntax of the version specification (JSR 56). * Check for correct syntax of the version specification (JSR 56).
*/ */
if (!JLI_ValidVersionString(info.jre_version)) { if (!JLI_ValidVersionString(info.jre_version)) {
ReportErrorMessage(SPC_ERROR1, info.jre_version); JLI_ReportErrorMessage(SPC_ERROR1, info.jre_version);
exit(1); exit(1);
} }
...@@ -970,7 +970,7 @@ SelectVersion(int argc, char **argv, char **main_class) ...@@ -970,7 +970,7 @@ SelectVersion(int argc, char **argv, char **main_class)
JLI_MemFree(new_argv); JLI_MemFree(new_argv);
return; return;
} else { } else {
ReportErrorMessage(CFG_ERROR4, info.jre_version); JLI_ReportErrorMessage(CFG_ERROR4, info.jre_version);
exit(1); exit(1);
} }
} }
...@@ -1040,7 +1040,7 @@ ParseArguments(int *pargc, char ***pargv, char **pjarfile, ...@@ -1040,7 +1040,7 @@ ParseArguments(int *pargc, char ***pargv, char **pjarfile,
* command line options. * command line options.
*/ */
} else if (JLI_StrCmp(arg, "-fullversion") == 0) { } else if (JLI_StrCmp(arg, "-fullversion") == 0) {
ReportMessage("%s full version \"%s\"", _launcher_name, GetFullVersion()); JLI_ReportMessage("%s full version \"%s\"", _launcher_name, GetFullVersion());
return JNI_FALSE; return JNI_FALSE;
} else if (JLI_StrCmp(arg, "-verbosegc") == 0) { } else if (JLI_StrCmp(arg, "-verbosegc") == 0) {
AddOption("-verbose:gc", NULL); AddOption("-verbose:gc", NULL);
...@@ -1080,7 +1080,7 @@ ParseArguments(int *pargc, char ***pargv, char **pjarfile, ...@@ -1080,7 +1080,7 @@ ParseArguments(int *pargc, char ***pargv, char **pjarfile,
JLI_StrCmp(arg, "-cs") == 0 || JLI_StrCmp(arg, "-cs") == 0 ||
JLI_StrCmp(arg, "-noasyncgc") == 0) { JLI_StrCmp(arg, "-noasyncgc") == 0) {
/* No longer supported */ /* No longer supported */
ReportErrorMessage(ARG_WARN, arg); JLI_ReportErrorMessage(ARG_WARN, arg);
} else if (JLI_StrCCmp(arg, "-version:") == 0 || } else if (JLI_StrCCmp(arg, "-version:") == 0 ||
JLI_StrCmp(arg, "-no-jre-restrict-search") == 0 || JLI_StrCmp(arg, "-no-jre-restrict-search") == 0 ||
JLI_StrCmp(arg, "-jre-restrict-search") == 0 || JLI_StrCmp(arg, "-jre-restrict-search") == 0 ||
...@@ -1143,12 +1143,12 @@ InitializeJVM(JavaVM **pvm, JNIEnv **penv, InvocationFunctions *ifn) ...@@ -1143,12 +1143,12 @@ InitializeJVM(JavaVM **pvm, JNIEnv **penv, InvocationFunctions *ifn)
#define NULL_CHECK0(e) if ((e) == 0) { \ #define NULL_CHECK0(e) if ((e) == 0) { \
ReportErrorMessage(JNI_ERROR); \ JLI_ReportErrorMessage(JNI_ERROR); \
return 0; \ return 0; \
} }
#define NULL_CHECK(e) if ((e) == 0) { \ #define NULL_CHECK(e) if ((e) == 0) { \
ReportErrorMessage(JNI_ERROR); \ JLI_ReportErrorMessage(JNI_ERROR); \
return; \ return; \
} }
...@@ -1351,7 +1351,7 @@ TranslateApplicationArgs(int jargc, const char **jargv, int *pargc, char ***parg ...@@ -1351,7 +1351,7 @@ TranslateApplicationArgs(int jargc, const char **jargv, int *pargc, char ***parg
char *arg = argv[i]; char *arg = argv[i];
if (arg[0] == '-' && arg[1] == 'J') { if (arg[0] == '-' && arg[1] == 'J') {
if (arg[2] == '\0') { if (arg[2] == '\0') {
ReportErrorMessage(ARG_ERROR3); JLI_ReportErrorMessage(ARG_ERROR3);
exit(1); exit(1);
} }
*nargv++ = arg + 2; *nargv++ = arg + 2;
...@@ -1418,7 +1418,7 @@ AddApplicationOptions(int cpathc, const char **cpathv) ...@@ -1418,7 +1418,7 @@ AddApplicationOptions(int cpathc, const char **cpathv)
} }
if (!GetApplicationHome(home, sizeof(home))) { if (!GetApplicationHome(home, sizeof(home))) {
ReportErrorMessage(CFG_ERROR5); JLI_ReportErrorMessage(CFG_ERROR5);
return JNI_FALSE; return JNI_FALSE;
} }
...@@ -1691,7 +1691,7 @@ ReadKnownVMs(const char *jrepath, const char * arch, jboolean speculative) ...@@ -1691,7 +1691,7 @@ ReadKnownVMs(const char *jrepath, const char * arch, jboolean speculative)
jvmCfg = fopen(jvmCfgName, "r"); jvmCfg = fopen(jvmCfgName, "r");
if (jvmCfg == NULL) { if (jvmCfg == NULL) {
if (!speculative) { if (!speculative) {
ReportErrorMessage(CFG_ERROR6, jvmCfgName); JLI_ReportErrorMessage(CFG_ERROR6, jvmCfgName);
exit(1); exit(1);
} else { } else {
return -1; return -1;
...@@ -1703,7 +1703,7 @@ ReadKnownVMs(const char *jrepath, const char * arch, jboolean speculative) ...@@ -1703,7 +1703,7 @@ ReadKnownVMs(const char *jrepath, const char * arch, jboolean speculative)
if (line[0] == '#') if (line[0] == '#')
continue; continue;
if (line[0] != '-') { if (line[0] != '-') {
ReportErrorMessage(CFG_WARN2, lineno, jvmCfgName); JLI_ReportErrorMessage(CFG_WARN2, lineno, jvmCfgName);
} }
if (cnt >= knownVMsLimit) { if (cnt >= knownVMsLimit) {
GrowKnownVMs(cnt); GrowKnownVMs(cnt);
...@@ -1711,13 +1711,13 @@ ReadKnownVMs(const char *jrepath, const char * arch, jboolean speculative) ...@@ -1711,13 +1711,13 @@ ReadKnownVMs(const char *jrepath, const char * arch, jboolean speculative)
line[JLI_StrLen(line)-1] = '\0'; /* remove trailing newline */ line[JLI_StrLen(line)-1] = '\0'; /* remove trailing newline */
tmpPtr = line + JLI_StrCSpn(line, whiteSpace); tmpPtr = line + JLI_StrCSpn(line, whiteSpace);
if (*tmpPtr == 0) { if (*tmpPtr == 0) {
ReportErrorMessage(CFG_WARN3, lineno, jvmCfgName); JLI_ReportErrorMessage(CFG_WARN3, lineno, jvmCfgName);
} else { } else {
/* Null-terminate this string for JLI_StringDup below */ /* Null-terminate this string for JLI_StringDup below */
*tmpPtr++ = 0; *tmpPtr++ = 0;
tmpPtr += JLI_StrSpn(tmpPtr, whiteSpace); tmpPtr += JLI_StrSpn(tmpPtr, whiteSpace);
if (*tmpPtr == 0) { if (*tmpPtr == 0) {
ReportErrorMessage(CFG_WARN3, lineno, jvmCfgName); JLI_ReportErrorMessage(CFG_WARN3, lineno, jvmCfgName);
} else { } else {
if (!JLI_StrCCmp(tmpPtr, "KNOWN")) { if (!JLI_StrCCmp(tmpPtr, "KNOWN")) {
vmType = VM_KNOWN; vmType = VM_KNOWN;
...@@ -1727,7 +1727,7 @@ ReadKnownVMs(const char *jrepath, const char * arch, jboolean speculative) ...@@ -1727,7 +1727,7 @@ ReadKnownVMs(const char *jrepath, const char * arch, jboolean speculative)
tmpPtr += JLI_StrSpn(tmpPtr, whiteSpace); tmpPtr += JLI_StrSpn(tmpPtr, whiteSpace);
} }
if (*tmpPtr == 0) { if (*tmpPtr == 0) {
ReportErrorMessage(CFG_WARN3, lineno, jvmCfgName); JLI_ReportErrorMessage(CFG_WARN3, lineno, jvmCfgName);
} else { } else {
/* Null terminate altVMName */ /* Null terminate altVMName */
altVMName = tmpPtr; altVMName = tmpPtr;
...@@ -1747,7 +1747,7 @@ ReadKnownVMs(const char *jrepath, const char * arch, jboolean speculative) ...@@ -1747,7 +1747,7 @@ ReadKnownVMs(const char *jrepath, const char * arch, jboolean speculative)
tmpPtr += JLI_StrSpn(tmpPtr, whiteSpace); tmpPtr += JLI_StrSpn(tmpPtr, whiteSpace);
} }
if (*tmpPtr == 0) { if (*tmpPtr == 0) {
ReportErrorMessage(CFG_WARN4, lineno, jvmCfgName); JLI_ReportErrorMessage(CFG_WARN4, lineno, jvmCfgName);
} else { } else {
/* Null terminate server class VM name */ /* Null terminate server class VM name */
serverClassVMName = tmpPtr; serverClassVMName = tmpPtr;
...@@ -1756,7 +1756,7 @@ ReadKnownVMs(const char *jrepath, const char * arch, jboolean speculative) ...@@ -1756,7 +1756,7 @@ ReadKnownVMs(const char *jrepath, const char * arch, jboolean speculative)
vmType = VM_IF_SERVER_CLASS; vmType = VM_IF_SERVER_CLASS;
} }
} else { } else {
ReportErrorMessage(CFG_WARN5, lineno, &jvmCfgName[0]); JLI_ReportErrorMessage(CFG_WARN5, lineno, &jvmCfgName[0]);
vmType = VM_KNOWN; vmType = VM_KNOWN;
} }
} }
...@@ -2019,7 +2019,7 @@ RemovableOption(char * option) ...@@ -2019,7 +2019,7 @@ RemovableOption(char * option)
* A utility procedure to always print to stderr * A utility procedure to always print to stderr
*/ */
void void
ReportMessage(const char* fmt, ...) JLI_ReportMessage(const char* fmt, ...)
{ {
va_list vl; va_list vl;
va_start(vl, fmt); va_start(vl, fmt);
......
...@@ -121,24 +121,20 @@ void CreateExecutionEnvironment(int *_argc, ...@@ -121,24 +121,20 @@ void CreateExecutionEnvironment(int *_argc,
char jvmpath[], char jvmpath[],
jint so_jvmpath, jint so_jvmpath,
char **original_argv); char **original_argv);
/* Reports an error message to stderr or a window as appropriate. */
void JLI_ReportErrorMessage(const char * message, ...);
/* /* Reports a system error message to stderr or a window */
* Report an error message to stderr or a window as appropriate. void JLI_ReportErrorMessageSys(const char * message, ...);
*/
void ReportErrorMessage(const char * message, ...);
void ReportErrorMessageSys(const char * format, ...);
/* /* Reports an error message only to stderr. */
* Report an error message only to stderr. void JLI_ReportMessage(const char * message, ...);
*/
void ReportMessage(const char * message, ...);
/* /*
* Report an exception which terminates the vm to stderr or a window * Reports an exception which terminates the vm to stderr or a window
* as appropriate. * as appropriate.
*/ */
void ReportExceptionDescription(JNIEnv * env); void JLI_ReportExceptionDescription(JNIEnv * env);
void PrintMachineDependentOptions(); void PrintMachineDependentOptions();
const char *jlong_format_specifier(); const char *jlong_format_specifier();
......
...@@ -289,13 +289,13 @@ CreateExecutionEnvironment(int *_argcp, ...@@ -289,13 +289,13 @@ CreateExecutionEnvironment(int *_argcp,
if (wanted == running) { if (wanted == running) {
/* Find out where the JRE is that we will be using. */ /* Find out where the JRE is that we will be using. */
if (!GetJREPath(jrepath, so_jrepath, arch, JNI_FALSE) ) { if (!GetJREPath(jrepath, so_jrepath, arch, JNI_FALSE) ) {
ReportErrorMessage(JRE_ERROR1); JLI_ReportErrorMessage(JRE_ERROR1);
exit(2); exit(2);
} }
/* Find the specified JVM type */ /* Find the specified JVM type */
if (ReadKnownVMs(jrepath, arch, JNI_FALSE) < 1) { if (ReadKnownVMs(jrepath, arch, JNI_FALSE) < 1) {
ReportErrorMessage(CFG_ERROR7); JLI_ReportErrorMessage(CFG_ERROR7);
exit(1); exit(1);
} }
...@@ -303,7 +303,7 @@ CreateExecutionEnvironment(int *_argcp, ...@@ -303,7 +303,7 @@ CreateExecutionEnvironment(int *_argcp,
jvmtype = CheckJvmType(_argcp, _argvp, JNI_FALSE); jvmtype = CheckJvmType(_argcp, _argvp, JNI_FALSE);
if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath, arch )) { if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath, arch )) {
ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath); JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath);
exit(4); exit(4);
} }
} else { /* do the same speculatively or exit */ } else { /* do the same speculatively or exit */
...@@ -330,7 +330,7 @@ CreateExecutionEnvironment(int *_argcp, ...@@ -330,7 +330,7 @@ CreateExecutionEnvironment(int *_argcp,
EndDataModelSpeculate: /* give up and let other code report error message */ EndDataModelSpeculate: /* give up and let other code report error message */
; ;
#else #else
ReportErrorMessage(JRE_ERROR2, wanted); JLI_ReportErrorMessage(JRE_ERROR2, wanted);
exit(1); exit(1);
#endif #endif
} }
...@@ -391,7 +391,7 @@ CreateExecutionEnvironment(int *_argcp, ...@@ -391,7 +391,7 @@ CreateExecutionEnvironment(int *_argcp,
break; break;
default: default:
ReportErrorMessage(JRE_ERROR3, __LINE__); JLI_ReportErrorMessage(JRE_ERROR3, __LINE__);
exit(1); /* unknown value in wanted */ exit(1); /* unknown value in wanted */
break; break;
} }
...@@ -553,17 +553,17 @@ CreateExecutionEnvironment(int *_argcp, ...@@ -553,17 +553,17 @@ CreateExecutionEnvironment(int *_argcp,
(void)fflush(stdout); (void)fflush(stdout);
(void)fflush(stderr); (void)fflush(stderr);
execve(newexec, argv, newenvp); execve(newexec, argv, newenvp);
ReportErrorMessageSys(JRE_ERROR4, newexec); JLI_ReportErrorMessageSys(JRE_ERROR4, newexec);
#ifdef DUAL_MODE #ifdef DUAL_MODE
if (running != wanted) { if (running != wanted) {
ReportErrorMessage(JRE_ERROR5, wanted, running); JLI_ReportErrorMessage(JRE_ERROR5, wanted, running);
# ifdef __solaris__ # ifdef __solaris__
# ifdef __sparc # ifdef __sparc
ReportErrorMessage(JRE_ERROR6); JLI_ReportErrorMessage(JRE_ERROR6);
# else # else
ReportErrorMessage(JRE_ERROR7); JLI_ReportErrorMessage(JRE_ERROR7);
# endif # endif
} }
# endif # endif
...@@ -627,7 +627,7 @@ GetJREPath(char *path, jint pathsize, const char * arch, jboolean speculative) ...@@ -627,7 +627,7 @@ GetJREPath(char *path, jint pathsize, const char * arch, jboolean speculative)
} }
if (!speculative) if (!speculative)
ReportErrorMessage(JRE_ERROR8 JAVA_DLL); JLI_ReportErrorMessage(JRE_ERROR8 JAVA_DLL);
return JNI_FALSE; return JNI_FALSE;
found: found:
...@@ -680,13 +680,13 @@ LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn) ...@@ -680,13 +680,13 @@ LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn)
if(length > 0) { if(length > 0) {
location = JLI_StrStr(buf, "sparcv8plus "); location = JLI_StrStr(buf, "sparcv8plus ");
if(location == NULL) { if(location == NULL) {
ReportErrorMessage(JVM_ERROR3); JLI_ReportErrorMessage(JVM_ERROR3);
return JNI_FALSE; return JNI_FALSE;
} }
} }
} }
#endif #endif
ReportErrorMessage(DLL_ERROR1, __LINE__); JLI_ReportErrorMessage(DLL_ERROR1, __LINE__);
goto error; goto error;
} }
...@@ -703,7 +703,7 @@ LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn) ...@@ -703,7 +703,7 @@ LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn)
return JNI_TRUE; return JNI_TRUE;
error: error:
ReportErrorMessage(DLL_ERROR2, jvmpath, dlerror()); JLI_ReportErrorMessage(DLL_ERROR2, jvmpath, dlerror());
return JNI_FALSE; return JNI_FALSE;
} }
...@@ -848,7 +848,7 @@ SetExecname(char **argv) ...@@ -848,7 +848,7 @@ SetExecname(char **argv)
fptr = (int (*)())dlsym(RTLD_DEFAULT, "main"); fptr = (int (*)())dlsym(RTLD_DEFAULT, "main");
if (fptr == NULL) { if (fptr == NULL) {
ReportErrorMessage(DLL_ERROR3, dlerror()); JLI_ReportErrorMessage(DLL_ERROR3, dlerror());
return JNI_FALSE; return JNI_FALSE;
} }
...@@ -885,7 +885,7 @@ SetExecname(char **argv) ...@@ -885,7 +885,7 @@ SetExecname(char **argv)
return exec_path; return exec_path;
} }
void ReportErrorMessage(const char* fmt, ...) { void JLI_ReportErrorMessage(const char* fmt, ...) {
va_list vl; va_list vl;
va_start(vl, fmt); va_start(vl, fmt);
vfprintf(stderr, fmt, vl); vfprintf(stderr, fmt, vl);
...@@ -893,7 +893,7 @@ void ReportErrorMessage(const char* fmt, ...) { ...@@ -893,7 +893,7 @@ void ReportErrorMessage(const char* fmt, ...) {
va_end(vl); va_end(vl);
} }
void ReportErrorMessageSys(const char* fmt, ...) { void JLI_ReportErrorMessageSys(const char* fmt, ...) {
va_list vl; va_list vl;
char *emsg; char *emsg;
...@@ -912,7 +912,7 @@ void ReportErrorMessageSys(const char* fmt, ...) { ...@@ -912,7 +912,7 @@ void ReportErrorMessageSys(const char* fmt, ...) {
va_end(vl); va_end(vl);
} }
void ReportExceptionDescription(JNIEnv * env) { void JLI_ReportExceptionDescription(JNIEnv * env) {
(*env)->ExceptionDescribe(env); (*env)->ExceptionDescribe(env);
} }
...@@ -1078,7 +1078,7 @@ ExecJRE(char *jre, char **argv) ...@@ -1078,7 +1078,7 @@ ExecJRE(char *jre, char **argv)
* Resolve the real path to the directory containing the selected JRE. * Resolve the real path to the directory containing the selected JRE.
*/ */
if (realpath(jre, wanted) == NULL) { if (realpath(jre, wanted) == NULL) {
ReportErrorMessage(JRE_ERROR9, jre); JLI_ReportErrorMessage(JRE_ERROR9, jre);
exit(1); exit(1);
} }
...@@ -1087,7 +1087,7 @@ ExecJRE(char *jre, char **argv) ...@@ -1087,7 +1087,7 @@ ExecJRE(char *jre, char **argv)
*/ */
SetExecname(argv); SetExecname(argv);
if (execname == NULL) { if (execname == NULL) {
ReportErrorMessage(JRE_ERROR10); JLI_ReportErrorMessage(JRE_ERROR10);
exit(1); exit(1);
} }
...@@ -1106,7 +1106,7 @@ ExecJRE(char *jre, char **argv) ...@@ -1106,7 +1106,7 @@ ExecJRE(char *jre, char **argv)
* can be so deadly. * can be so deadly.
*/ */
if (JLI_StrLen(wanted) + JLI_StrLen(progname) + 6 > PATH_MAX) { if (JLI_StrLen(wanted) + JLI_StrLen(progname) + 6 > PATH_MAX) {
ReportErrorMessage(JRE_ERROR11); JLI_ReportErrorMessage(JRE_ERROR11);
exit(1); exit(1);
} }
...@@ -1126,7 +1126,7 @@ ExecJRE(char *jre, char **argv) ...@@ -1126,7 +1126,7 @@ ExecJRE(char *jre, char **argv)
(void)fflush(stdout); (void)fflush(stdout);
(void)fflush(stderr); (void)fflush(stderr);
execv(wanted, argv); execv(wanted, argv);
ReportErrorMessageSys(JRE_ERROR12, wanted); JLI_ReportErrorMessageSys(JRE_ERROR12, wanted);
exit(1); exit(1);
} }
......
...@@ -105,26 +105,26 @@ CreateExecutionEnvironment(int *_argc, ...@@ -105,26 +105,26 @@ CreateExecutionEnvironment(int *_argc,
} }
} }
if (running != wanted) { if (running != wanted) {
ReportErrorMessage(JRE_ERROR2, wanted); JLI_ReportErrorMessage(JRE_ERROR2, wanted);
exit(1); exit(1);
} }
/* Find out where the JRE is that we will be using. */ /* Find out where the JRE is that we will be using. */
if (!GetJREPath(jrepath, so_jrepath)) { if (!GetJREPath(jrepath, so_jrepath)) {
ReportErrorMessage(JRE_ERROR1); JLI_ReportErrorMessage(JRE_ERROR1);
exit(2); exit(2);
} }
/* Find the specified JVM type */ /* Find the specified JVM type */
if (ReadKnownVMs(jrepath, (char*)GetArch(), JNI_FALSE) < 1) { if (ReadKnownVMs(jrepath, (char*)GetArch(), JNI_FALSE) < 1) {
ReportErrorMessage(CFG_ERROR7); JLI_ReportErrorMessage(CFG_ERROR7);
exit(1); exit(1);
} }
jvmtype = CheckJvmType(_argc, _argv, JNI_FALSE); jvmtype = CheckJvmType(_argc, _argv, JNI_FALSE);
jvmpath[0] = '\0'; jvmpath[0] = '\0';
if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath)) { if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath)) {
ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath); JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath);
exit(4); exit(4);
} }
/* If we got here, jvmpath has been correctly initialized. */ /* If we got here, jvmpath has been correctly initialized. */
...@@ -160,7 +160,7 @@ GetJREPath(char *path, jint pathsize) ...@@ -160,7 +160,7 @@ GetJREPath(char *path, jint pathsize)
goto found; goto found;
} }
ReportErrorMessage(JRE_ERROR8 JAVA_DLL); JLI_ReportErrorMessage(JRE_ERROR8 JAVA_DLL);
return JNI_FALSE; return JNI_FALSE;
found: found:
...@@ -212,7 +212,7 @@ LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn) ...@@ -212,7 +212,7 @@ LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn)
JLI_TraceLauncher("CRT path is %s\n", crtpath); JLI_TraceLauncher("CRT path is %s\n", crtpath);
if (_access(crtpath, 0) == 0) { if (_access(crtpath, 0) == 0) {
if (LoadLibrary(crtpath) == 0) { if (LoadLibrary(crtpath) == 0) {
ReportErrorMessage(DLL_ERROR4, crtpath); JLI_ReportErrorMessage(DLL_ERROR4, crtpath);
return JNI_FALSE; return JNI_FALSE;
} }
} }
...@@ -220,7 +220,7 @@ LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn) ...@@ -220,7 +220,7 @@ LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn)
/* Load the Java VM DLL */ /* Load the Java VM DLL */
if ((handle = LoadLibrary(jvmpath)) == 0) { if ((handle = LoadLibrary(jvmpath)) == 0) {
ReportErrorMessage(DLL_ERROR4, (char *)jvmpath); JLI_ReportErrorMessage(DLL_ERROR4, (char *)jvmpath);
return JNI_FALSE; return JNI_FALSE;
} }
...@@ -230,7 +230,7 @@ LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn) ...@@ -230,7 +230,7 @@ LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn)
ifn->GetDefaultJavaVMInitArgs = ifn->GetDefaultJavaVMInitArgs =
(void *)GetProcAddress(handle, "JNI_GetDefaultJavaVMInitArgs"); (void *)GetProcAddress(handle, "JNI_GetDefaultJavaVMInitArgs");
if (ifn->CreateJavaVM == 0 || ifn->GetDefaultJavaVMInitArgs == 0) { if (ifn->CreateJavaVM == 0 || ifn->GetDefaultJavaVMInitArgs == 0) {
ReportErrorMessage(JNI_ERROR1, (char *)jvmpath); JLI_ReportErrorMessage(JNI_ERROR1, (char *)jvmpath);
return JNI_FALSE; return JNI_FALSE;
} }
...@@ -292,19 +292,19 @@ GetPublicJREHome(char *buf, jint bufsize) ...@@ -292,19 +292,19 @@ GetPublicJREHome(char *buf, jint bufsize)
/* Find the current version of the JRE */ /* Find the current version of the JRE */
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, JRE_KEY, 0, KEY_READ, &key) != 0) { if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, JRE_KEY, 0, KEY_READ, &key) != 0) {
ReportErrorMessage(REG_ERROR1, JRE_KEY); JLI_ReportErrorMessage(REG_ERROR1, JRE_KEY);
return JNI_FALSE; return JNI_FALSE;
} }
if (!GetStringFromRegistry(key, "CurrentVersion", if (!GetStringFromRegistry(key, "CurrentVersion",
version, sizeof(version))) { version, sizeof(version))) {
ReportErrorMessage(REG_ERROR2, JRE_KEY); JLI_ReportErrorMessage(REG_ERROR2, JRE_KEY);
RegCloseKey(key); RegCloseKey(key);
return JNI_FALSE; return JNI_FALSE;
} }
if (JLI_StrCmp(version, GetDotVersion()) != 0) { if (JLI_StrCmp(version, GetDotVersion()) != 0) {
ReportErrorMessage(REG_ERROR3, JRE_KEY, version, GetDotVersion() JLI_ReportErrorMessage(REG_ERROR3, JRE_KEY, version, GetDotVersion()
); );
RegCloseKey(key); RegCloseKey(key);
return JNI_FALSE; return JNI_FALSE;
...@@ -312,13 +312,13 @@ GetPublicJREHome(char *buf, jint bufsize) ...@@ -312,13 +312,13 @@ GetPublicJREHome(char *buf, jint bufsize)
/* Find directory where the current version is installed. */ /* Find directory where the current version is installed. */
if (RegOpenKeyEx(key, version, 0, KEY_READ, &subkey) != 0) { if (RegOpenKeyEx(key, version, 0, KEY_READ, &subkey) != 0) {
ReportErrorMessage(REG_ERROR1, JRE_KEY, version); JLI_ReportErrorMessage(REG_ERROR1, JRE_KEY, version);
RegCloseKey(key); RegCloseKey(key);
return JNI_FALSE; return JNI_FALSE;
} }
if (!GetStringFromRegistry(subkey, "JavaHome", buf, bufsize)) { if (!GetStringFromRegistry(subkey, "JavaHome", buf, bufsize)) {
ReportErrorMessage(REG_ERROR4, JRE_KEY, version); JLI_ReportErrorMessage(REG_ERROR4, JRE_KEY, version);
RegCloseKey(key); RegCloseKey(key);
RegCloseKey(subkey); RegCloseKey(subkey);
return JNI_FALSE; return JNI_FALSE;
...@@ -370,7 +370,7 @@ jlong Counter2Micros(jlong counts) ...@@ -370,7 +370,7 @@ jlong Counter2Micros(jlong counts)
} }
void void
ReportErrorMessage(const char* fmt, ...) { JLI_ReportErrorMessage(const char* fmt, ...) {
va_list vl; va_list vl;
va_start(vl,fmt); va_start(vl,fmt);
...@@ -394,12 +394,12 @@ ReportErrorMessage(const char* fmt, ...) { ...@@ -394,12 +394,12 @@ ReportErrorMessage(const char* fmt, ...) {
} }
/* /*
* Just like ReportErrorMessage, except that it concatenates the system * Just like JLI_ReportErrorMessage, except that it concatenates the system
* error message if any, its upto the calling routine to correctly * error message if any, its upto the calling routine to correctly
* format the separation of the messages. * format the separation of the messages.
*/ */
void void
ReportErrorMessageSys(const char *fmt, ...) JLI_ReportErrorMessageSys(const char *fmt, ...)
{ {
va_list vl; va_list vl;
...@@ -462,7 +462,7 @@ ReportErrorMessageSys(const char *fmt, ...) ...@@ -462,7 +462,7 @@ ReportErrorMessageSys(const char *fmt, ...)
va_end(vl); va_end(vl);
} }
void ReportExceptionDescription(JNIEnv * env) { void JLI_ReportExceptionDescription(JNIEnv * env) {
if (IsJavaw()) { if (IsJavaw()) {
/* /*
* This code should be replaced by code which opens a window with * This code should be replaced by code which opens a window with
...@@ -733,7 +733,7 @@ ExecJRE(char *jre, char **argv) { ...@@ -733,7 +733,7 @@ ExecJRE(char *jre, char **argv) {
*/ */
len = GetModuleFileName(NULL, path, MAXPATHLEN + 1); len = GetModuleFileName(NULL, path, MAXPATHLEN + 1);
if (len == 0 || len > MAXPATHLEN) { if (len == 0 || len > MAXPATHLEN) {
ReportErrorMessageSys(JRE_ERROR9, progname); JLI_ReportErrorMessageSys(JRE_ERROR9, progname);
exit(1); exit(1);
} }
...@@ -766,7 +766,7 @@ ExecJRE(char *jre, char **argv) { ...@@ -766,7 +766,7 @@ ExecJRE(char *jre, char **argv) {
* If it weren't for this semantic flaw, the code below would be ... * If it weren't for this semantic flaw, the code below would be ...
* *
* execv(path, argv); * execv(path, argv);
* ReportErrorMessage("Error: Exec of %s failed\n", path); * JLI_ReportErrorMessage("Error: Exec of %s failed\n", path);
* exit(1); * exit(1);
* *
* The incorrect exec semantics could be addressed by: * The incorrect exec semantics could be addressed by:
...@@ -876,7 +876,7 @@ ExecJRE(char *jre, char **argv) { ...@@ -876,7 +876,7 @@ ExecJRE(char *jre, char **argv) {
(LPCTSTR)NULL, /* current directory */ (LPCTSTR)NULL, /* current directory */
(LPSTARTUPINFO)&si, /* (in) startup information */ (LPSTARTUPINFO)&si, /* (in) startup information */
(LPPROCESS_INFORMATION)&pi)) { /* (out) process information */ (LPPROCESS_INFORMATION)&pi)) { /* (out) process information */
ReportErrorMessageSys(SYS_ERROR1, path); JLI_ReportErrorMessageSys(SYS_ERROR1, path);
exit(1); exit(1);
} }
...@@ -884,7 +884,7 @@ ExecJRE(char *jre, char **argv) { ...@@ -884,7 +884,7 @@ ExecJRE(char *jre, char **argv) {
if (GetExitCodeProcess(pi.hProcess, &exitCode) == FALSE) if (GetExitCodeProcess(pi.hProcess, &exitCode) == FALSE)
exitCode = 1; exitCode = 1;
} else { } else {
ReportErrorMessage(SYS_ERROR2); JLI_ReportErrorMessage(SYS_ERROR2);
exitCode = 1; exitCode = 1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册