pyjnius icon indicating copy to clipboard operation
pyjnius copied to clipboard

Adding elements in ArrayList messes up with another ArrayList

Open isevastoyanov opened this issue 5 years ago • 0 comments

`

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: array_list_bug

isevastoyanov avatar Jun 04 '19 13:06 isevastoyanov