Java 8 language spec flaw/bug

Maurizio Cimadamore maurizio.cimadamore at
Fri Aug 22 14:23:12 UTC 2014

On 22/08/14 15:11, Davin McCall wrote:
> The type arguments are those of Class - i.e. String and StringBuilder 
> (from Class<String> and Class<StringBuilder>, being the types of 
> String.class and StringBuilder.class respectively). These are used to 
> impose constraints on the type variable T (for the foo function). So 
> the constraints are: ‹String |<=| T› and ‹StringBuilder |<=| T›. Are 
> you saying that the paragraph I quoted does not apply, since 'T' is a 
> type variable and not a proper type? In that case should I apply instead:
The paragraph applies, since it speaks about 'type'. An inference 
variable is a type. A type-variable is a type. String is a type. ? 
extends Something is _not_ a type.
So, the constraints should be reduced as equality constraints. And 
that's the right thing to do - the results of type inference should be 
proper types - a wildcard is not an acceptable inference result (as, 
again, it's not a type...).

Can think of a type T that is not a wildcard and yet it contains both 
String and StringBuilder?


More information about the lambda-dev mailing list