Issue1558

classification
Title: PyFunction to single method interface wrapping does not handle java.lang.Object methods
Type: behaviour Severity: normal
Components: Core Versions: 2.5b1
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: MrMeanie, fwierzbicki, nriley, thobes, zyasoft
Priority: Keywords: patch

Created on 2010-02-17.20:47:10 by MrMeanie, last changed 2010-07-20.05:20:31 by zyasoft.

Files
File name Uploaded Description Edit Remove
Jython_r6980_PyFunction_tojava_patch_20100217_v1.patch nriley, 2010-02-18.02:13:37
Messages
msg5540 (view) Author: Geoffrey French (MrMeanie) Date: 2010-02-17.20:47:08
A Python function can be passed as a parameter to a Java method, where the corresponding argument is a single method interface. This is accomplished by having PyFunction.__tojava__ perform the conversion/wrapping.
While the resulting wrapped PyFunction works properly when the interface method is invoked, it malfunctions if the Java code attempts to access a method those defined in java.lang.Object, hashCode() or toString() for example.
I believe others have run into this difficulty.

I believe others have discovered that this can block the use of method specifically coded to accept PyFunctions or PyObjects - for example, given the two java methods:

void myMethod(PyFunction x);
void myMethod(SingleMethodInterface x);

The PyFunction.__tojava__() modification would result in the second method being chosen over the first, despite the fact that the first may be desirable.


Many Thanks.

Regards

Geoffrey French
msg5541 (view) Author: Nicholas Riley (nriley) Date: 2010-02-18.02:13:36
Attaching patch as permissions are currently broken.
msg5910 (view) Author: Jim Baker (zyasoft) Date: 2010-07-20.05:20:30
Tobias fixed this earlier, in r6982. As of r7081, added a simple test to verify that object methods like toString can be passed functions.
History
Date User Action Args
2010-07-20 05:20:31zyasoftsetstatus: open -> closed
resolution: fixed
messages: + msg5910
2010-04-26 01:27:48zyasoftsetnosy: + zyasoft
2010-04-11 02:13:15pjenveysetnosy: + thobes
2010-02-18 15:32:29fwierzbickisetnosy: + fwierzbicki
2010-02-18 02:13:38nrileysetfiles: + Jython_r6980_PyFunction_tojava_patch_20100217_v1.patch
keywords: + patch
messages: + msg5541
nosy: + nriley
2010-02-17 20:47:10MrMeaniecreate