Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Niefer2008-05-09 14:38:41 -0400
committerAndrew Niefer2008-05-09 14:38:41 -0400
commit55a3f945a9c7e0d833077809decd80f847d18b34 (patch)
tree46add1cb86d95d7f806622051c5728161619a958 /bundles
parenta1a45001f0fb860fe1f2a914c30c83e7ef8b1261 (diff)
downloadrt.equinox.framework-55a3f945a9c7e0d833077809decd80f847d18b34.tar.gz
rt.equinox.framework-55a3f945a9c7e0d833077809decd80f847d18b34.tar.xz
rt.equinox.framework-55a3f945a9c7e0d833077809decd80f847d18b34.zip
bug 195897 - identify sun vms on linux with java -version
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbon.c3
-rw-r--r--bundles/org.eclipse.equinox.executable/library/eclipse.c6
-rw-r--r--bundles/org.eclipse.equinox.executable/library/eclipseNix.c53
-rw-r--r--bundles/org.eclipse.equinox.executable/library/eclipseOS.h2
-rw-r--r--bundles/org.eclipse.equinox.executable/library/win32/eclipseWin.c3
-rw-r--r--bundles/org.eclipse.equinox.executable/library/wpf/eclipseWpf.cpp3
6 files changed, 60 insertions, 10 deletions
diff --git a/bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbon.c b/bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbon.c
index 2118707d6..2661761af 100644
--- a/bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbon.c
+++ b/bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbon.c
@@ -443,6 +443,7 @@ void processVMArgs(char **vmargs[] )
}
}
-int isSunVM( _TCHAR * vm ) {
+int isSunVM( _TCHAR * javaVM, _TCHAR * jniLib ) {
+ _TCHAR *vm = (jniLib != NULL) ? jniLib : javaVM;
return (strncmp(vm, JAVA_FRAMEWORK, strlen(JAVA_FRAMEWORK)) == 0);
}
diff --git a/bundles/org.eclipse.equinox.executable/library/eclipse.c b/bundles/org.eclipse.equinox.executable/library/eclipse.c
index 4fee3877f..5710aacd9 100644
--- a/bundles/org.eclipse.equinox.executable/library/eclipse.c
+++ b/bundles/org.eclipse.equinox.executable/library/eclipse.c
@@ -694,9 +694,9 @@ static _TCHAR** parseArgList( _TCHAR* data ) {
return execArg;
}
-static void adjustVMArgs( _TCHAR *vm, _TCHAR **vmArgv[] ) {
+static void adjustVMArgs( _TCHAR *javaVM, _TCHAR *jniLib, _TCHAR **vmArgv[] ) {
/* Sun VMs need some extra perm gen space */
- if (isSunVM(vm) && permGen != NULL) {
+ if (permGen != NULL && isSunVM(javaVM, jniLib)) {
int specified = 0, i = -1;
/* first check to see if it is already specified */
@@ -744,7 +744,7 @@ static void getVMCommand( int launchMode, int argc, _TCHAR* argv[], _TCHAR **vmA
/* If the user specified "-vmargs", add them instead of the default VM args. */
vmArg = (userVMarg != NULL) ? userVMarg : getArgVM( (launchMode == LAUNCH_JNI) ? jniLib : javaVM );
- adjustVMArgs((launchMode == LAUNCH_JNI) ? jniLib : javaVM, &vmArg);
+ adjustVMArgs(javaVM, jniLib, &vmArg);
/* Calculate the number of VM arguments. */
while (vmArg[ nVMarg ] != NULL)
diff --git a/bundles/org.eclipse.equinox.executable/library/eclipseNix.c b/bundles/org.eclipse.equinox.executable/library/eclipseNix.c
index 6a725ed66..cdbc29699 100644
--- a/bundles/org.eclipse.equinox.executable/library/eclipseNix.c
+++ b/bundles/org.eclipse.equinox.executable/library/eclipseNix.c
@@ -173,7 +173,54 @@ int startJavaVM( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[], _TCHAR*
return startJavaJNI(libPath, vmArgs, progArgs, jarFile);
}
-int isSunVM( _TCHAR * vm ) {
- /* don't know how to decide on this platform */
- return 0;
+int isSunVM( _TCHAR * javaVM, _TCHAR * jniLib ) {
+ if (javaVM == NULL)
+ return 0;
+
+ int descriptors[2];
+ int result = 0;
+ /* create pipe, [0] is read end, [1] is write end */
+ if (pipe(descriptors) != 0)
+ return 0; /* error */
+
+ int pid = fork();
+ if (pid == 0 ) {
+ /* child, connect stdout & stderr to write end of the pipe*/
+ dup2(descriptors[1], STDERR_FILENO);
+ dup2(descriptors[1], STDOUT_FILENO);
+
+ /* close descriptors */
+ close(descriptors[0]);
+ close(descriptors[1]);
+
+ /* exec java -version */
+ _TCHAR *args [] = { javaVM, _T_ECLIPSE("-version"), NULL };
+ execv(args[0], args);
+ /* if we make it here, there was a problem with exec, just exit */
+ exit(0);
+ } else if (pid > 0){
+ /* parent */
+ close(descriptors[1]);
+ FILE * stream = fdopen( descriptors[0], "r");
+ if (stream != NULL) {
+ _TCHAR buffer[256];
+ while ( fgets(buffer, 256, stream) != NULL) {
+ if (_tcsstr(buffer, _T_ECLIPSE("Java HotSpot(TM)")) || _tcsstr(buffer, _T_ECLIPSE("OpenJDK"))) {
+ result = 1;
+ break;
+ }
+ if (_tcsstr(buffer, _T_ECLIPSE("IBM")) != NULL) {
+ result = 0;
+ break;
+ }
+ }
+ fclose(stream);
+ close(descriptors[0]);
+ }
+ } else {
+ /* failed to fork */
+ close(descriptors[0]);
+ close(descriptors[1]);
+ }
+ return result;
}
diff --git a/bundles/org.eclipse.equinox.executable/library/eclipseOS.h b/bundles/org.eclipse.equinox.executable/library/eclipseOS.h
index f64fae4a3..2cb9ff457 100644
--- a/bundles/org.eclipse.equinox.executable/library/eclipseOS.h
+++ b/bundles/org.eclipse.equinox.executable/library/eclipseOS.h
@@ -131,7 +131,7 @@ extern int startJavaVM( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[], _
extern void processVMArgs(_TCHAR **vmargs[] );
/* is this a Sun VM, returns 0 if we don't know */
-extern int isSunVM( _TCHAR * vm );
+extern int isSunVM( _TCHAR * javaVM, _TCHAR * jniLib );
/* an array of paths that will need to be on the search path to load the vm shared library */
extern _TCHAR ** getVMLibrarySearchPath(_TCHAR * vmLibrary);
diff --git a/bundles/org.eclipse.equinox.executable/library/win32/eclipseWin.c b/bundles/org.eclipse.equinox.executable/library/win32/eclipseWin.c
index 52b36b503..40bd96d9c 100644
--- a/bundles/org.eclipse.equinox.executable/library/win32/eclipseWin.c
+++ b/bundles/org.eclipse.equinox.executable/library/win32/eclipseWin.c
@@ -445,7 +445,8 @@ int startJavaVM( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[], _TCHAR*
return startJavaJNI(libPath, vmArgs, progArgs, jarFile);
}
-int isSunVM( _TCHAR * vm ) {
+int isSunVM( _TCHAR * javaVM, _TCHAR * jniLib ) {
+ _TCHAR *vm = (jniLib != NULL) ? jniLib : javaVM;
int result = 0;
DWORD infoSize;
DWORD handle;
diff --git a/bundles/org.eclipse.equinox.executable/library/wpf/eclipseWpf.cpp b/bundles/org.eclipse.equinox.executable/library/wpf/eclipseWpf.cpp
index 6dfee896d..2dc940d13 100644
--- a/bundles/org.eclipse.equinox.executable/library/wpf/eclipseWpf.cpp
+++ b/bundles/org.eclipse.equinox.executable/library/wpf/eclipseWpf.cpp
@@ -510,7 +510,8 @@ int startJavaVM( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[], _TCHAR*
return startJavaJNI(libPath, vmArgs, progArgs, jarFile);
}
-int isSunVM( _TCHAR * vm ) {
+int isSunVM( _TCHAR * javaVM, _TCHAR * jniLib ) {
+ _TCHAR *vm = (jniLib != NULL) ? jniLib : javaVM;
int result = 0;
DWORD infoSize;
DWORD handle;

Back to the top