IDEA-210117 DLL are not properly searched from user applications working directories

IDEA-209990 Run/Debug: a JVMTI agent specified with -agentlib VM option cannot load from working directory

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

GitOrigin-RevId: 01e2f78a3ae3840e18e6e86954a2520ea8d87c0a
This commit is contained in:
Vladimir.Orlov
2019-04-28 17:01:16 +03:00
committed by intellij-monorepo-bot
parent e647ea1b7e
commit fdec4a9cd6
3 changed files with 9 additions and 3 deletions
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2018 JetBrains s.r.o.
* Copyright 2000-2019 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -565,6 +565,9 @@ bool LoadVMOptions()
vmOptionLines.push_back(std::string("-Djb.vmOptionsFile=") + EncodeWideACP(used));
if (!AddClassPathOptions(vmOptionLines)) return false;
std::string dllName(jvmPath);
std::string binDir = dllName + "\\bin";
vmOptionLines.push_back(std::string("-Djava.library.path=") + binDir);
AddPredefinedVMOptions(vmOptionLines);
vmOptionCount = vmOptionLines.size();
@@ -582,6 +585,7 @@ 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,13 +597,15 @@ bool LoadJVMLibrary()
dllName = clientDllName;
}
// 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());
// 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());
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 ";