<div dir="ltr">Hello guys, amber is for new language features. Questions with java compilation or JLS/JVMS belong to the compiler group.<div><br></div><div>That said, I believe this behavior is most likely a preservation of method resolution, that for instance methods, methods from superclass have higher priority than methods from interfaces. For example, before Java 8, static methods could not be defined in interfaces; and when they were added in 8, resolution rule states that they aren't shadowed to child types, so classes cannot "inherit" interface static methods, unlike interface static fields.</div><div><br></div><div>Another fun fact is that superinterface fields take precedence in resolution over superclass fields. Also a legacy from old Java, but I don't think that is going to be changed to make things "consistent".</div><div><br></div><div>Regards,</div><div>Chen Liang</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Sun, Feb 9, 2025 at 4:26 PM Pavel Rappo <<a href="mailto:pavel.rappo@gmail.com">pavel.rappo@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Attila,<br>
<br>
Come to think of it, we should use some other, more narrowly focused,<br>
mailing list. Apologies to subscribers of this list. Since lambda-dev<br>
is defunct now, perhaps we could use compiler-dev, amber-dev, or<br>
core-libs-dev instead. I'm voting for amber-dev, where Brian mostly<br>
resides these days.<br>
<br>
-Pavel<br>
<br>
On Sun, Feb 9, 2025 at 10:12 PM Pavel Rappo <<a href="mailto:pavel.rappo@gmail.com" target="_blank">pavel.rappo@gmail.com</a>> wrote:<br>
><br>
> You are not specifically asking Brian, are you? If so, sorry for replying.<br>
><br>
> My humble take is that the default method is something to use when<br>
> there's nothing else there. When there's something, even if it's<br>
> abstract, we use that. So, a default method is a minimally interfering<br>
> fallback/extension scenario, if you will.<br>
><br>
> That abstract A.m() effectively replaces default F.m() in C as if<br>
> F.m() were never there. If F.m() were allowed to provide<br>
> implementation for A.m() in C, then some uncompliable code could<br>
> suddenly become compilable and operational at runtime.<br>
><br>
> -Pavel.<br>
><br>
> On Sun, Feb 9, 2025 at 9:04 PM Attila Szegedi <<a href="mailto:szegedia@gmail.com" target="_blank">szegedia@gmail.com</a>> wrote:<br>
> ><br>
> > Hey folks,<br>
> ><br>
> > I found a somewhat puzzling behavior: default interface methods aren't considered abstract method implementations. Trying to compile this minimal reproducer:<br>
> ><br>
> > ------ C.java ------<br>
> > abstract class A {<br>
> >Â Â abstract void m();<br>
> > }<br>
> ><br>
> > interface F {<br>
> >Â Â default void m() {}<br>
> > }<br>
> ><br>
> > class C extends A implements F {}<br>
> > ------ C.java ------<br>
> ><br>
> > $ javac C.java<br>
> > C.java:9: error: C is not abstract and does not override abstract method m() in A<br>
> > class C extends A implements F {<br>
> > ^<br>
> > 1 error<br>
> ><br>
> > I can accept this being valid according to JLS today (I tried with 11, 21, and 23.) I admit this is one of rare occasions when I didn't go scouring the JLS to figure out what exactly prevents the compiler from accepting F.m() as implementation of A.m() in C. I'm wondering though if this isn't something that could be improved upon in the future. (I'm sure there's a gotcha somewhere. Right, Brian? ;-) )<br>
> ><br>
> > Have a great day,<br>
> >Â Â Attila.<br>
</blockquote></div>