Skip to content

Commit

Permalink
fix up new dlopen code.
Browse files Browse the repository at this point in the history
  • Loading branch information
benson-basis committed May 3, 2015
1 parent af670f4 commit 6570581
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions jnius/jnius_jvm_dlopen.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ cdef void create_jnienv() except *:
if JAVA_HOME is None or JAVA_HOME == '':
raise SystemError("JAVA_HOME is not set.")

lib_path = os.path.join(JAVA_HOME, JNIUS_LIB_SUFFIX)
lib_path = str_for_c(os.path.join(JAVA_HOME, JNIUS_LIB_SUFFIX))

cdef void *handle = dlopen(lib_path, RTLD_NOW | RTLD_GLOBAL)
if handle == NULL:
raise SystemError("Error calling dlopen({0}: {1}".format(lib_path, dlerror()))

cdef void *jniCreateJVM = dlsym(handle, "JNI_CreateJavaVM")
cdef void *jniCreateJVM = dlsym(handle, b"JNI_CreateJavaVM")

if jniCreateJVM == NULL:
raise SystemError("Error calling dlfcn for JNI_CreateJavaVM: {0}".format(dlerror()))
Expand All @@ -65,7 +65,8 @@ cdef void create_jnienv() except *:

options = <JavaVMOption*>malloc(sizeof(JavaVMOption) * len(optarr))
for i, opt in enumerate(optarr):
options[i].optionString = <bytes>(opt)
optbytes = str_for_c(opt)
options[i].optionString = <bytes>(optbytes)
options[i].extraInfo = NULL

args.version = JNI_VERSION_1_6
Expand Down

0 comments on commit 6570581

Please sign in to comment.