--- old/src/jdk.incubator.jpackage/windows/native/applauncher/WinLauncher.cpp 2020-08-13 14:33:16.111118000 -0400 +++ new/src/jdk.incubator.jpackage/windows/native/applauncher/WinLauncher.cpp 2020-08-13 14:33:14.974905500 -0400 @@ -100,6 +100,56 @@ return std::unique_ptr(new Dll(dllFullPath)); } + +class DllWrapper { +public: + DllWrapper(const tstring& dllName) { + try { + // Try load DLL. + dll = std::unique_ptr(new Dll(dllName)); + LOG_TRACE(tstrings::any() << "Load [" << dllName << "]: OK"); + } + catch (const std::exception&) { + // JVM DLL load failed, though it exists in file system. + try { + // Try adjust the DLL search paths with AddDllDirectory() WINAPI CALL + dll = loadDllWithAddDllDirectory(dllName); + } + catch (const std::exception&) { + // AddDllDirectory() didn't work. Try altering PATH environment + // variable as the last resort. + dll = loadDllWithAlteredPATH(dllName); + } + } + } + +private: + DllWrapper(const DllWrapper&); + DllWrapper& operator=(const DllWrapper&); + +private: + std::unique_ptr dll; +}; + + +tstring getJvmLibPath(const Jvm& jvm, bool isClientJvm) { + FileUtils::mkpath path; + path << FileUtils::dirname(jvm.getPath()); + if (isClientJvm) { + path << _T("client"); + } else { + path << _T("server"); + } + path << _T("jvm.dll"); + + if (isClientJvm && !FileUtils::isFileExists(path)) { + return getJvmLibPath(jvm, false); + } + + return path; +} + + void launchApp() { // [RT-31061] otherwise UI can be left in back of other windows. ::AllowSetForegroundWindow(ASFW_ANY); @@ -115,20 +165,14 @@ << _T("runtime")) .createJvmLauncher()); - std::unique_ptr jvmDll; - try { - // Try load JVM DLL. - jvmDll = std::unique_ptr(new Dll(jvm->getPath())); - } catch (const std::exception&) { - // JVM DLL load failed, though it exists in file system. - try { - // Try adjust the DLL search paths with AddDllDirectory() WINAPI CALL - jvmDll = loadDllWithAddDllDirectory(jvm->getPath()); - } catch (const std::exception&) { - // AddDllDirectory() didn't work. Try altering PATH environment - // variable as the last resort. - jvmDll = loadDllWithAlteredPATH(jvm->getPath()); - } + const DllWrapper jliDll(jvm->getPath()); + std::unique_ptr splashDll; + if (jvm->isWithSplash()) { + const DllWrapper jvmDll(getJvmLibPath(*jvm, jvm->isClientJvm())); + splashDll = std::unique_ptr(new DllWrapper( + FileUtils::mkpath() + << FileUtils::dirname(jvm->getPath()) + << _T("splashscreen.dll"))); } jvm->launch();