IDEA-207158 IDEA 2019.1 with Java 11: cannot install on Win 10 from scratch

The trick with SetCurrentDirectory back and forth doesn't work because the missing dll can be requested asynchrounously (on loading awt.dll). So we can just add the right dir to the dll serach path instead.
This commit is contained in:
Anton Tarasov
2019-02-15 23:20:46 +03:00
parent 10904acc8b
commit 2c2476d547
@@ -581,7 +581,6 @@ bool LoadJVMLibrary()
{
std::string dllName(jvmPath);
std::string binDir = dllName + "\\bin";
TCHAR currentDir[MAX_PATH];
std::string serverDllName = binDir + "\\server\\jvm.dll";
std::string clientDllName = binDir + "\\client\\jvm.dll";
if ((bServerJVM && FileExists(serverDllName)) || !FileExists(clientDllName))
@@ -593,15 +592,13 @@ bool LoadJVMLibrary()
dllName = clientDllName;
}
// ensure we can find msvcr100.dll which is located in jre/bin directory; jvm.dll depends on it.
GetCurrentDirectory(sizeof(currentDir),currentDir);
SetCurrentDirectoryA(binDir.c_str());
// ensure we can find msvcr<ver>.dll which is located in jre/bin directory; jvm.dll (awt.dll) depends on it.
SetDllDirectoryA(binDir.c_str());
hJVM = LoadLibraryA(dllName.c_str());
if (hJVM)
{
pCreateJavaVM = (JNI_createJavaVM) GetProcAddress(hJVM, "JNI_CreateJavaVM");
}
SetCurrentDirectory(currentDir);
if (!pCreateJavaVM)
{
std::string jvmError = "Failed to load JVM DLL ";