Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Niefer2009-11-13 15:20:21 -0500
committerAndrew Niefer2009-11-13 15:20:21 -0500
commit0be2d5d341a4365caf6fa6fb7eae3c56d67ec1b5 (patch)
tree887783615c18a7e13ef3e28e8fdc6b2782d55d23
parentc70c29c1cda284f217ebadc90224027227c23d67 (diff)
downloadrt.equinox.framework-0be2d5d341a4365caf6fa6fb7eae3c56d67ec1b5.tar.gz
rt.equinox.framework-0be2d5d341a4365caf6fa6fb7eae3c56d67ec1b5.tar.xz
rt.equinox.framework-0be2d5d341a4365caf6fa6fb7eae3c56d67ec1b5.zip
bug 291919 - improved error messages
-rw-r--r--bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbon.c15
-rw-r--r--bundles/org.eclipse.equinox.executable/library/eclipse.c47
-rw-r--r--bundles/org.eclipse.equinox.executable/library/eclipseJNI.c45
-rw-r--r--bundles/org.eclipse.equinox.executable/library/eclipseJNI.h7
-rw-r--r--bundles/org.eclipse.equinox.executable/library/eclipseNix.c2
-rw-r--r--bundles/org.eclipse.equinox.executable/library/eclipseOS.h6
-rw-r--r--bundles/org.eclipse.equinox.executable/library/eclipseShm.c7
-rw-r--r--bundles/org.eclipse.equinox.executable/library/gtk/eclipseGtk.c15
-rw-r--r--bundles/org.eclipse.equinox.executable/library/make_version.mak2
-rw-r--r--bundles/org.eclipse.equinox.executable/library/motif/eclipseMotif.c14
-rw-r--r--bundles/org.eclipse.equinox.executable/library/win32/eclipseWin.c14
-rw-r--r--bundles/org.eclipse.equinox.executable/library/wpf/eclipseWpf.cpp15
12 files changed, 139 insertions, 50 deletions
diff --git a/bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbon.c b/bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbon.c
index e5da4e69a..3bd9a51c6 100644
--- a/bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbon.c
+++ b/bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbon.c
@@ -35,6 +35,8 @@
#define DEBUG 0
+static _TCHAR* noForkingMsg = _T_ECLIPSE("Internal Error, forking the jvm is not supported on MacOS.\n");
+
char *findCommand(char *command);
/* Global Variables */
@@ -51,7 +53,7 @@ typedef struct {
_TCHAR ** vmArgs;
_TCHAR ** progArgs;
_TCHAR * jarFile;
- int result;
+ JavaResults* result;
} StartVMArgs;
#ifdef COCOA
@@ -337,13 +339,17 @@ void restartLauncher( char* program, char* args[] )
}
}
-int launchJavaVM( _TCHAR* args[] )
+JavaResults* launchJavaVM( _TCHAR* args[] )
{
/*for now always do JNI on Mac, should not come in here */
- return -1;
+ JavaResults * results = malloc(sizeof(JavaResults));
+ results->launchResult = -1;
+ results->runResult = 0;
+ results->errorMessage = _tcsdup(noForkingMsg);
+ return results;
}
-int startJavaVM( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[], _TCHAR* jarFile )
+JavaResults* startJavaVM( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[], _TCHAR* jarFile )
{
if (secondThread == 0) {
/* Set an environment variable that tells the AWT (if started) we started the JVM on the main thread. */
@@ -379,6 +385,7 @@ int startJavaVM( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[], _TCHAR*
args.vmArgs = vmArgs;
args.progArgs = progArgs;
args.jarFile = jarFile;
+ args.result = 0;
loopRef = CFRunLoopGetCurrent();
diff --git a/bundles/org.eclipse.equinox.executable/library/eclipse.c b/bundles/org.eclipse.equinox.executable/library/eclipse.c
index 204b1009f..d0b39638d 100644
--- a/bundles/org.eclipse.equinox.executable/library/eclipse.c
+++ b/bundles/org.eclipse.equinox.executable/library/eclipse.c
@@ -187,6 +187,8 @@ _TCHAR** initialArgv = NULL;
/* Define error messages. (non-NLS) */
static _TCHAR* exitMsg = _T_ECLIPSE("JVM terminated. Exit code=%d\n%s");
+static _TCHAR* javaFailureMsg = _T_ECLIPSE("Internal Error, unable to determine the results of running the JVM.");
+static _TCHAR* returnCodeMsg = _T_ECLIPSE("Java was started but returned exit code=%d\n%s");
static _TCHAR* goVMMsg = _T_ECLIPSE("Start VM: %s\n");
static _TCHAR* pathMsg = _T_ECLIPSE("%s in your current PATH");
static _TCHAR* shareMsg = _T_ECLIPSE("No exit data available.");
@@ -354,7 +356,7 @@ JNIEXPORT int run(int argc, _TCHAR* argv[], _TCHAR* vmArgs[])
_TCHAR** progCommandArgs = NULL;
_TCHAR** relaunchCommand = NULL;
_TCHAR* errorMsg = NULL, *msg = NULL;
- int exitCode = 0;
+ JavaResults* javaResults = NULL;
int launchMode;
int running = 1;
@@ -475,12 +477,20 @@ JNIEXPORT int run(int argc, _TCHAR* argv[], _TCHAR* vmArgs[])
if (debug) _tprintf( goVMMsg, msg );
if(launchMode == LAUNCH_JNI) {
- exitCode = startJavaVM(jniLib, vmCommandArgs, progCommandArgs, jarFile);
+ javaResults = startJavaVM(jniLib, vmCommandArgs, progCommandArgs, jarFile);
} else {
- exitCode = launchJavaVM(vmCommand);
+ javaResults = launchJavaVM(vmCommand);
}
- switch( exitCode ) {
+ if (javaResults == NULL) {
+ /* shouldn't happen, but just in case */
+ javaResults = malloc(sizeof(JavaResults));
+ javaResults->launchResult = -11;
+ javaResults->runResult = 0;
+ javaResults->errorMessage = _tcsdup(javaFailureMsg);
+ }
+
+ switch( javaResults->launchResult + javaResults->runResult ) {
case 0: /* normal exit */
running = 0;
break;
@@ -553,8 +563,18 @@ JNIEXPORT int run(int argc, _TCHAR* argv[], _TCHAR* vmArgs[])
}
}
if (errorMsg == NULL) {
- errorMsg = malloc( (_tcslen(exitMsg) + _tcslen(msg) + 10) * sizeof(_TCHAR) );
- _stprintf( errorMsg, exitMsg, exitCode, msg );
+ if (javaResults->runResult) {
+ /* java was started ok, but returned non-zero exit code */
+ errorMsg = malloc( (_tcslen(returnCodeMsg) + _tcslen(msg) + 10) *sizeof(_TCHAR));
+ _stprintf(errorMsg, returnCodeMsg,javaResults->runResult, msg);
+ } else if (javaResults->errorMessage != NULL){
+ /* else we had a problem launching java, use custom error message */
+ errorMsg = javaResults->errorMessage;
+ } else {
+ /* no custom message, use generic message */
+ errorMsg = malloc( (_tcslen(exitMsg) + _tcslen(msg) + 10) * sizeof(_TCHAR) );
+ _stprintf( errorMsg, exitMsg, javaResults->launchResult, msg );
+ }
}
if (_tcslen(errorMsg) > 0) {
@@ -575,7 +595,7 @@ JNIEXPORT int run(int argc, _TCHAR* argv[], _TCHAR* vmArgs[])
restartLauncher(NULL, relaunchCommand);
if (launchMode == LAUNCH_JNI)
- cleanupVM(exitCode);
+ cleanupVM(javaResults->launchResult ? javaResults->launchResult : javaResults->runResult);
if (sharedID != NULL) {
destroySharedData( sharedID );
@@ -595,7 +615,13 @@ JNIEXPORT int run(int argc, _TCHAR* argv[], _TCHAR* vmArgs[])
if ( exitData != NULL ) free( exitData );
if ( splashBitmap != NULL ) free( splashBitmap );
- return exitCode;
+ if (javaResults == NULL)
+ return -1;
+
+ /* reuse the running variable for convenience */
+ running = javaResults->launchResult != 0 ? javaResults->launchResult : javaResults->runResult;
+ free(javaResults);
+ return running;
}
static _TCHAR** buildLaunchCommand( _TCHAR* program, _TCHAR** vmArgs, _TCHAR** progArgs ) {
@@ -1120,9 +1146,10 @@ static _TCHAR* findStartupJar(){
return file;
/* old startup.jar? */
- file = checkPath(OLD_STARTUP, programDir, 0);
+ ch = OLD_STARTUP;
+ file = checkPath(ch, programDir, 0);
if (_tstat( file, &stats ) == 0)
- return (file == OLD_STARTUP) ? _tcsdup(OLD_STARTUP) : file;
+ return (file == ch) ? _tcsdup(ch) : file;
return NULL;
}
diff --git a/bundles/org.eclipse.equinox.executable/library/eclipseJNI.c b/bundles/org.eclipse.equinox.executable/library/eclipseJNI.c
index 728abbba1..dc0a94710 100644
--- a/bundles/org.eclipse.equinox.executable/library/eclipseJNI.c
+++ b/bundles/org.eclipse.equinox.executable/library/eclipseJNI.c
@@ -18,6 +18,13 @@
#include <stdlib.h>
#include <string.h>
+
+static _TCHAR* failedToLoadLibrary = _T_ECLIPSE("Failed to load the JNI shared library \"%s\".\n");
+static _TCHAR* createVMSymbolNotFound = _T_ECLIPSE("The JVM shared library \"%s\"\ndoes not contain the JNI_CreateJavaVM symbol.\n");
+static _TCHAR* failedCreateVM = _T_ECLIPSE("Failed to create the Java Virtual Machine.\n");
+static _TCHAR* internalExpectedVMArgs = _T_ECLIPSE("Internal Error, the JVM argument list is empty.\n");
+static _TCHAR* mainClassNotFound = _T_ECLIPSE("Failed to find a Main Class in \"%s\".\n");
+
static JNINativeMethod natives[] = {{"_update_splash", "()V", (void *)&update_splash},
{"_get_splash_handle", "()J", (void *)&get_splash_handle},
{"_set_exit_data", "(Ljava/lang/String;Ljava/lang/String;)V", (void *)&set_exit_data},
@@ -203,7 +210,7 @@ static jstring newJavaString(JNIEnv *env, _TCHAR * str)
size_t length = _tcslen(str);
jbyteArray bytes = (*env)->NewByteArray(env, length);
if(bytes != NULL) {
- (*env)->SetByteArrayRegion(env, bytes, 0, length, str);
+ (*env)->SetByteArrayRegion(env, bytes, 0, length, (jbyte *)str);
if (!(*env)->ExceptionOccurred(env)) {
if (string_class == NULL)
string_class = (*env)->FindClass(env, "java/lang/String");
@@ -259,16 +266,16 @@ static jobjectArray createRunArgs( JNIEnv *env, _TCHAR * args[] ) {
return stringArray;
}
-int startJavaJNI( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[], _TCHAR* jarFile )
+JavaResults * startJavaJNI( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[], _TCHAR* jarFile )
{
int i;
int numVMArgs = -1;
- int jvmExitCode = -1;
void * jniLibrary;
JNI_createJavaVM createJavaVM;
JavaVMInitArgs init_args;
JavaVMOption * options;
char * mainClassName = NULL;
+ JavaResults * results = NULL;
/* JNI reflection */
jclass mainClass = NULL; /* The Main class to load */
@@ -277,14 +284,23 @@ int startJavaJNI( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[], _TCHAR*
jmethodID runMethod = NULL; /* Main.run(String[]) */
jobjectArray methodArgs = NULL; /* Arguments to pass to run */
+ results = malloc(sizeof(JavaResults));
+ memset(results, 0, sizeof(JavaResults));
+
jniLibrary = loadLibrary(libPath);
if(jniLibrary == NULL) {
- return -1; /*error*/
+ results->launchResult = -1;
+ results->errorMessage = malloc((_tcslen(failedToLoadLibrary) + _tcslen(libPath) + 1) * sizeof(_TCHAR));
+ _stprintf(results->errorMessage, failedToLoadLibrary, libPath);
+ return results; /*error*/
}
createJavaVM = (JNI_createJavaVM)findSymbol(jniLibrary, _T_ECLIPSE("JNI_CreateJavaVM"));
if(createJavaVM == NULL) {
- return -1; /*error*/
+ results->launchResult = -2;
+ results->errorMessage = malloc((_tcslen(createVMSymbolNotFound) + _tcslen(libPath) + 1) * sizeof(_TCHAR));
+ _stprintf(results->errorMessage, createVMSymbolNotFound, libPath);
+ return results; /*error*/
}
/* count the vm args */
@@ -292,7 +308,9 @@ int startJavaJNI( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[], _TCHAR*
if(numVMArgs <= 0) {
/*error, we expect at least the required vm arg */
- return -1;
+ results->launchResult = -3;
+ results->errorMessage = _tcsdup(internalExpectedVMArgs);
+ return results;
}
options = malloc(numVMArgs * sizeof(JavaVMOption));
@@ -328,6 +346,7 @@ int startJavaJNI( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[], _TCHAR*
}
if(mainClass != NULL) {
+ results->launchResult = -6; /* this will be reset to 0 below on success */
mainConstructor = (*env)->GetMethodID(env, mainClass, "<init>", "()V");
if(mainConstructor != NULL) {
mainObject = (*env)->NewObject(env, mainClass, mainConstructor);
@@ -336,19 +355,27 @@ int startJavaJNI( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[], _TCHAR*
if(runMethod != NULL) {
methodArgs = createRunArgs(env, progArgs);
if(methodArgs != NULL) {
- jvmExitCode = (*env)->CallIntMethod(env, mainObject, runMethod, methodArgs);
+ results->launchResult = 0;
+ results->runResult = (*env)->CallIntMethod(env, mainObject, runMethod, methodArgs);
(*env)->DeleteLocalRef(env, methodArgs);
}
}
(*env)->DeleteLocalRef(env, mainObject);
}
}
- }
+ } else {
+ results->launchResult = -5;
+ results->errorMessage = malloc((_tcslen(mainClassNotFound) + _tcslen(jarFile) + 1) * sizeof(_TCHAR));
+ _stprintf(results->errorMessage, mainClassNotFound, jarFile);
+ }
if((*env)->ExceptionOccurred(env)){
(*env)->ExceptionDescribe(env);
(*env)->ExceptionClear(env);
}
+ } else {
+ results->launchResult = -4;
+ results->errorMessage = _tcsdup(failedCreateVM);
}
/* toNarrow allocated new strings, free them */
@@ -356,7 +383,7 @@ int startJavaJNI( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[], _TCHAR*
free( options[i].optionString );
}
free(options);
- return jvmExitCode;
+ return results;
}
static char * getMainClass(JNIEnv *env, _TCHAR * jarFile) {
diff --git a/bundles/org.eclipse.equinox.executable/library/eclipseJNI.h b/bundles/org.eclipse.equinox.executable/library/eclipseJNI.h
index 138b55177..3ef4b89dc 100644
--- a/bundles/org.eclipse.equinox.executable/library/eclipseJNI.h
+++ b/bundles/org.eclipse.equinox.executable/library/eclipseJNI.h
@@ -14,6 +14,11 @@
#include "eclipseUnicode.h"
#include <jni.h>
+typedef struct {
+ int launchResult;
+ int runResult;
+ _TCHAR * errorMessage;
+} JavaResults;
typedef jint (JNICALL *JNI_createJavaVM)(JavaVM **pvm, JNIEnv **env, void *args);
@@ -76,7 +81,7 @@ JNIEXPORT void JNICALL takedown_splash(JNIEnv *, jobject);
* be returned to the main launcher, which will display a message if
* the termination was not normal.
*/
-extern int startJavaJNI( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[], _TCHAR* jarFile );
+extern JavaResults* startJavaJNI( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[], _TCHAR* jarFile );
extern void cleanupVM( int );
#endif
diff --git a/bundles/org.eclipse.equinox.executable/library/eclipseNix.c b/bundles/org.eclipse.equinox.executable/library/eclipseNix.c
index acd302e9a..37a08efbd 100644
--- a/bundles/org.eclipse.equinox.executable/library/eclipseNix.c
+++ b/bundles/org.eclipse.equinox.executable/library/eclipseNix.c
@@ -169,7 +169,7 @@ void processVMArgs(_TCHAR **vmargs[] ) {
/* nothing yet */
}
-int startJavaVM( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[], _TCHAR* jarFile )
+JavaResults* startJavaVM( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[], _TCHAR* jarFile )
{
return startJavaJNI(libPath, vmArgs, progArgs, jarFile);
}
diff --git a/bundles/org.eclipse.equinox.executable/library/eclipseOS.h b/bundles/org.eclipse.equinox.executable/library/eclipseOS.h
index a55fec533..5c81dfcb4 100644
--- a/bundles/org.eclipse.equinox.executable/library/eclipseOS.h
+++ b/bundles/org.eclipse.equinox.executable/library/eclipseOS.h
@@ -13,7 +13,7 @@
#ifndef ECLIPSE_OS_H
#define ECLIPSE_OS_H
-#include <jni.h>
+#include "eclipseJNI.h"
#include "eclipseUnicode.h"
#ifdef MACOSX
@@ -101,10 +101,10 @@ extern void takeDownSplash();
extern void restartLauncher( _TCHAR* program, _TCHAR* args[] );
/* launch the vm in a separate process and wait for it to finish */
-extern int launchJavaVM( _TCHAR* args[] );
+extern JavaResults* launchJavaVM( _TCHAR* args[] );
/* launch the vm in this process using JNI invocation */
-extern int startJavaVM( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[], _TCHAR* jarFile );
+extern JavaResults* startJavaVM( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[], _TCHAR* jarFile );
/* do any platform specific processing of the user vmargs */
extern void processVMArgs(_TCHAR **vmargs[] );
diff --git a/bundles/org.eclipse.equinox.executable/library/eclipseShm.c b/bundles/org.eclipse.equinox.executable/library/eclipseShm.c
index 7ed3b8107..9934fe54e 100644
--- a/bundles/org.eclipse.equinox.executable/library/eclipseShm.c
+++ b/bundles/org.eclipse.equinox.executable/library/eclipseShm.c
@@ -13,6 +13,8 @@
#include "eclipseOS.h"
#include "eclipseShm.h"
+static _TCHAR* ECLIPSE_UNITIALIZED = _T_ECLIPSE("ECLIPSE_UNINITIALIZED");
+
#ifdef _WIN32
#include <stdio.h>
@@ -32,6 +34,8 @@ int createSharedData(_TCHAR** id, int size) {
_stprintf(*id, _T_ECLIPSE("%lx_%lx"), GetCurrentProcessId(), (DWORD) mapHandle);
#endif
}
+ /* set the shared data to "uninitialized" */
+ setSharedData(*id, ECLIPSE_UNITIALIZED);
return 0;
}
@@ -75,6 +79,7 @@ int getSharedData(_TCHAR* id, _TCHAR** data) {
if (mapHandle == NULL) return -1;
sharedData = MapViewOfFile(handle, FILE_MAP_WRITE, 0, 0, 0);
if (sharedData == NULL) return -1;
+ if (_tcscmp(sharedData, ECLIPSE_UNITIALIZED)== 0) return 0;
if (data != NULL) {
size_t length = (_tcslen(sharedData) + 1) * sizeof(_TCHAR);
newData = malloc(length);
@@ -208,6 +213,7 @@ int createSharedData(char** id, int size) {
*id = malloc(9 * sizeof(char));
sprintf(*id, "%x", shmid);
}
+ setSharedData(*id, ECLIPSE_UNITIALIZED);
return 0;
}
@@ -233,6 +239,7 @@ int getSharedData( char* id, char** data ) {
if (shmid == -1) return -1;
sharedData = shmat(shmid, (void *)0, 0);
if (sharedData == (char *)(-1)) return -1;
+ if (_tcscmp(sharedData, ECLIPSE_UNITIALIZED) == 0) return 0;
length = strlen(sharedData) + 1;
newData = malloc(length);
memcpy(newData, sharedData, length);
diff --git a/bundles/org.eclipse.equinox.executable/library/gtk/eclipseGtk.c b/bundles/org.eclipse.equinox.executable/library/gtk/eclipseGtk.c
index 343aeb343..003ddd310 100644
--- a/bundles/org.eclipse.equinox.executable/library/gtk/eclipseGtk.c
+++ b/bundles/org.eclipse.equinox.executable/library/gtk/eclipseGtk.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -151,9 +151,9 @@ char** getArgVM( char* vm )
return result;
}
-int launchJavaVM( char* args[] )
+JavaResults* launchJavaVM( char* args[] )
{
- int jvmExitCode = 1;
+ JavaResults* jvmResults = NULL;
pid_t jvmProcess;
int exitCode;
@@ -168,16 +168,21 @@ int launchJavaVM( char* args[] )
execv(args[0], args);
/* The JVM would not start ... return error code to parent process. */
+ /* TODO, how to distinguish this as a launch problem to the other process? */
_exit(errno);
}
+ jvmResults = malloc(sizeof(JavaResults));
+ memset(jvmResults, 0, sizeof(JavaResults));
+
/* If the JVM is still running, wait for it to terminate. */
if (jvmProcess != 0)
{
waitpid(jvmProcess, &exitCode, 0);
if (WIFEXITED(exitCode))
- jvmExitCode = WEXITSTATUS(exitCode);
+ /* TODO, this should really be a runResult if we could distinguish the launch problem above */
+ jvmResults->launchResult = WEXITSTATUS(exitCode);
}
- return jvmExitCode;
+ return jvmResults;
}
diff --git a/bundles/org.eclipse.equinox.executable/library/make_version.mak b/bundles/org.eclipse.equinox.executable/library/make_version.mak
index 004b158c5..e7eb8ed0a 100644
--- a/bundles/org.eclipse.equinox.executable/library/make_version.mak
+++ b/bundles/org.eclipse.equinox.executable/library/make_version.mak
@@ -10,5 +10,5 @@
#*******************************************************************************
maj_ver=1
-min_ver=302
+min_ver=303
LIB_VERSION = $(maj_ver)$(min_ver)
diff --git a/bundles/org.eclipse.equinox.executable/library/motif/eclipseMotif.c b/bundles/org.eclipse.equinox.executable/library/motif/eclipseMotif.c
index 8b32bcbe0..d69fa8a60 100644
--- a/bundles/org.eclipse.equinox.executable/library/motif/eclipseMotif.c
+++ b/bundles/org.eclipse.equinox.executable/library/motif/eclipseMotif.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -274,8 +274,9 @@ void fixEnvForNetscape()
}
#endif /* NETSCAPE_FIX */
-int launchJavaVM( char* args[] )
+JavaResults* launchJavaVM( char* args[] )
{
+ JavaResults* jvmResults = NULL;
int exitCode;
#ifdef NETSCAPE_FIX
@@ -309,17 +310,22 @@ int launchJavaVM( char* args[] )
execv( args[0], args );
/* The JVM would not start ... return error code to parent process. */
+ /* TODO, how to distinguish this as a launch problem to the other process? */
jvmExitCode = errno;
exit( jvmExitCode );
}
+ jvmResults = malloc(sizeof(JavaResults));
+ memset(jvmResults, 0, sizeof(JavaResults));
+
/* If the JVM is still running, wait for it to terminate. */
if (jvmProcess != 0)
{
waitpid(jvmProcess, &exitCode, 0);
- jvmExitCode = ((exitCode & 0x00ff) == 0 ? (exitCode >> 8) : exitCode); /* see wait(2) */
+ /* TODO, this should really be a runResult if we could distinguish the launch problem above */
+ jvmResults->launchResult = ((exitCode & 0x00ff) == 0 ? (exitCode >> 8) : exitCode); /* see wait(2) */
}
/* Return the exit code from the JVM. */
- return jvmExitCode;
+ return jvmResults;
}
diff --git a/bundles/org.eclipse.equinox.executable/library/win32/eclipseWin.c b/bundles/org.eclipse.equinox.executable/library/win32/eclipseWin.c
index 013400f39..1c035ebed 100644
--- a/bundles/org.eclipse.equinox.executable/library/win32/eclipseWin.c
+++ b/bundles/org.eclipse.equinox.executable/library/win32/eclipseWin.c
@@ -40,7 +40,7 @@ static _TCHAR* argVM[] = { NULL };
/* Define local variables for running the JVM and detecting its exit. */
static HANDLE jvmProcess = 0;
-static int jvmExitCode = 0;
+static JavaResults* jvmResults = NULL;
static UINT jvmExitTimeout = 100;
static UINT_PTR jvmExitTimerId = 99;
@@ -372,12 +372,14 @@ void restartLauncher( _TCHAR* program, _TCHAR* args[] )
free(commandLine);
}
-int launchJavaVM( _TCHAR* args[] )
+JavaResults* launchJavaVM( _TCHAR* args[] )
{
MSG msg;
_TCHAR* commandLine;
jvmProcess = 0;
commandLine = buildCommandLine(NULL, args);
+ jvmResults = malloc(sizeof(JavaResults));
+ memset(jvmResults, 0, sizeof(JavaResults));
/*
* Start the Java virtual machine. Use CreateProcess() instead of spawnv()
@@ -391,7 +393,7 @@ int launchJavaVM( _TCHAR* args[] )
CloseHandle( pi.hThread );
jvmProcess = pi.hProcess;
} else {
- jvmExitCode = errno;
+ jvmResults->launchResult = errno;
}
}
@@ -419,7 +421,7 @@ int launchJavaVM( _TCHAR* args[] )
}
/* Return the exit code from the JVM. */
- return jvmExitCode;
+ return jvmResults;
}
/* Detect JVM Process Termination */
@@ -432,7 +434,7 @@ static void CALLBACK detectJvmExit( HWND hwnd, UINT uMsg, UINT id, DWORD dwTime
exitCode != STILL_ACTIVE)
{
/* Save the JVM exit code. This should cause the loop in launchJavaVM() to exit. */
- jvmExitCode = exitCode;
+ jvmResults->runResult = exitCode;
jvmProcess = 0;
}
}
@@ -441,7 +443,7 @@ void processVMArgs(_TCHAR **vmargs[] ) {
/* nothing yet */
}
-int startJavaVM( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[], _TCHAR* jarFile )
+JavaResults* startJavaVM( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[], _TCHAR* jarFile )
{
return startJavaJNI(libPath, vmArgs, progArgs, jarFile);
}
diff --git a/bundles/org.eclipse.equinox.executable/library/wpf/eclipseWpf.cpp b/bundles/org.eclipse.equinox.executable/library/wpf/eclipseWpf.cpp
index 98213ef13..77d431f3b 100644
--- a/bundles/org.eclipse.equinox.executable/library/wpf/eclipseWpf.cpp
+++ b/bundles/org.eclipse.equinox.executable/library/wpf/eclipseWpf.cpp
@@ -46,7 +46,7 @@ static _TCHAR* argVM[] = { NULL };
/* Define local variables for running the JVM and detecting its exit. */
static int jvmProcess = 0;
-static int jvmExitCode = 0;
+static JavaResults* jvmResults = NULL;
static int jvmExitTimeout = 100;
static int jvmExitTimerId = 99;
@@ -430,12 +430,15 @@ void restartLauncher( _TCHAR* program, _TCHAR* args[] )
free(commandLine);
}
-int launchJavaVM( _TCHAR* args[] )
+JavaResults* launchJavaVM( _TCHAR* args[] )
{
MSG msg;
_TCHAR* commandLine;
jvmProcess = -1;
commandLine = buildCommandLine(NULL, args);
+ jvmResults = malloc(sizeof(JavaResults));
+ memset(jvmResults, 0, sizeof(JavaResults));
+
/*
* Start the Java virtual machine. Use CreateProcess() instead of spawnv()
* otherwise the arguments cannot be freed since spawnv() segments fault.
@@ -456,7 +459,7 @@ int launchJavaVM( _TCHAR* args[] )
if (jvmProcess == -1)
{
/* Return the error number. */
- jvmExitCode = errno;
+ jvmResults->launchResult = errno;
jvmProcess = 0;
}
@@ -485,7 +488,7 @@ int launchJavaVM( _TCHAR* args[] )
}
/* Return the exit code from the JVM. */
- return jvmExitCode;
+ return jvmResults;
}
/* Detect JVM Process Termination */
@@ -497,7 +500,7 @@ static void CALLBACK detectJvmExit ()
exitCode != STILL_ACTIVE)
{
/* Save the JVM exit code. This should cause the loop in launchJavaVM() to exit. */
- jvmExitCode = exitCode;
+ jvmResults->runResult = exitCode;
jvmProcess = 0;
}
}
@@ -506,7 +509,7 @@ void processVMArgs(_TCHAR **vmargs[] ) {
// /* nothing yet */
}
-int startJavaVM( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[], _TCHAR* jarFile )
+JavaResults* startJavaVM( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[], _TCHAR* jarFile )
{
return startJavaJNI(libPath, vmArgs, progArgs, jarFile);
}

Back to the top