Issue2115

classification
Title: Callable objects cannot be used as args to Java method params taking single method interfaces
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: zyasoft Nosy List: zyasoft
Priority: low Keywords:

Created on 2014-02-21.17:29:41 by zyasoft, last changed 2014-09-24.00:11:25 by zyasoft.

Messages
msg8242 (view) Author: Jim Baker (zyasoft) Date: 2014-02-21.17:29:40
As seen in the socket-reboot project, it's necessary to wrap calls to bound methods with a function so that it can be directly used by single method interfaces, eg:

        def workaround_jython_bug_for_bound_methods(_):
            self._notify_selectors()

        future.addListener(workaround_jython_bug_for_bound_methods)

The likely solution is to add a PyMethod#__java__, taking in account being bound or not, comparable to PyFunction#__java__.
msg8539 (view) Author: Jim Baker (zyasoft) Date: 2014-05-22.01:24:46
Target beta 4
msg9018 (view) Author: Jim Baker (zyasoft) Date: 2014-09-24.00:02:27
Bound methods are supported as of https://hg.python.org/jython/rev/0e4c6e7d2273

Per my commit message:
Note that any callable object should have this behavior, since there
is no possibility of ambiguity; however, this change did not add such
support for __call__ since it seems to be a bit more complex in how it
interacts with class derivation. But a test, currently skipped, as
been added for such future support.
History
Date User Action Args
2014-09-24 00:11:25zyasoftsettitle: Not all callables cannot be used for single method interface callbacks -> Callable objects cannot be used as args to Java method params taking single method interfaces
2014-09-24 00:02:34zyasoftsetpriority: normal -> low
2014-09-24 00:02:28zyasoftsetmessages: + msg9018
title: Bound methods cannot be used for single method interface callbacks -> Not all callables cannot be used for single method interface callbacks
2014-05-22 01:24:46zyasoftsetmessages: + msg8539
2014-02-21 17:29:41zyasoftcreate