Issue2639

classification
Title: equal (==) /not equal (!=) is not working with Java.util.list when compared to [] it always return true
Type: Severity: normal
Components: Core Versions: Jython 2.7
Milestone:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Amjad, jamesmudd
Priority: Keywords:

Created on 2017-10-31.10:15:20 by Amjad, last changed 2017-11-08.11:04:21 by Amjad.

Messages
msg11642 (view) Author: James Mudd (jamesmudd) Date: 2017-11-01.21:26:58
This does look like a bug to me. To reproduce:

Jython 2.7.1 (, Oct 2 2017, 18:35:43) 
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java9
Type "help", "copyright", "credits" or "license" for more information.
>>> from java.util import ArrayList
>>> al = ArrayList()
>>> al == []
True
>>> al != []
True   <<<<<<<<<<<<<<< I think this is wrong
>>> al.add(3)
True
>>> al == []
False
>>> al != []
True
msg11651 (view) Author: James Mudd (jamesmudd) Date: 2017-11-07.23:36:46
This doesn't only effect empty list != on a Java list with Python list will currently return True, where == also returns True e.g.
    >>> from java.util import ArrayList       
    >>> al1 = ArrayList([1,2,3])
    >>> al1 == [1,2,3]
    True   <================= Correct
    >>> al1 != [1,2,3]
    True   <================= This is wrong!

I have looked into this one a bit and it seems like the issue is evaluating __ne__ for Java lists. I have a test case and a fix on a branch here https://github.com/jamesmudd/jython/tree/2639 but it might not be the best solution.

I would like to investigate a little more though as currently JavaProxyList didn't implement __ne__ which I though should be ok as it should be logically equivalent to not(__eq__) however that wasn't the code path followed (when evaluating !=) so maybe this points to a different underlying problem. If anyone has looked at this area before feel free to comment with hints.
msg11654 (view) Author: Amjad (Amjad) Date: 2017-11-08.11:04:21
The issue is also happens with java map when comparing to {}!
History
Date User Action Args
2017-11-08 11:04:21Amjadsetmessages: + msg11654
2017-11-07 23:36:47jamesmuddsetmessages: + msg11651
2017-11-01 21:26:58jamesmuddsetnosy: + jamesmudd
messages: + msg11642
components: + Core
versions: + Jython 2.7
2017-10-31 10:15:20Amjadcreate