-
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
Unable to create a Map<str, byte[]>
#550
Comments
The problem here is this:
When pyjnius is converting the python variables to Java it uses the method signature to decide how to do the conversion before making the actual Java method call. In Java you would write something like I looked through the code and I don't see a way to fix this without breaking other stuff. Is it possible for you to use a work-around like this?
Alternatively, you could try not using |
@hx2A could another kwarg be used to force the type conversion? |
@cmacdonald a kwarg could be used to do that but the HashMap object would still be Also note that in my simple example code above,
A kwarg that had the same effect as |
the generics is just compiler decoration; the hashmap will store whatever object we give it in JNI. My understanding is this is some of the array conversion mapping that Jnius does. I'm not sure if it is in the way in or out. Way to test would be to put in Python and then read the object classname from Java (with generics turned off) |
In jnius_conversion.pxi there is the function
What we would want instead is for it to use the
It would do this if we could force the I'm still not convinced this will solve @AbdealiJK 's problem though. If they create a |
AIUI, at bytecode level: Map<String,byte[]> map
byte[] arr = map.get("a"); is compiled to something equivalent to: Map map;
byte[] arr = (byte[]) map.get("a"); Hence
I believe yes |
Interesting. I did some testing and I believe you are correct. So perhaps all we need to do is make the kwarg you suggested? |
I have rediscovered this bug. It seems impossible for a PythonJavaClass to return byte[] and for Java to recognise it as such. I worked around it by having my Python method populate and return a ByteBuffer. |
I am using a java library which expects me to send a
Map<str, byte[]>
.I am unable to create
Map<str, byte[]>
in java. This I what have tried:I seem to be unable to create a
Map<str, byte[]>
right now and I am not sure how to do it ...I am using:
The text was updated successfully, but these errors were encountered: