Open
Description
Steps to Reproduce
- Native android aar's method
private ConcurrentHashMap<byte[], Object> map = new ConcurrentHashMap();
Object getData(byte[] key) {
return map.get(key);
}
void putData(byte[] data) {
map.put(data, data);
}
- Xamarin android invoker method generated by binding generator
void GetData(byte[] p0) {
...
IntPtr native_p0 = JNIEnv.NewArray (p0);
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_p0);
JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_getData_arrayB, __args);
...
}
void PutData(byte[] p0) {
...
IntPtr native_p0 = JNIEnv.NewArray (p0);
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_p0);
JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_putData_arrayB, __args);
...
}
- When we use this Xamarin binded lib in code, it returns null always as follows.
byte[] data=new byte[]{1,2,3};
someObj.PutData(data);
var ans = someObj.GetData(data); // always returns null
Here, we know why someObj.GetData(data)
returns null always.
It is because GetData(p0)
doesn't use p0
itself as a key to get corresponding value, but it generates new address by IntPtr native_p0 = JNIEnv.NewArray (p0)
and use it as a key.
So the Map variable couldn't find a proper key/value stored by the key (byte array pointer address) generated newly each time in calling someObj.GetData(data)
.
Hope you to fix this issue ASAP.
It should NOT return null in above code, and it SHOULD return byte[]{1,2,3} as corresponding value.