Issue2752

classification
Title: Allow Python functions to be used as a java.lang.FunctionalInterface
Type: rfe Severity: normal
Components: Versions: Jython 2.7.3
Milestone:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: jamesmudd
Priority: normal Keywords:

Created on 2019-03-27.20:14:11 by jamesmudd, last changed 2019-03-27.20:14:11 by jamesmudd.

Files
File name Uploaded Description Edit Remove
predicateExample.py jamesmudd, 2019-03-27.20:14:11
Messages
msg12406 (view) Author: James Mudd (jamesmudd) Date: 2019-03-27.20:14:11
It would be nice in Java 8 onward if Python functions could be used where functional interfaces specified by lambdas (or method refs) can be used in Java.

Examples would be in streams e.g.

    filtered_list = al.stream().filter(moreThanThree).collect(toList())

See attached example for full code.

This fails at them moment because although Predicate is a @FunctionalInterface it also declares default methods. which results in it not being coerced in PyFunction.__tojava__(Class<?>)

Probably for after 2.7.1 it might be easier to implement when default methods can be introspected via reflection.
History
Date User Action Args
2019-03-27 20:14:11jamesmuddcreate