Re: Support for interface default methods when selecting an overloaded method

Nicolas Falliere <[email protected]> Thu, 5 Mar 2020 15:03:26 -0800
Newsgroups gmane.comp.lang.jython.devel
Message-ID <CAJP=iOWbW33kJoc1Dz0rLrmNw5Ej8nBC4wW3EHF6Eek0DCx+tQ@mail.gmail.com>
Jeff,

Thanks for your response. I did file a bug here:
https://bugs.jython.org/issue2866
Unfortunately, I'm afraid I don't have any bandwidth to look into the
details of the projects and submit a patch atm :S

*> working on a 3.x*
AWESOME! For some reason, I thought support for 3.0 was a long lost dream,
I'm super excited to read that Python 3 support is in the works!

Best regards,
--
Nicolas Falliere ([email protected])
JEB Decompiler, Founder and Architect
PNF Software <https://www.pnfsoftware.com/> | Follow us on Twitter
<https://twitter.com/jebdec> | Join us on Slack
<https://www.pnfsoftware.com/chat> | Bulletin Board
<https://www.pnfsoftware.com/forum>


On Thu, Mar 5, 2020 at 11:59 AM Jeff Allen <[email protected]> wrote:

> Thanks for trying the RC.
>
> Had it worked, it would have been luck. It has crossed my mind that it
> ought to be a feature, but we haven't attempted to add it. I haven't even
> thought about how default is implemented in Java.
>
> You could raise it as a bug (feature request) on bugs.jython.org. You
> could even submit a patch. (The logic of method resolution is fairly
> complicated.) There will, I think, be a 2.7.3, and if there isn't, it will
> be because we're working on a 3.x. One of them should have this if it can
> be implemented at all.
>
> Jeff Allen
>
> On 05/03/2020 06:30, Nicolas Falliere wrote:
>
> Hello Jython Dev Team,
>
> 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. Is that the case, or am I doing
> something wrong? In the former case, any chance to support that in a coming
> release?
>
> Thank you & Best regards,
> --
> Nicolas Falliere ([email protected])
> JEB Decompiler, Founder and Architect
> PNF Software <https://www.pnfsoftware.com/> | Follow us on Twitter
> <https://twitter.com/jebdec> | Join us on Slack
> <https://www.pnfsoftware.com/chat> | Bulletin Board
> <https://www.pnfsoftware.com/forum>
>
>
> _______________________________________________
> Jython-dev mailing [email protected]://lists.sourceforge.net/lists/listinfo/jython-dev
>
>

_______________________________________________
Jython-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jython-dev