8306854: javac with '-source 7' should honor default methods in implemented Java 8 interfaces

Alex Buckley alex.buckley at oracle.com
Tue Apr 25 19:23:36 UTC 2023

To put my earlier mail in concrete terms:

On 4/25/2023 8:33 AM, Volker Simonis wrote:
> Instead of relying on the *global* `-source` setting, I think
> `firstUnimplementedAbstractImpl()` should rather rely on the class
> file version of the corresponing class (i.e. `B` in this case) and if
> that class file version is >= 8, it should consider its default method
> implementations. I even think that the check for `allowDefaultMethods`
> could be completely removed, because if the class dependency `B`
> wasn't compiled before, it will be compiled from source and fail for
> `-source 7` because it contains a default method. If on the other
> hand, the class dependency `B` was already compiled to a class file
> with `-source 8` it is OK to use it's default method.

It's not OK to consider, use, or interpret a default method in B.class 
(version >= Java 8) when compiling C.java with `-source 7`.

Arguably, javac with `-source 7` shouldn't even read class files whose 
version is > Java 7. Such class files will contain artifacts that have 
no meaning to a program written in the Java language specified by JLS7.


More information about the compiler-dev mailing list