Message13008
| Author |
nfalliere |
| Recipients |
nfalliere |
| Date |
2020年03月05日.23:01:08 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1583449268.58.0.127155011518.issue2866@roundup.psfhosted.org> |
| In-reply-to |
| Content |
Per https://www.jython.org/jython-old-sites/archive/221/archive/22/userguide.html#overloaded-java-method-signatures: "Java methods are allowed to be overloaded for different signatures (types and number of arguments). When different versions of the method differ in the number of arguments that they expect, the appropriate method can be easily determined from the number of arguments passed to the method."
With Jyhon 2.7 (2.7.1, and the current RC of 2.7.2 as well), this works fine for regular class methods, eg:
class A {
void f(int a) {
return a + 1;
}
void f(int a, int b) {
return a+b;
}
}
in Jython:
A().f(4) # will select the proper overload
A().f(1, 2) # will select the proper overload
However, for interfaces:
interface I {
default void f(int a) {
return f(a, 1);
}
void f(int a, int b);
}
class A implements I {
void f(int a, int b) {
return a+b;
}
}
in Jython:
x = someMethodReturningAnObjectImplementingI()
x.f(4) # fail, complains that method should receive 2 args
So it looks like default methods, a language addition of Java 8, may not be seen by the Jython interpreter. Any chance to get that added in a future 2.7.x maintenance release? |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2020年03月05日 23:01:08 | nfalliere | set | recipients:
+ nfalliere |
| 2020年03月05日 23:01:08 | nfalliere | set | messageid: <1583449268.58.0.127155011518.issue2866@roundup.psfhosted.org> |
| 2020年03月05日 23:01:08 | nfalliere | link | issue2866 messages |
| 2020年03月05日 23:01:08 | nfalliere | create |
|