--- old/src/jdk.incubator.jpackage/share/native/applauncher/JvmLauncher.cpp 2020-08-13 14:32:57.956540700 -0400 +++ new/src/jdk.incubator.jpackage/share/native/applauncher/JvmLauncher.cpp 2020-08-13 14:32:56.802519800 -0400 @@ -66,8 +66,7 @@ if (splash != appOptions.end()) { const tstring splashPath = CfgFile::asString(*splash); if (FileUtils::isFileExists(splashPath)) { - addArgument(_T("-splash")); - addArgument(splashPath); + addArgument(_T("-splash:") + splashPath); } else { LOG_WARNING(tstrings::any() << "Splash property ignored. File \"" @@ -138,6 +137,23 @@ } +bool Jvm::isWithSplash() const { + tstring_array::const_iterator it = args.begin(); + const tstring_array::const_iterator end = args.end(); + for (; it != end; ++it) { + if (tstrings::startsWith(*it, _T("-splash:"))) { + return true; + } + } + return false; +} + + +bool Jvm::isClientJvm() const { + return std::find(args.begin(), args.end(), _T("-client")) != args.end(); +} + + namespace { void convertArgs(const std::vector& args, std::vector& argv) { argv.reserve(args.size() + 1); --- old/src/jdk.incubator.jpackage/share/native/applauncher/JvmLauncher.h 2020-08-13 14:33:07.440004300 -0400 +++ new/src/jdk.incubator.jpackage/share/native/applauncher/JvmLauncher.h 2020-08-13 14:33:06.275342300 -0400 @@ -50,6 +50,10 @@ return jvmPath; } + bool isWithSplash() const; + + bool isClientJvm() const; + void launch(); private: --- 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();