Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better debugging for Windows DLL JNI booting #740

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions jnius/jnius_jvm_desktop.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ cdef void create_jnienv() except *:
args.nOptions = len(optarr)
args.ignoreUnrecognized = JNI_FALSE

attempted = []
if sys.version_info >= (3, 8):
# uh, let's see if this works and cleanup later
java = get_java_setup('win32')
Expand All @@ -61,15 +62,18 @@ cdef void create_jnienv() except *:
if not os.path.isdir(path):
continue
with os.add_dll_directory(path):
attempted.append(path)
try:
ret = JNI_CreateJavaVM(&jvm, <void **>&_platform_default_env, &args)
except Exception as e:
pass
else:
break
else:
raise Exception("Unable to create jni env, no jvm dll found.")

if len(attempted) > 0:
raise Exception("Unable to create jni env, no jvm dll found in %s" % str(attempted))
else:
raise Exception("Unable to create jni env, no valid java library paths were found in %s, perhaps you need to update JAVA_HOME" % jdk_home)
else:
ret = JNI_CreateJavaVM(&jvm, <void **>&_platform_default_env, &args)

Expand Down
Loading