Skip to content

Commit

Permalink
fixes #1242
Browse files Browse the repository at this point in the history
  • Loading branch information
astrelsky committed Nov 27, 2024
1 parent 29cce31 commit c9355c1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion native/common/jp_platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,21 @@ class Win32PlatformAdapter : public JPPlatformAdapter
{
JP_RAISE(PyExc_SystemError, "Unable to get JVM path with locale.");
}
jvmLibrary = LoadLibraryW(wpath);
wchar_t *tmp = wcsstr(wpath, L"bin\\server\\jvm.dll");
if (tmp == NULL)
{
PyErr_Format(PyExc_ValueError, "Unable to get JVM bin path from %s", path);
JP_RAISE_PYTHON();
}
tmp[3] = L'\0'; // null terminate to temporarily use as directory
// we need to ensure the correct JVM DLLs are loaded
// there may be multiple in the current system PATH
if (!SetDllDirectoryW(wpath))
{
JP_RAISE_OS_ERROR_WINDOWS( GetLastError(), path);
}
tmp[3] = L'\\';
jvmLibrary = LoadLibraryExW(wpath, NULL, LOAD_LIBRARY_SEARCH_USER_DIRS|LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
PyMem_RawFree(wpath);
if (jvmLibrary == NULL)
{
Expand Down

0 comments on commit c9355c1

Please sign in to comment.