< prev index next >

src/jdk.incubator.jpackage/windows/native/applauncher/WinLauncher.cpp

Print this page

        

*** 98,107 **** --- 98,157 ---- }); return std::unique_ptr<Dll>(new Dll(dllFullPath)); } + + class DllWrapper { + public: + DllWrapper(const tstring& dllName) { + try { + // Try load DLL. + dll = std::unique_ptr<Dll>(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> 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); const tstring launcherPath = SysInfo::getProcessModulePath();
*** 113,136 **** .setAppDir(FileUtils::mkpath() << appImageRoot << _T("app")) .setDefaultRuntimePath(FileUtils::mkpath() << appImageRoot << _T("runtime")) .createJvmLauncher()); ! std::unique_ptr<Dll> jvmDll; ! try { ! // Try load JVM DLL. ! jvmDll = std::unique_ptr<Dll>(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()); ! } } jvm->launch(); } --- 163,180 ---- .setAppDir(FileUtils::mkpath() << appImageRoot << _T("app")) .setDefaultRuntimePath(FileUtils::mkpath() << appImageRoot << _T("runtime")) .createJvmLauncher()); ! const DllWrapper jliDll(jvm->getPath()); ! std::unique_ptr<DllWrapper> splashDll; ! if (jvm->isWithSplash()) { ! const DllWrapper jvmDll(getJvmLibPath(*jvm, jvm->isClientJvm())); ! splashDll = std::unique_ptr<DllWrapper>(new DllWrapper( ! FileUtils::mkpath() ! << FileUtils::dirname(jvm->getPath()) ! << _T("splashscreen.dll"))); } jvm->launch(); }
< prev index next >