-
Notifications
You must be signed in to change notification settings - Fork 256
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
varargs and autoboxing causes segfault #509
Comments
Here's the top of the stack according to the JVM dump:
This may imply that the call succeeded (release_args) is called in the finally block (https://github.com/kivy/pyjnius/blob/master/jnius/jnius_export_class.pxi#L786) Why is the jarray converted back to Python? in case it has been updated? Segfault must be at or the following line. Line 210 in 8380ee8
|
also hitting this :/ |
This is still there with v1.3.0. An easy and environment agnostic set of steps to reproduce : docker run -it --rm agileops/centos-javapython:latest bash
pip3 install pyjnius==1.3.0
python3 And then run the following script from jnius import autoclass
Arrays = autoclass('java.util.Arrays')
l = Arrays.asList(1, 2, 5) Gives a nice core dump.
Solution? |
A few notes for anyone who is trying this code under JPype. JPype does handle this case though autoboxing without a casting operator, but may not be what you desire. The output of this autoconversion will be of type Number by contract as it has to refer to Python objects with a Python type int. Currently, the best match for this is java.lang.Long. In future releases, the exact type can be different (for example it may wish to use PyLong) as we try to better to actually store Python objects on Java objects rather than risk truncation.
In general if you want a specific type of boxing casting first is needed
Note that in JPype varargs can auto unpack lists. The reason this works is that varargs in Java is implemented as Object[] so a Python list is checked to see if it can be unpacked to Object[]. If the elements all have defined Java conversions then the list unpacks into the varargs without error.
|
Arrays.asList() uses varargs and a generic type
The text was updated successfully, but these errors were encountered: