diff --git a/jnius/jnius_conversion.pxi b/jnius/jnius_conversion.pxi index 6ac3d8c..8fe596c 100644 --- a/jnius/jnius_conversion.pxi +++ b/jnius/jnius_conversion.pxi @@ -145,8 +145,15 @@ cdef convert_jobject_to_python(JNIEnv *j_env, bytes definition, jobject j_object return convert_jarray_to_python(j_env, r[1:], j_object) if r not in jclass_register: - from reflect import autoclass - ret_jc = autoclass(r.replace('/', '.'))(noinstance=True) + if r.startswith('$Proxy'): + # only for $Proxy on android, don't use autoclass. The dalvik vm is + # not able to give us introspection on that one (FindClass return + # NULL). + from .reflect import Object + ret_jc = Object(noinstance=True) + else: + from reflect import autoclass + ret_jc = autoclass(r.replace('/', '.'))(noinstance=True) else: ret_jc = jclass_register[r](noinstance=True) ret_jc.instanciate_from(create_local_ref(j_env, j_object)) @@ -339,7 +346,7 @@ cdef jobject convert_python_to_jobject(JNIEnv *j_env, definition, obj) except *: elif definition == 'I': retclass = j_env[0].FindClass(j_env, 'java/lang/Integer') retmidinit = j_env[0].GetMethodID(j_env, retclass, '', '(I)V') - j_ret[0].i = obj + j_ret[0].i = int(obj) elif definition == 'J': retclass = j_env[0].FindClass(j_env, 'java/lang/Long') retmidinit = j_env[0].GetMethodID(j_env, retclass, '', '(J)V') diff --git a/jnius/jnius_jvm_desktop.pxi b/jnius/jnius_jvm_desktop.pxi index b8aed0e..58258bc 100644 --- a/jnius/jnius_jvm_desktop.pxi +++ b/jnius/jnius_jvm_desktop.pxi @@ -27,7 +27,7 @@ def classpath(): else: split_char = ':' - paths = [realpath('.'), join(dirname(__file__), 'src', 'org'), ] + paths = [realpath('.'), join(dirname(__file__), 'src'), ] if 'CLASSPATH' not in environ: return split_char.join(paths) diff --git a/jnius/jnius_proxy.pxi b/jnius/jnius_proxy.pxi index 2669e04..f4cd1da 100644 --- a/jnius/jnius_proxy.pxi +++ b/jnius/jnius_proxy.pxi @@ -61,18 +61,18 @@ cdef class PythonJavaClass(object): py_method = self.__javamethods__.get(key, None) if not py_method: - print(''.join( + print(''.join([ '\n===== Python/java method missing ======', - '\nPython class:', self, + '\nPython class:', repr(self), '\nJava method name:', method_name, '\nSignature: ({}){}'.format(''.join(args_signature), ret_signature), - '\n=======================================\n')) + '\n=======================================\n'])) raise NotImplemented('The method {} is not implemented'.format(key)) return py_method(*args) cdef jobject invoke0(JNIEnv *j_env, jobject j_this, jobject j_proxy, jobject - j_method, jobjectArray args) except *: + j_method, jobjectArray args) with gil: from .reflect import get_signature, Method # get the python object @@ -142,7 +142,7 @@ cdef jobject invoke0(JNIEnv *j_env, jobject j_this, jobject j_proxy, jobject cdef create_proxy_instance(JNIEnv *j_env, py_obj, j_interfaces): from .reflect import autoclass Proxy = autoclass('java.lang.reflect.Proxy') - NativeInvocationHandler = autoclass('jnius.NativeInvocationHandler') + NativeInvocationHandler = autoclass('org.jnius.NativeInvocationHandler') ClassLoader = autoclass('java.lang.ClassLoader') # convert strings to Class @@ -156,7 +156,9 @@ cdef create_proxy_instance(JNIEnv *j_env, py_obj, j_interfaces): j_env[0].RegisterNatives(j_env, nih.j_cls, invoke_methods, 1) # create the proxy and pass it the invocation handler + classLoader = ClassLoader.getSystemClassLoader() + cdef JavaClass j_obj = Proxy.newProxyInstance( - ClassLoader.getSystemClassLoader(), j_interfaces, nih) + classLoader, j_interfaces, nih) return j_obj diff --git a/jnius/src/org/jnius/NativeInvocationHandler.java b/jnius/src/org/jnius/NativeInvocationHandler.java index c50383a..ed5ba66 100644 --- a/jnius/src/org/jnius/NativeInvocationHandler.java +++ b/jnius/src/org/jnius/NativeInvocationHandler.java @@ -1,4 +1,4 @@ -package jnius; +package org.jnius; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method;