Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArun Thondapu2015-01-21 10:23:22 +0000
committerArun Thondapu2015-01-21 10:35:11 +0000
commitb8f0c70aa8d1fa6e158076a29561469f86da2ba5 (patch)
tree94ebbe5e0fbfe06b1755a3b89fcf0d83e7ef9d0c
parent7147f2b90db4a5a8d9d415f549b16ab3ee1bb81b (diff)
downloadrt.equinox.framework-b8f0c70aa8d1fa6e158076a29561469f86da2ba5.tar.gz
rt.equinox.framework-b8f0c70aa8d1fa6e158076a29561469f86da2ba5.tar.xz
rt.equinox.framework-b8f0c70aa8d1fa6e158076a29561469f86da2ba5.zip
Bug 449990 - [1.9] --launcher.XXMaxPermSize should not pass
-XX:MaxPermSize= for Oracle VMs >= 8 Change-Id: Ia48f28d9115b04e4772a6a454c6565c0ad57abbb
-rw-r--r--features/org.eclipse.equinox.executable.feature/library/carbon/eclipseCarbon.c16
-rw-r--r--features/org.eclipse.equinox.executable.feature/library/eclipse.c4
-rw-r--r--features/org.eclipse.equinox.executable.feature/library/eclipseNix.c79
-rw-r--r--features/org.eclipse.equinox.executable.feature/library/eclipseOS.h4
-rw-r--r--features/org.eclipse.equinox.executable.feature/library/win32/eclipseWin.c2
5 files changed, 45 insertions, 60 deletions
diff --git a/features/org.eclipse.equinox.executable.feature/library/carbon/eclipseCarbon.c b/features/org.eclipse.equinox.executable.feature/library/carbon/eclipseCarbon.c
index 0170578b3..500311abb 100644
--- a/features/org.eclipse.equinox.executable.feature/library/carbon/eclipseCarbon.c
+++ b/features/org.eclipse.equinox.executable.feature/library/carbon/eclipseCarbon.c
@@ -45,7 +45,7 @@ char *findCommand(char *command);
char* defaultVM = "java";
char* vmLibrary = "JavaVM";
char* shippedVMDir = "../../../jre/Contents/Home/jre/bin/";
-int isSUN = 0;
+int isSunMaxPermSizeVM = 0;
static void adjustLibraryPath(char * vmLibrary);
static char * findLib(char * command);
@@ -532,11 +532,15 @@ char * getJavaVersion(char* command) {
}
}
if (strstr(buffer, "Java HotSpot(TM)") || strstr(buffer, "OpenJDK")) {
- isSUN = 1;
+ if (version != NULL) {
+ if (version[0] == '1' && ((int)(version[2] - '0') < 8)) {
+ isSunMaxPermSizeVM = 1;
+ }
+ }
break;
}
if (strstr(buffer, "IBM") != NULL) {
- isSUN = 0;
+ isSunMaxPermSizeVM = 0;
break;
}
}
@@ -598,7 +602,7 @@ char * findVMLibrary( char* command ) {
if (strstr(cmd, "/JavaVM.framework/") != NULL && (strstr(cmd, "/Current/") != NULL || strstr(cmd, "/A/") != NULL)) {
cmd = getJavaHome();
}
- // This is necessary to initialize isSUN
+ // This is necessary to initialize isSunMaxPermSizeVM
getJavaVersion(cmd);
result = JAVA_FRAMEWORK;
if (strstr(cmd, "/JavaVM.framework/") == NULL) {
@@ -858,6 +862,6 @@ void processVMArgs(char **vmargs[] )
}
}
-int isSunVM( _TCHAR * javaVM, _TCHAR * jniLib ) {
- return isSUN;
+int isMaxPermSizeVM( _TCHAR * javaVM, _TCHAR * jniLib ) {
+ return isSunMaxPermSizeVM;
}
diff --git a/features/org.eclipse.equinox.executable.feature/library/eclipse.c b/features/org.eclipse.equinox.executable.feature/library/eclipse.c
index 90020dc5f..788fc757e 100644
--- a/features/org.eclipse.equinox.executable.feature/library/eclipse.c
+++ b/features/org.eclipse.equinox.executable.feature/library/eclipse.c
@@ -957,7 +957,7 @@ static void mergeUserVMArgs(_TCHAR **vmArgs[]) {
}
static void adjustVMArgs(_TCHAR *javaVM, _TCHAR *jniLib, _TCHAR **vmArgv[]) {
- /* Sun VMs need some extra perm gen space */
+ /* Sun/Oracle VMs below version 8 need some extra perm gen space */
/* Detecting Sun VM is expensive - only do so if necessary */
if (permGen != NULL) {
int specified = 0, i = -1;
@@ -970,7 +970,7 @@ static void adjustVMArgs(_TCHAR *javaVM, _TCHAR *jniLib, _TCHAR **vmArgv[]) {
}
}
- if (!specified && isSunVM(javaVM, jniLib)) {
+ if (!specified && isMaxPermSizeVM(javaVM, jniLib)) {
_TCHAR ** oldArgs = *vmArgv;
_TCHAR *newArg = malloc((_tcslen(XXPERMGEN) + _tcslen(permGen) + 1) * sizeof(_TCHAR));
_stprintf(newArg, _T_ECLIPSE("%s%s"), XXPERMGEN, permGen);
diff --git a/features/org.eclipse.equinox.executable.feature/library/eclipseNix.c b/features/org.eclipse.equinox.executable.feature/library/eclipseNix.c
index bc57e2250..a4439c752 100644
--- a/features/org.eclipse.equinox.executable.feature/library/eclipseNix.c
+++ b/features/org.eclipse.equinox.executable.feature/library/eclipseNix.c
@@ -174,61 +174,42 @@ JavaResults* startJavaVM( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[],
return startJavaJNI(libPath, vmArgs, progArgs, jarFile);
}
-int isSunVM( _TCHAR * javaVM, _TCHAR * jniLib ) {
- int descriptors[2];
- int result = 0;
- int pid = -1;
-
- if (javaVM == NULL)
+int isMaxPermSizeVM( _TCHAR * javaVM, _TCHAR * jniLib ) {
+ FILE *fp = NULL;
+ _TCHAR buffer[4096];
+ _TCHAR *version = NULL, *firstChar;
+ int numChars = 0, result = 0;
+ _stprintf(buffer,"%s -version 2>&1", javaVM);
+ fp = popen(buffer, "r");
+ if (fp == NULL) {
return 0;
-
- /* create pipe, [0] is read end, [1] is write end */
- if (pipe(descriptors) != 0)
- return 0; /* error */
-
- 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);
+ }
+ while (fgets(buffer, sizeof(buffer)-1, fp) != NULL) {
+ if (!version) {
+ firstChar = (_TCHAR *) (_tcschr(buffer, '"') + 1);
+ if (firstChar != NULL)
+ numChars = (int) (_tcsrchr(buffer, '"') - firstChar);
+
+ /* Allocate a buffer and copy the version string into it. */
+ if (numChars > 0) {
+ version = malloc( numChars + 1 );
+ _tcsncpy(version, firstChar, numChars);
+ version[numChars] = '\0';
+ }
}
- } else if (pid > 0){
- /* parent */
- FILE * stream = NULL;
- int status = 0;
- close(descriptors[1]);
- 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"))) {
+ if (_tcsstr(buffer, "Java HotSpot(TM)") || _tcsstr(buffer, "OpenJDK")) {
+ if (version != NULL) {
+ if (version[0] == '1' && ((int)(version[2] - '0') < 8)) {
result = 1;
- break;
- }
- if (_tcsstr(buffer, _T_ECLIPSE("IBM")) != NULL) {
- result = 0;
- break;
}
}
- fclose(stream);
- close(descriptors[0]);
+ break;
+ }
+ if (_tcsstr(buffer, "IBM") != NULL) {
+ result = 0;
+ break;
}
- waitpid(pid, &status, 0);
- } else {
- /* failed to fork */
- close(descriptors[0]);
- close(descriptors[1]);
}
+ pclose(fp);
return result;
}
diff --git a/features/org.eclipse.equinox.executable.feature/library/eclipseOS.h b/features/org.eclipse.equinox.executable.feature/library/eclipseOS.h
index a0e0902d1..3beca9c71 100644
--- a/features/org.eclipse.equinox.executable.feature/library/eclipseOS.h
+++ b/features/org.eclipse.equinox.executable.feature/library/eclipseOS.h
@@ -109,8 +109,8 @@ extern JavaResults* startJavaVM( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* prog
/* do any platform specific processing of the user vmargs */
extern void processVMArgs(_TCHAR **vmargs[] );
-/* is this a Sun VM, returns 0 if we don't know */
-extern int isSunVM( _TCHAR * javaVM, _TCHAR * jniLib );
+/* is this a Sun/Oracle VM whose version is < 8 (then it needs extra perm gen space), returns 0 if we don't know */
+extern int isMaxPermSizeVM( _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/features/org.eclipse.equinox.executable.feature/library/win32/eclipseWin.c b/features/org.eclipse.equinox.executable.feature/library/win32/eclipseWin.c
index 1e9c1c8e0..e93388257 100644
--- a/features/org.eclipse.equinox.executable.feature/library/win32/eclipseWin.c
+++ b/features/org.eclipse.equinox.executable.feature/library/win32/eclipseWin.c
@@ -577,7 +577,7 @@ JavaResults* startJavaVM( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[],
return startJavaJNI(libPath, vmArgs, progArgs, jarFile);
}
-int isSunVM( _TCHAR * javaVM, _TCHAR * jniLib ) {
+int isMaxPermSizeVM( _TCHAR * javaVM, _TCHAR * jniLib ) {
_TCHAR *vm = (jniLib != NULL) ? jniLib : javaVM;
int result = 0;
DWORD infoSize;

Back to the top