--- old/modules/jdk.packager/src/main/native/library/common/JavaVirtualMachine.cpp 2016-11-10 23:00:39.000000000 +0300 +++ new/modules/jdk.packager/src/main/native/library/common/JavaVirtualMachine.cpp 2016-11-10 23:00:39.000000000 +0300 @@ -54,7 +54,6 @@ if (javavm.StartJVM() == true) { result = true; - javavm.ShutdownJVM(); } else { Platform& platform = Platform::GetInstance(); @@ -66,10 +65,6 @@ // Private typedef for function pointer casting -#ifndef USE_JLI_LAUNCH -#define LAUNCH_FUNC "JNI_CreateJavaVM" -typedef jint (JNICALL *JVM_CREATE)(JavaVM ** jvm, JNIEnv ** env, void *); -#else #define LAUNCH_FUNC "JLI_Launch" typedef int (JNICALL *JVM_CREATE)(int argc, char ** argv, int jargc, const char** jargv, @@ -82,7 +77,6 @@ jboolean cpwildcard, jboolean javaw, jint ergo); -#endif //USE_JLI_LAUNCH class JavaLibrary : public Library { JVM_CREATE FCreateProc; @@ -94,31 +88,6 @@ FCreateProc = NULL; } -#ifndef USE_JLI_LAUNCH -bool JavaVMCreate(JavaVM** jvm, JNIEnv** env, void* jvmArgs) { - bool result = true; - - if (FCreateProc == NULL) { - FCreateProc = (JVM_CREATE)GetProcAddress(LAUNCH_FUNC); - } - - if (FCreateProc == NULL) { - Platform& platform = Platform::GetInstance(); - Messages& messages = Messages::GetInstance(); - platform.ShowMessage(messages.GetMessage(FAILED_LOCATING_JVM_ENTRY_POINT)); - return false; - } - - if ((*FCreateProc)(jvm, env, jvmArgs) < 0) { - Platform& platform = Platform::GetInstance(); - Messages& messages = Messages::GetInstance(); - platform.ShowMessage(messages.GetMessage(FAILED_CREATING_JVM)); - return false; - } - - return result; - } -#else bool JavaVMCreate(size_t argc, char *argv[]) { if (FCreateProc == NULL) { FCreateProc = (JVM_CREATE)GetProcAddress(LAUNCH_FUNC); @@ -143,41 +112,8 @@ false, 0) == 0; } -#endif //USE_JLI_LAUNCH }; -#ifndef USE_JLI_LAUNCH -//debug hook to print JVM messages into console. -static jint JNICALL vfprintfHook(FILE *fp, const char *format, va_list args) { -#ifdef WINDOWS - char buffer[20480]; - int len; - HANDLE hConsole; - DWORD wasWritten; - - len = _vsnprintf_s(buffer, sizeof(buffer), sizeof(buffer), format, args); - - if (len <= 0) { - return len; - } - - hConsole = GetStdHandle(STD_OUTPUT_HANDLE); - - if (hConsole == INVALID_HANDLE_VALUE) { - return false; - } - - //JVM will always pass us ASCII - WriteConsoleA(hConsole, buffer, strlen(buffer), &wasWritten, NULL); - - return (jint) len; -#endif //WINDOWS -#ifdef LINUX - return 0; -#endif //LINUX -} -#endif //USE_JLI_LAUNCH - //-------------------------------------------------------------------------------------------------- struct JavaOptionItem { @@ -195,16 +131,6 @@ public: JavaOptions() { FOptions = NULL; - -#ifndef USE_JLI_LAUNCH -#ifdef DEBUG - Platform& platform = Platform::GetInstance(); - - if (platform.GetDebugState() == dsNative) { - AppendValue(_T("vfprintf"), _T(""), (void*)vfprintfHook); - } -#endif //DEBUG -#endif //USE_JLI_LAUNCH } ~JavaOptions() { @@ -262,30 +188,6 @@ } } -#ifndef USE_JLI_LAUNCH - JavaVMOption* ToJavaOptions() { - FOptions = new JavaVMOption[FItems.size()]; - memset(FOptions, 0, sizeof(JavaVMOption) * FItems.size()); - Macros& macros = Macros::GetInstance(); - unsigned int index = 0; - - for (std::list::const_iterator iterator = FItems.begin(); - iterator != FItems.end(); iterator++) { - TString key = iterator->name; - TString value = iterator->value; - TString option = Helpers::NameValueToString(key, value); - option = macros.ExpandMacros(option); -#ifdef DEBUG - printf("%s\n", PlatformString(option).c_str()); -#endif //DEBUG - FOptions[index].optionString = PlatformString::duplicate(PlatformString(option).c_str()); - FOptions[index].extraInfo = iterator->extraInfo; - index++; - } - - return FOptions; - } -#else std::list ToList() { std::list result; Macros& macros = Macros::GetInstance(); @@ -301,7 +203,6 @@ return result; } -#endif //USE_JLI_LAUNCH size_t GetCount() { return FItems.size(); @@ -350,10 +251,6 @@ //-------------------------------------------------------------------------------------------------- JavaVirtualMachine::JavaVirtualMachine() { -#ifndef USE_JLI_LAUNCH - FEnv = NULL; - FJvm = NULL; -#endif //USE_JLI_LAUNCH } JavaVirtualMachine::~JavaVirtualMachine(void) { @@ -426,42 +323,6 @@ javaLibrary.Load(package.GetJVMLibraryFileName()); -#ifndef USE_JLI_LAUNCH - options.AppendValue(_T("-Djava.class.path"), classpath); - - if (package.HasSplashScreen() == true) { - options.AppendValue(TString(_T("-splash:")) + package.GetSplashScreenFileName(), _T("")); - } - - // Set up the VM init args - JavaVMInitArgs jvmArgs; - memset(&jvmArgs, 0, sizeof(JavaVMInitArgs)); - jvmArgs.version = JNI_VERSION_1_6; - jvmArgs.options = options.ToJavaOptions(); - jvmArgs.nOptions = (jint)options.GetCount(); - jvmArgs.ignoreUnrecognized = JNI_TRUE; - - if (javaLibrary.JavaVMCreate(&FJvm, &FEnv, &jvmArgs) == true) { - try { - JavaClass mainClass(FEnv, Helpers::ConvertIdToJavaPath(mainClassName)); - JavaStaticMethod mainMethod = mainClass.GetStaticMethod(_T("main"), _T("([Ljava/lang/String;)V")); - std::list appargs = package.GetArgs(); - JavaStringArray largs(FEnv, appargs); - - package.FreeBootFields(); - - mainMethod.CallVoidMethod(1, largs.GetData()); - return true; - } - catch (JavaException& exception) { - platform.ShowMessage(exception.GetMessage()); - return false; - } - } - - return false; -} -#else // Initialize the arguments to JLI_Launch() // // On Mac OS X JLI_Launch spawns a new thread that actually starts the JVM. This @@ -539,28 +400,4 @@ } return false; -} -#endif //USE_JLI_LAUNCH - -void JavaVirtualMachine::ShutdownJVM() { -#ifndef USE_JLI_LAUNCH - if (FJvm != NULL) { - // If application main() exits quickly but application is run on some other thread - // (e.g. Swing app performs invokeLater() in main and exits) - // then if we return execution to tWinMain it will exit. - // This will cause process to exit and application will not actually run. - // - // To avoid this we are trying to detach jvm from current thread (java.exe does the same) - // Because we are doing this on the main JVM thread (i.e. one that was used to create JVM) - // this call will spawn "Destroy Java VM" java thread that will shut JVM once there are - // no non-daemon threads running, and then return control here. - // I.e. this will happen when EDT and other app thread will exit. - if (FJvm->DetachCurrentThread() != JNI_OK) { - Platform& platform = Platform::GetInstance(); - platform.ShowMessage(_T("Detach failed.")); - } - - FJvm->DestroyJavaVM(); - } -#endif //USE_JLI_LAUNCH -} +} \ No newline at end of file --- old/modules/jdk.packager/src/main/native/library/common/JavaVirtualMachine.h 2016-11-10 23:00:40.000000000 +0300 +++ new/modules/jdk.packager/src/main/native/library/common/JavaVirtualMachine.h 2016-11-10 23:00:40.000000000 +0300 @@ -39,32 +39,12 @@ #include "Platform.h" -#ifdef WINDOWS -#define USE_JLI_LAUNCH -#endif //WINDOWS - -#ifdef MAC -#define USE_JLI_LAUNCH -#endif //MAC - -#ifdef LINUX -#define USE_JLI_LAUNCH -#endif //LINUX - - class JavaVirtualMachine { -#ifndef USE_JLI_LAUNCH -private: - JNIEnv* FEnv; - JavaVM* FJvm; -#endif //USE_JLI_LAUNCH - public: JavaVirtualMachine(); ~JavaVirtualMachine(void); bool StartJVM(); - void ShutdownJVM(); }; bool RunVM(); --- old/modules/jdk.packager/src/main/native/library/common/LinuxPlatform.cpp 2016-11-10 23:00:41.000000000 +0300 +++ new/modules/jdk.packager/src/main/native/library/common/LinuxPlatform.cpp 2016-11-10 23:00:41.000000000 +0300 @@ -127,7 +127,6 @@ } TString LinuxPlatform::GetBundledJVMLibraryFileName(TString RuntimePath) { -#ifdef USE_JLI_LAUNCH TString result = FilePath::IncludeTrailingSeparater(RuntimePath) + "lib/"JAVAARCH"/jli/libjli.so"; @@ -135,25 +134,6 @@ result = FilePath::IncludeTrailingSeparater(RuntimePath) + "lib/"JAVAARCH"/jli/libjli.so"; } -#else - TString result = FilePath::IncludeTrailingSeparater(RuntimePath) + - "jre/lib/"JAVAARCH"/client/libjvm.so"; - - if (FilePath::FileExists(result) == false) { - result = FilePath::IncludeTrailingSeparater(RuntimePath) + - "jre/lib/"JAVAARCH"/server/libjvm.so"; - } - - if (FilePath::FileExists(result) == false) { - result = FilePath::IncludeTrailingSeparater(RuntimePath) + - "lib/"JAVAARCH"/server/libjvm.so"; - } - - if (FilePath::FileExists(result) == false) { - result = FilePath::IncludeTrailingSeparater(RuntimePath) + - "lib/"JAVAARCH"/server/libjvm.so"; - } -#endif return result; } --- old/modules/jdk.packager/src/main/native/library/common/Messages.cpp 2016-11-10 23:00:42.000000000 +0300 +++ new/modules/jdk.packager/src/main/native/library/common/Messages.cpp 2016-11-10 23:00:42.000000000 +0300 @@ -44,11 +44,7 @@ FMessages.SetReadOnly(false); FMessages.SetValue(LIBRARY_NOT_FOUND, _T("Failed to find library.")); FMessages.SetValue(FAILED_CREATING_JVM, _T("Failed to create JVM")); -#ifndef USE_JLI_LAUNCH - FMessages.SetValue(FAILED_LOCATING_JVM_ENTRY_POINT, _T("Failed to locate JNI_CreateJavaVM")); -#else FMessages.SetValue(FAILED_LOCATING_JVM_ENTRY_POINT, _T("Failed to locate JLI_Launch")); -#endif FMessages.SetValue(NO_MAIN_CLASS_SPECIFIED, _T("No main class specified")); FMessages.SetValue(METHOD_NOT_FOUND, _T("No method %s in class %s.")); FMessages.SetValue(CLASS_NOT_FOUND, _T("Class %s not found.")); --- old/modules/jdk.packager/src/main/native/library/common/WindowsPlatform.cpp 2016-11-10 23:00:43.000000000 +0300 +++ new/modules/jdk.packager/src/main/native/library/common/WindowsPlatform.cpp 2016-11-10 23:00:43.000000000 +0300 @@ -254,7 +254,6 @@ //} TString WindowsPlatform::GetBundledJVMLibraryFileName(TString RuntimePath) { -#ifdef USE_JLI_LAUNCH TString result = FilePath::IncludeTrailingSeparater(RuntimePath) + _T("jre\\bin\\jli.dll"); @@ -262,25 +261,6 @@ result = FilePath::IncludeTrailingSeparater(RuntimePath) + _T("bin\\jli.dll"); } -#else - TString result = FilePath::IncludeTrailingSeparater(RuntimePath) + - _T("jre\\bin\\client\\jvm.dll"); - - if (FilePath::FileExists(result) == false) { - result = FilePath::IncludeTrailingSeparater(RuntimePath) + - _T("jre\\bin\\server\\jvm.dll"); - } - - if (FilePath::FileExists(result) == false) { - result = FilePath::IncludeTrailingSeparater(RuntimePath) + - _T("bin\\client\\jvm.dll"); - } - - if (FilePath::FileExists(result) == false) { - result = FilePath::IncludeTrailingSeparater(RuntimePath) + - _T("bin\\server\\jvm.dll"); - } -#endif return result; }