From 3aac18b993d008e0632bd4659dfb61d08683603f Mon Sep 17 00:00:00 2001 From: Markus Stoll Date: Thu, 24 Apr 2014 18:28:58 +0200 Subject: [PATCH] WOStart Java 8 support bugfixes --- Utilities/WOStart/CompileScripts/compile.bat | 13 ++++++ Utilities/WOStart/CompileScripts/make32.sh | 7 +++ Utilities/WOStart/CompileScripts/make64.sh | 7 +++ Utilities/WOStart/CompileScripts/makeclean.sh | 4 ++ Utilities/WOStart/Makefile | 6 +-- Utilities/WOStart/ReadMe.txt | 7 ++- Utilities/WOStart/WOStart.cpp | 43 +++++++++++++++--- Utilities/WOStart/java_md.c | 11 +++-- Utilities/WOStart/{win32/libz.a => libz32.a} | Bin Utilities/WOStart/{win64/libz.a => libz64.a} | Bin Utilities/WOStart/make.config | 13 +++--- 11 files changed, 87 insertions(+), 24 deletions(-) create mode 100644 Utilities/WOStart/CompileScripts/compile.bat create mode 100644 Utilities/WOStart/CompileScripts/make32.sh create mode 100644 Utilities/WOStart/CompileScripts/make64.sh create mode 100644 Utilities/WOStart/CompileScripts/makeclean.sh rename Utilities/WOStart/{win32/libz.a => libz32.a} (100%) rename Utilities/WOStart/{win64/libz.a => libz64.a} (100%) diff --git a/Utilities/WOStart/CompileScripts/compile.bat b/Utilities/WOStart/CompileScripts/compile.bat new file mode 100644 index 00000000000..937300acf94 --- /dev/null +++ b/Utilities/WOStart/CompileScripts/compile.bat @@ -0,0 +1,13 @@ +set OLDDIR=%CD% +cd %~dp0 +cd .. + +c:\MSys\bin\sh --login %~dp0\make32.sh +copy WOStart.exe WOStart.32.exe + +c:\MSys\bin\sh --login %~dp0\make64.sh +copy WOStart.exe WOStart.64.exe + +c:\MSys\bin\sh --login %~dp0\makeclean.sh + +cd %OLDDIR% diff --git a/Utilities/WOStart/CompileScripts/make32.sh b/Utilities/WOStart/CompileScripts/make32.sh new file mode 100644 index 00000000000..f31260eb2fc --- /dev/null +++ b/Utilities/WOStart/CompileScripts/make32.sh @@ -0,0 +1,7 @@ +. /bin/win-builds-switch.sh 32 + +cd `dirname $0` +cd .. + +make clean +make diff --git a/Utilities/WOStart/CompileScripts/make64.sh b/Utilities/WOStart/CompileScripts/make64.sh new file mode 100644 index 00000000000..0644e034689 --- /dev/null +++ b/Utilities/WOStart/CompileScripts/make64.sh @@ -0,0 +1,7 @@ +. /bin/win-builds-switch.sh 64 + +cd `dirname $0` +cd .. + +make clean +make diff --git a/Utilities/WOStart/CompileScripts/makeclean.sh b/Utilities/WOStart/CompileScripts/makeclean.sh new file mode 100644 index 00000000000..cf9d3f3bae7 --- /dev/null +++ b/Utilities/WOStart/CompileScripts/makeclean.sh @@ -0,0 +1,4 @@ +cd `dirname $0` +cd .. + +make clean diff --git a/Utilities/WOStart/Makefile b/Utilities/WOStart/Makefile index dd7ccc3b592..00191601eba 100644 --- a/Utilities/WOStart/Makefile +++ b/Utilities/WOStart/Makefile @@ -1,8 +1,8 @@ include make.config WOStart${EXESUFFIX}: java.o java_md.o manifest_info.o WOStart.o - ${CC} ${CFLAGS} -o ${WINEDITION}/WOStart${EXESUFFIX} *.o ${LIBS} - strip ${WINEDITION}/WOStart${EXESUFFIX} + ${CC} ${CFLAGS} -o WOStart${EXESUFFIX} *.o ${LIBS} + strip WOStart${EXESUFFIX} .c.o: ${CC} ${CFLAGS} -c $< @@ -11,4 +11,4 @@ WOStart${EXESUFFIX}: java.o java_md.o manifest_info.o WOStart.o ${CC} ${CFLAGS} -c $< clean: - rm *.o \ No newline at end of file + rm *.o WOStart.exe \ No newline at end of file diff --git a/Utilities/WOStart/ReadMe.txt b/Utilities/WOStart/ReadMe.txt index faeb582e58f..44bbed76f58 100644 --- a/Utilities/WOStart/ReadMe.txt +++ b/Utilities/WOStart/ReadMe.txt @@ -10,15 +10,14 @@ Using this has some advandages - No problems due to classpath length As with java.exe the current VM is read from registry. For now, this works -up to Java7. +up to Java8. - Compiling -Makefile and make.config are prepared for compiling using Mingw32 and Mingw64 -under windows (for mingw64 you might have to create a symbolic link using -"ln -s x86_64-w64-mingw32-strip.exe strip.exe"). +Makefile and make.config are prepared for compiling using Mingw (32 and 64 Bit) +under windows. To get it compiled with Mingw under Linux you might have to tweak make.config a little bit. diff --git a/Utilities/WOStart/WOStart.cpp b/Utilities/WOStart/WOStart.cpp index 4f7aae9444b..be79c0429c4 100644 --- a/Utilities/WOStart/WOStart.cpp +++ b/Utilities/WOStart/WOStart.cpp @@ -14,7 +14,7 @@ string getNextRoot(); string getNextLocal(); #define APPNAME "WOStart" -#define VERSION "1.0" +#define VERSION "1.1" extern "C" { int Java_Main(int argc, char ** argv, char *javaCommand); @@ -28,10 +28,10 @@ string g_currentDirectory; string g_appRoot; // Path to WebObjects installation -string g_WORoot(getNextRoot()); +string g_WORoot; // Path to WebObjects Local directory -string g_localRoot(getNextLocal()); +string g_localRoot; // Path to Home Root (what does this mean in this context?) string g_homeRoot("C:\\"); @@ -45,6 +45,8 @@ string g_jvmCommand("java"); // JVM options string g_jvmOptions(""); +static bool debugoutput = false; + // Report fatal error and exit // void fatalError(char *message) { @@ -116,6 +118,7 @@ string getNextRoot() { { DWORD bufLen = _MAX_PATH; char buf[_MAX_PATH]; + buf[0] = 0; RegQueryValueEx(hKey, "NEXT_ROOT", NULL, NULL, (LPBYTE) buf, &bufLen); @@ -124,8 +127,12 @@ string getNextRoot() { normalisePath(root); } - if (root.length() > 0) + if (root.length() > 0) { + if (debugoutput) { + cout << "WORoot found in Registry: " << root.c_str() << endl; + } return root; + } // cerr << "Warning: Unable to locate WOROOT/NEXT_ROOT using registry" << endl; @@ -168,6 +175,10 @@ string getNextRoot() { DWORD fattr = GetFileAttributes(root.c_str()); if (fattr != INVALID_FILE_ATTRIBUTES && fattr & FILE_ATTRIBUTE_DIRECTORY) { + if (debugoutput) { + cout << "WORoot found on drive: " << root.c_str() << endl; + } + return root; } @@ -438,6 +449,14 @@ int wostart_main(int argc, TCHAR* argv[]) // tell the world about ourselves; cout << APPNAME << " " << VERSION << endl; + if (getenv("_JAVA_LAUNCHER_DEBUG") != 0) { + debugoutput = true; + } + + g_WORoot = getNextRoot(); + g_localRoot = getNextLocal(); + + // where are we being launched from? g_currentDirectory = getAppDirectory(); @@ -457,9 +476,21 @@ int wostart_main(int argc, TCHAR* argv[]) int js = jargs.size(); char *new_argv[1000]; - cout << "Arguments" << endl; + // + // remove suffixes from command (remove .32.exe, .64.exe, .exe) + // + cout << "Command" << endl; + string command = argv[0]; + size_t found = command.find('.'); + if(found != string::npos) { + string substr = command.substr(0, found); + command.assign(substr); + } - new_argv[0] = argv[0]; + new_argv[0] = (char *)command.c_str(); + cout << " " << new_argv[0] << endl; + + cout << "Arguments" << endl; int ii; for(ii=0; ii < js; ii++) { diff --git a/Utilities/WOStart/java_md.c b/Utilities/WOStart/java_md.c index f4e87d25591..cb17a41b36c 100644 --- a/Utilities/WOStart/java_md.c +++ b/Utilities/WOStart/java_md.c @@ -241,9 +241,10 @@ WinMain(HINSTANCE inst, HINSTANCE previnst, LPSTR cmdline, int cmdshow) * Helpers to look in the registry for a public JRE. */ /* Same for 1.5.0, 1.5.1, 1.5.2 etc. */ -#define DOTRELEASE "1.5" +#define DOTRELEASE5 "1.5" #define DOTRELEASE6 "1.6" #define DOTRELEASE7 "1.7" +#define DOTRELEASE8 "1.8" #define JRE_KEY "Software\\JavaSoft\\Java Runtime Environment" static jboolean @@ -281,11 +282,13 @@ GetPublicJREHome(char *buf, jint bufsize) return JNI_FALSE; } - if (strcmp(version, DOTRELEASE) != 0 && + if (strcmp(version, DOTRELEASE5) != 0 && strcmp(version, DOTRELEASE6) != 0 && - strcmp(version, DOTRELEASE7) != 0) { + strcmp(version, DOTRELEASE7) != 0 && + strcmp(version, DOTRELEASE8) != 0) + { fprintf(stderr, "Registry key '" JRE_KEY "\\CurrentVersion'\nhas " - "value '%s', but '" DOTRELEASE "' or '" DOTRELEASE6 "' or '" DOTRELEASE7 "' is required.\n", version); + "value '%s', but '" DOTRELEASE5 "' upto '" DOTRELEASE8 "' is required.\n", version); RegCloseKey(key); return JNI_FALSE; } diff --git a/Utilities/WOStart/win32/libz.a b/Utilities/WOStart/libz32.a similarity index 100% rename from Utilities/WOStart/win32/libz.a rename to Utilities/WOStart/libz32.a diff --git a/Utilities/WOStart/win64/libz.a b/Utilities/WOStart/libz64.a similarity index 100% rename from Utilities/WOStart/win64/libz.a rename to Utilities/WOStart/libz64.a diff --git a/Utilities/WOStart/make.config b/Utilities/WOStart/make.config index 155d30e074c..31dce7504b3 100644 --- a/Utilities/WOStart/make.config +++ b/Utilities/WOStart/make.config @@ -2,12 +2,11 @@ CC = gcc GCCTARGET = $(shell bash -c '${CC} -dumpmachine') -ifeq "${GCCTARGET}" "mingw32" -WINEDITION = win32 +CFLAGS = -I/C/Program\ Files\ \(x86\)/Java/jdk1.5.0_14/include -I/C/Program\ Files\ \(x86\)/Java/jdk1.5.0_14/include/win32 -L./ +EXESUFFIX = .exe + +ifeq "${GCCTARGET}" "i686-w64-mingw32" +LIBS = -lz32 -lstdc++ -static else -WINEDITION = win64 +LIBS = -lz64 -lstdc++ -static endif - -CFLAGS = -I/C/Program\ Files\ \(x86\)/Java/jdk1.5.0_14/include -I/C/Program\ Files\ \(x86\)/Java/jdk1.5.0_14/include/win32 -L${WINEDITION} -LIBS = -lz -lstdc++ -static -EXESUFFIX = .exe