Broken example in spec ?

Srikanth S Adayapalam srikanth_sankaran at
Sat Feb 9 20:10:39 PST 2013

0.6.1 - 9.8, Discussion & motivation box, second bullet says:

// --------8< -----------------

Under the current definition, a functional interface may be parameterized 
in a way that produces distinct abstract methods—that is, multiple methods 
that cannot be legally overridden with a single declaration. For example: 
interface I { Object m(); }
interface J<S> { S m(); }
interface K<T> { T m(); }
interface Functional<S,T> extends I, J<S>, K<T> {}
Interface Functional is functional—I.m is return-type-substitutable for 
the other two—but Functional<String,Integer> clearly cannot be implemented 
with a single method. This situation is acceptable, however: when 
functional interfaces are implicitly implemented, the overriding 
effectively occurs generically; instantiation of type parameters only 
occurs at the use site. In other words, if a lambda expression represents 
a Functional<String,Integer>, its treatment is similar to that of the 
class FunctionalImpl<S,T> implements Functional<S,T> { ... }
Functional<String,Integer> f = new FunctionalImpl<String,Integer>();

// --------8< -----------------

I think this part needs a careful relook - Both javac 8b74 and eclipse 
refuse to compile this snippet *precisely* for the reason that certain 
parameterization could run into unrelated  return types.
Ergo, `Functional' is not even a legal interface - let alone a functional 

Let me know if I have missed some nuance here.


-------------- next part --------------
An HTML attachment was scrubbed...

More information about the lambda-spec-experts mailing list