Commit Graph

202 Commits

Author SHA1 Message Date
Akshay Arora 81aabc58e9 Update __init__.py 2016-10-27 11:42:14 +05:30
Akshay Arora b5a1ecb7ec Detach only on android 2016-10-26 20:42:55 +05:30
Akshay Arora 9838660626 call detach on all threads before exiting 2016-10-26 20:34:01 +05:30
espes 27a4a85ac5 check for exceptions in find_javaclass 2016-08-29 13:47:37 -07:00
espes 57efacb311 fix longs 2016-08-29 13:43:32 -07:00
Mathieu Virbel ddcaa432e5 fix python3 issue for decoding str (it might come from an updated Cython.). Closes #218 2016-04-18 20:28:13 +02:00
Mathieu Virbel 57c8461053 remove const_char, as Cython supports const from 0.18 2016-04-05 14:47:00 +02:00
akshayaurora 9565b7de85 charSequence: remove repeated code. 2016-03-17 04:34:02 +05:30
akshayaurora 6fc9107231 call toString forCharSequence 2016-03-16 14:56:18 +05:30
Mathieu Virbel 6a7421df72 remove debug from a previous commit/pr. Closes #190 2015-12-11 17:06:49 +01:00
Mathieu Virbel ac2324d96e fixes bytearray tests again (python3) 2015-12-10 14:14:48 +01:00
Mathieu Virbel c5863be424 bytearray: fix bytes -128-127 from java to 0-255 python 2015-12-10 13:11:25 +01:00
Mathieu Virbel f11f88e2df Merge branch 'master' of github.com:kivy/pyjnius
Conflicts:
	jnius/jnius_conversion.pxi
2015-12-10 00:56:06 +01:00
Mathieu Virbel 5bb7e6cfdb supports bytearray as argument for byte[]. Useful for socket/bluetooth reading (no need to read one by one) 2015-12-10 00:55:08 +01:00
bob c2cb331f41 compilation error fixed 2015-11-09 14:08:57 +02:00
Benson Margulies 209e57ed0d eliminate use of 'future' outside of tests, try to fix p2/p3 issues with setup. 2015-11-04 07:33:15 -05:00
Benson Margulies 3968f3af17 Merge branch 'master' of github.com:kivy/pyjnius into python-34
Conflicts:
	.travis.yml
	Makefile
	setup.py
	tests/test_proxy.py
2015-11-03 07:51:45 -05:00
dessant fc77dd624d Merge pull request #133 from chrisjrn/signatures
API for human-readable method signatures
2015-11-03 14:00:35 +02:00
dessant 5b4378ac85 Merge pull request #163 from benson-basis/fix-build-tests
Fix build tests
2015-11-03 13:57:59 +02:00
Akshay Arora 4adf0aa725 Merge pull request #153 from retsyo/patch-2
Another missing PR
2015-10-07 11:46:57 +05:30
Mathieu Virbel 2627d95227 Fixes multiples memory leak in exception analysis, find_javaclass, and class instanciations 2015-07-26 14:29:51 +02:00
gabriel pettier ae359e054d allow setting java fields of object type
using convert_python_to_jobject
2015-07-21 16:36:42 +02:00
Benson Margulies 953fab9bd8 fix up new dlopen code. 2015-05-03 11:24:32 -04:00
Benson Margulies fa9f4531c0 Use dlopen instead of linking -ljvn. 2015-05-03 11:24:32 -04:00
Benson Margulies e1070965cc Support Python 3.4
see if we can't make travis happy.
2015-05-03 11:24:27 -04:00
Benson Margulies cca4da3cb0 Some sauce to map Java Beans to python properties and lists. 2015-05-03 11:23:47 -04:00
Benson Margulies 2753c59573 Make lists work like Python list containers. 2015-04-30 16:24:27 -04:00
Benson Margulies 0c86904ede Support to map getters to properties. 2015-04-30 16:13:16 -04:00
Benson Margulies 6d91a2fe62 Fix 159: passing the result of autoclass to java.lang.Class parameter. 2015-04-30 14:17:28 -04:00
Mathieu Virbel a54772835c Merge pull request #152 from tonyfinn/patch-1
Re-applies #138
2015-03-13 15:11:57 +01:00
Mathieu Virbel 6208c609eb Merge pull request #150 from msmolens/set-fields
Enable setting primitive data type fields on Java classes
2015-03-12 16:22:45 +01:00
Mathieu Virbel 9425a2cc31 Merge pull request #115 from Lenbok/issue-96-exception-handling
Issue 96 improved exception handling
2015-03-12 16:20:17 +01:00
Mathieu Virbel ce3572ba79 fixes hashCode overflow. (disclamer: i wont talk about collision probabiliity or whatever. In my point of view, it seems very low, as the id() is based on the address of the object, it except if you uses tons of memory, you wont get it. And whatever the changes are, this will never keep up safe from colliding with others java object.). Closes #146 2015-03-02 11:22:05 +01:00
Mathieu Virbel a0c9467d42 add native support for CharSequence. We supported String, but not the baseclass CharSequence. Both returns a python string, and a python string can be assigned to both. 2015-03-02 10:59:34 +01:00
Max Smolens 18d506911e Enable setting primitive data type fields on Java classes 2015-02-25 22:59:28 -05:00
Mathieu Virbel 857e4c762a add a jnius.detach() method to detach a thread that used some jni.
This cannot be automatic as jnius do not control the thread creation, so it cannot add a callabck to autocall this method.
It must be added by the user before the thread leave, if it used pyjnius inside.

Ref #107
Ref #97
2015-02-07 19:33:19 +01:00
retsyo 15664625ac Update jnius_conversion.pxi
change chr(<char>j_chars[i]) to unichr(j_chars[i]), now it can deal with Chinese
2015-01-29 19:47:26 +08:00
Ryan Pessa 4839674fdd use temporary var to handle unsigned char -> jbyte (signed char) 2015-01-27 10:28:14 -06:00
Tony Finn f0b8ce3856 Fix JVM signatures for the java.lang.Class method.
The methods defined in the Class class contain semicolons at the end of the signatures for methods which return primitives, while these are only required after class names. As a result, a JVM error occurs when attempting to call any of the affected methods.
2015-01-03 18:56:50 +00:00
Mathieu Virbel 5fb4667c18 detect the implementation issue on IsAssignableFrom, and go the other way around for ART. Also dont try to use ExceptionDescribe if there is no Exception throw, or we will get a bad bad native crash. Closes #92 2014-11-13 09:43:11 +01:00
Mathieu Virbel bb3cd4f376 Merge pull request #110 from abrasive/jvmoptions
Add control of JVM startup options
2014-09-30 20:01:09 +02:00
Christopher Neugebauer 4948cc0e8e (oops) 2014-09-17 17:51:56 +10:00
Christopher Neugebauer 422b5b122c Improves the help rendering for signatures.py 2014-09-17 17:50:31 +10:00
Christopher Neugebauer c222e479fa Documents signatures.py better 2014-09-17 17:45:07 +10:00
Christopher Neugebauer 7a17a9cc3d Renames “java_signature” to “with_signature”; adds “signature” method to public API 2014-09-17 17:30:37 +10:00
Christopher Neugebauer 176dc70919 First pass at a nicer signatures API with tests 2014-09-16 20:17:13 +10:00
Mathieu Virbel 9f9d61618f fixes for Cython 0.21. Closes #131 2014-09-16 10:08:32 +02:00
Akshay Arora b38a365fda Merge pull request #111 from abrasive/multidim
Add support for multidimensional arrays
2014-09-15 01:02:50 +05:30
Mathieu Virbel f5b555d3d2 Add specific case for Android/libART: it crash if we check NativeInvocationHandler/InvocationHandler with isAssignableFrom. Plus, include some defaults methods implementation of java.lang.Object (hashCode, toString, equals), which is used by ART. Closes #92. Closes #113. 2014-07-31 13:49:25 +02:00
Mathieu Virbel a45ba1737e fix issue with "cannot allocate an array of constant size 0" on Windows / MSVC compiler 2014-05-22 17:54:51 +02:00
Lenbok d93c911d9e Add improved exception handling:
- Disable calling ExceptionDescribe, as this pollutes stderr, making it harder
to implement clean exception handling. JNI documentation describes it as being for
debugging purposes.

- Extract separate fields for the exception class name, exception message, and
exception stack trace, and add these as attributes to JavaException. Calling
code can now decide for itself whether and how to present this information.
2014-05-19 10:22:36 +12:00
Len Trigg 6328de8142 Incorporate patch from #96 and a unit test 2014-05-16 12:12:12 +12:00
James Laird 2910e2fddc Add control of JVM startup options 2014-05-09 18:20:29 +10:00
James Laird 0279d2e870 Add support for multidimensional arrays 2014-05-05 17:29:33 +10:00
Mathieu Virbel d5d2926190 raise an exception if the signature have invalid character + fix pyjnius documentation about array declaration in signature 2014-01-21 09:48:48 +01:00
Len Boyette f88f3ed170 Compile in Windows successfully
Fixed jvm.lib reference
2013-11-25 22:41:12 -05:00
Mathieu Virbel 9d7c90135b Merge pull request #72 from limodou/patch-1
Fix string format error in 2.6
2013-10-25 07:14:49 -07:00
Mathieu Virbel 6ea6173346 Merge pull request #78 from zielmicha/master
Fix field dereference when multiple instances of a class exist. Fixes #77
2013-10-25 07:14:29 -07:00
Mathieu Virbel 5fc9e58b4c fix a leak when calling constructor with string arguments 2013-10-16 11:52:14 +02:00
Michał Zieliński 51889323a3 Fix field dereference when multiple instances of a class exist. Fixes #77 2013-09-16 22:04:56 +02:00
Mathieu Virbel 693275fe48 new ByteArray native class, used to transport [B in python, instead of using Python list + integer.
ByteArray have .tostring() + .tolist(), and support slices / item lookup / size, but everything is readonly.
2013-09-11 17:18:49 +02:00
Mathieu Virbel af824144cc fixes for convert_jobject_to_python to correctly handle [B as parameters, as well as "Ljava/lang/Object;" that can be converted into "[Ljava/lang/String;" 2013-09-10 11:05:13 +02:00
Mathieu Virbel 9a18e94aa9 proxy: add "except *" to correctly propagate the python exception in invoke0, and let traceback print it. (python exception doesn't go through java... ^^).
+ avoid double-referencing in proxy. Before, we was having weird issue without it, but i'm not able to trigger it right now. Do the clean way.
2013-09-10 11:03:55 +02:00
limodou a92308975b Fix string format error in 2.6
In 2.6, you should give index value to format.
2013-08-29 16:14:06 +08:00
Mathieu Virbel 04c8ced2a7 Merge branch 'master' of github.com:kivy/pyjnius 2013-08-17 19:14:04 +02:00
Mathieu Virbel 8541c489ff make sure that GetObjectArrayElement are freed. 2013-08-17 19:13:49 +02:00
Max Shabalihin d226263174 fix NotImplemented not found 2013-08-12 17:26:44 +04:00
Mathieu Virbel 54097ccacb dont overload the type, or later if will failed as well. 2013-08-06 16:24:19 +02:00
Michał Zieliński 35c410e542 fix lookup_java_object_name local reference leak 2013-08-02 14:14:50 +02:00
Michał Zieliński d6a3d1cf5f Delete local reference after constructing class 2013-08-01 22:38:27 +02:00
Michał Zieliński 2df76cb7f6 Check for exception after calling constructor 2013-08-01 21:25:20 +02:00
Mathieu Virbel 481b3e5d30 basic support for output args. works only in the original type allow slice assignment. We gently ignore TypeError if the assignation didnt work. closes #58 2013-07-02 09:43:39 +02:00
Mathieu Virbel 5ff62b146e last fixes to make pyjnius Java-thread proof. If you call any jnius related from a C thread, it will leak and/or crash (this hasnt been tested). 2013-06-25 11:49:42 +02:00
Mathieu Virbel 21d365df24 XXX avoid to switch between thread when invoke0 is called / new push_jnienv/pop_jnienv. Without it, if another thread use pyjnius = crash. (i have explored TLS storage for storing j_env, but it seems not available on Android. 2013-06-25 00:08:24 +02:00
Mathieu Virbel 3db9a76ed8 class: fix thread issues when using a class between thread (j_cls MUST be a global ref to work.) 2013-06-24 22:07:31 +02:00
Mathieu Virbel 8349037dd3 jnius: fix push/pop jnienv in order to avoid GIL going on using the previous thread env while we are still on the current thread 2013-06-24 18:36:58 +02:00
Mathieu Virbel 5bf97da477 jnius: refactor to not save jni env, and use the current pushed/pop env. This resolve few issues when pyjnius is called from a proxy (error such as E/dalvikvm( 6036): JNI ERROR: env->self != thread-self (0x68415860 vs. 0x400bb010); auto-correcting) 2013-06-24 17:58:20 +02:00
Mathieu Virbel 2c5a14dae2 fix encoding issues in test_implementation.py 2013-06-24 09:36:31 +02:00
Mathieu Virbel 5ec6d80ba3 accept python string as a valid argument for [B and [C 2013-06-24 09:21:40 +02:00
Mathieu Virbel 3fe55c1bb2 Allow to pass None for array (example: String[] can be null.) 2013-06-23 15:46:25 +02:00
Mathieu Virbel ded2378679 Add __javacontext__ for proxy class, which can be either "system" or "app". Default goes to system if non existent.
Also check the exception before trying to convert the returned value, as i've experienced, sometimes the value returned is not NULL, but is not valid at all, cause an exception happen.
2013-04-28 19:15:25 +02:00
Mathieu Virbel 1844de341e add a better repr for LocalRef class (ie, indicate the source reference we came from.) 2013-04-28 19:14:14 +02:00
Mathieu Virbel 4cf0b865b9 cython 0.19 fixes, jlong was interpreted as a number, not as a pointer value anymore. 2013-04-28 19:13:23 +02:00
Mathieu Virbel abc36192c3 fix tests 2013-03-24 18:49:31 -05:00
Mathieu Virbel 242245a6f4 proxy: force GIL on invoke0, and add a special case for $Proxy name (android failed to FindClass) 2013-03-24 18:45:33 -05:00
Mathieu Virbel 2a95adc674 cleanup proxy code 2013-03-13 21:38:10 +01:00
Mathieu Virbel a1c18107d3 add DEBUG boolean in the java class 2013-03-13 19:12:53 +01:00
Mathieu Virbel 717c0166cf reduce code 2013-03-13 19:12:40 +01:00
Mathieu Virbel 46555de7b2 implement void return 2013-03-13 19:12:33 +01:00
Mathieu Virbel 0686d6b54b ident java 2013-03-13 18:53:39 +01:00
Mathieu Virbel ac94b7c815 fix crash in Java, it look like changing CreateLocalRef to CreateGlobalRef works, and retain correctly some references needed for the invocation. But i'm not entirely sure about the implication. 2013-03-13 18:53:25 +01:00
tshirtman 7068b37d69 fix classpath for windows and CLASSPATH definition 2013-01-03 13:12:40 +01:00
tshirtman e10ed056bb move testImpl to tests/test_proxy.py and move NativeInvocationHandler
adapt jnius_jvm_desktop to have access to java jnius package
2013-01-03 12:57:46 +01:00
tshirtman be312974f3 fix issue with int/long not being accepted as Object in conversion
not sure it's the best fix, but seems to fix it
2013-01-03 01:45:52 +01:00
tshirtman 208806f635 add support for multiple signatures, add various tests 2013-01-03 01:19:49 +01:00
Mathieu Virbel a2d0076e56 added convert_python_to_jobject: don't do convert to java primitive/jvalue, but jobject. fixed array translation. 2013-01-02 18:11:12 +01:00
Mathieu Virbel 143ab371b6 more work on the proxy, better argument conversion. shuffle() works on array <= 3. with 9 argument, it seem to call toArray(), and argument conversion is not great for [I 2013-01-02 13:57:08 +01:00
Mathieu Virbel 8915e9d558 debug 2013-01-02 12:18:44 +01:00
Mathieu Virbel 9838ac9282 fix for always returning an Object from invoke(). If it's a native primitive, create the corresponding native java.lang.<type>.
The current conversion is only for: int (java.lang.Long), bool (java.lang.Boolean), float (java.lang.Double).
+ remove debug
2013-01-02 12:18:30 +01:00
Mathieu Virbel f12abcbc88 add auto conversion for java.lang.Long/Integer/Float/Double/Short/Boolean/Byte/Character 2013-01-02 12:16:51 +01:00