From bab84f03da6dcd5af6b9263df721e41643533649 Mon Sep 17 00:00:00 2001 From: Karl Nelson Date: Sat, 24 Feb 2024 10:11:30 -0800 Subject: [PATCH 1/2] Change to use wstring for Windows --- native/common/jp_platform.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/native/common/jp_platform.cpp b/native/common/jp_platform.cpp index ea7b0cd4e..005144b21 100644 --- a/native/common/jp_platform.cpp +++ b/native/common/jp_platform.cpp @@ -64,7 +64,13 @@ class Win32PlatformAdapter : public JPPlatformAdapter virtual void loadLibrary(const char* path) override { JP_TRACE_IN("Win32PlatformAdapter::loadLibrary"); - jvmLibrary = LoadLibrary(path); + wchar_t *wpath = Py_DecodeLocale(path, NULL); + if (wpath == NULL) + { + JP_RAISE(PyExc_SystemError, "Unable to get JVM path with locale."); + } + jvmLibrary = LoadLibraryW(wpath); + PyMem_RawFree(wpath); if (jvmLibrary == NULL) { JP_RAISE_OS_ERROR_WINDOWS( GetLastError(), path); From 2c0420edfe1328636e2621f0dd1231a1ea7318d0 Mon Sep 17 00:00:00 2001 From: Karl Nelson Date: Sat, 24 Feb 2024 10:18:10 -0800 Subject: [PATCH 2/2] Fix tabs --- native/common/jp_platform.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/native/common/jp_platform.cpp b/native/common/jp_platform.cpp index 005144b21..1501e1fbf 100644 --- a/native/common/jp_platform.cpp +++ b/native/common/jp_platform.cpp @@ -64,13 +64,13 @@ class Win32PlatformAdapter : public JPPlatformAdapter virtual void loadLibrary(const char* path) override { JP_TRACE_IN("Win32PlatformAdapter::loadLibrary"); - wchar_t *wpath = Py_DecodeLocale(path, NULL); - if (wpath == NULL) - { - JP_RAISE(PyExc_SystemError, "Unable to get JVM path with locale."); - } + wchar_t *wpath = Py_DecodeLocale(path, NULL); + if (wpath == NULL) + { + JP_RAISE(PyExc_SystemError, "Unable to get JVM path with locale."); + } jvmLibrary = LoadLibraryW(wpath); - PyMem_RawFree(wpath); + PyMem_RawFree(wpath); if (jvmLibrary == NULL) { JP_RAISE_OS_ERROR_WINDOWS( GetLastError(), path);