pyjnius
pyjnius copied to clipboard
Adding elements in ArrayList messes up with another ArrayList
`
from java.types import ArrayList # this is just a Java ArrayList, it's just wrapped in another Py file.
elements = [1, 2, 3, 4]
def put_elements_in_another_list(elements_list):
list_internal = ArrayList()
for element in elements_list:
list_internal.add(element)
return list_internal
mutations = ArrayList()
mutations.add(tuple(put_elements_in_another_list(elements)))
print(mutations.size())
`
This is the code snippet. You would expect the printed value to be 1 but it is 0. Pyjnius version is 1.2.0.
If you move tuple(put_elements_in_another_list(elements)) into a variable, everything will be fine.
Here is the debug info in the add method in Java ArrayList: