Defaut methods are not visible if -source 1.7 is set

Remi Forax forax at
Tue Oct 29 10:26:27 PDT 2013

This is from enhanced-metadata-spec-discuss mailing list
but I think this issue can interest this audience because it seems
that javac doesn't respect the spec we have drafted or the spec has 
changed without me noticing it.
Anyway there is a discrepancy somewhere.

 From Joe Darcy:

>> Wouldn't this risk the same issues as when we turned 
>> isAnnotationPresent() into a default?
> No; we don't have the same hazard here as with isAnnotationPresent. 
> The issue we ran into with making isAnnotationPresent a default method 
> was that isAnnotationPresent was part of the original AnnotatedElement 
> interface defined way back in Java SE 5. In implementation decision in 
> javac did not expose the existence of default methods to code being 
> compiled under source levels less than 8. That is a pragmatic choice 
> and usually gives the desired result, but not in this case.

So it seems that javac 8 doesn't see default methods if source level is 
1.7 (-source 1.7)
and as Joe notice this hamper to transform any existing abstract method 
to a default method.

I'm pretty sure that we have talked about that and said that adding 
default to a method should be
source compatible when we have discussed about Iterator.remove.
Otherwise it goes against the intuition that providing a body to an 
existing abstract method is harmless.

So either javac8 implementation is not correct (BTW, javac7 see default 
or the spec shoud be changed to say that adding a default implementation 
is not a compatible change
and Iterator.remove should be re-abstracted.


More information about the lambda-spec-experts mailing list