Issue2550
Created on 2017年02月08日.14:21:17 by stefan.richthofer, last changed 2017年02月27日.04:48:58 by zyasoft.
| Messages | |||
|---|---|---|---|
| msg11082 (view) | Author: Stefan Richthofer (stefan.richthofer) | Date: 2017年02月08日.14:21:15 | |
====================================================================== ERROR: test_sort (__main__.JavaListTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/data/workspace/linux/Jython/ssh/jython/dist/Lib/test/list_tests.py", line 442, in test_sort self._test_sort() File "/data/workspace/linux/Jython/ssh/jython/dist/Lib/test/list_tests.py", line 446, in _test_sort u.sort() TypeError: sort(): expected 1 args; got 0 ---------------------------------------------------------------------- I investigated a bit and found that the object in question is of type ArrayList and indeed: Jython 2.7.1b3 (, Feb 8 2017, 02:12:28) [OpenJDK 64-Bit Server VM (Oracle Corporation)] on java1.8.0_121 Type "help", "copyright", "credits" or "license" for more information. >>> from java.util import ArrayList >>> lst = ArrayList([1, 0]) >>> lst.sort() Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: sort(): expected 1 args; got 0 In Java 7 this passes without complain. So what shall this arg be that is suddenly required in Java 8? Let's try: >>> lst.sort(0) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: sort(): 1st arg can't be coerced to java.util.Comparator >>> So, looking into Java 8 ArrayList, etc: Lists have a sort method now and Jython seems to prefer that over the original Jython-style sort method. The Java sort-method however requires a comparator, which can be null to fallback to some default behavior (what is probably what we want). To fix this in a Java version independent fashion I'd suggest to blacklist methods called 'sort' for JavaTypes that implement java.util.List, when going through methods in PyJavaType.init. This should assure that Jython always chooses the right sort-method. Maybe we can alternatively implement an overloading logic for these methods. I'd suggest to add this as an enhancement to this solution later on. |
|||
| msg11083 (view) | Author: Stefan Richthofer (stefan.richthofer) | Date: 2017年02月08日.14:40:32 | |
Okay, after a closer look, solution appears to be much simpler: In JavaProxyList.java simply move listSortProxy from getProxyMethods to getPostProxyMethods. This solves the issue; running regrtests now... |
|||
| msg11084 (view) | Author: Stefan Richthofer (stefan.richthofer) | Date: 2017年02月08日.15:16:07 | |
Fixed as of https://github.com/jythontools/jython/commit/3b27d76fb2e25d00c1b40c2d3ca55c81a8ea8e15. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2017年02月27日 04:48:58 | zyasoft | set | status: pending -> closed |
| 2017年02月08日 15:16:07 | stefan.richthofer | set | status: open -> pending assignee: stefan.richthofer resolution: fixed messages: + msg11084 milestone: Jython 2.7.1 |
| 2017年02月08日 14:40:32 | stefan.richthofer | set | messages: + msg11083 |
| 2017年02月08日 14:21:17 | stefan.richthofer | create | |
Supported by Python Software Foundation,
Powered by Roundup