Exceptions and lambda.
maurizio.cimadamore at oracle.com
Wed Feb 6 05:33:58 PST 2013
On 06/02/13 13:03, Maurizio Cimadamore wrote:
> On 06/02/13 12:51, Srikanth S Adayapalam wrote:
>> I couldn't find some text that explicitly
>> forbids the scenario we are talking about (where types are elided and
>> inferred and
>> there is no further need to refer to any type variables)
> I think I cannot find it either - I think it should be in 15.27.3 Type
> of a Lambda Expression' - Dan?
The only bit about this that I could find is the discussion section in
9.8 (bullet 4).
It would seem that the text is implying that the restriction comes from
the fact that a lambda has no syntax for declaring type-parameters. On
the other hand I'm not sure that's enough, as the compiler could simply
generate a signature that matches the one in the functional descriptor
so that overriding is preserved (esp. when lambda formals are omitted).
If parameters are explcit, it's a different story, as the check that
enforces that lambda parameter types should match types in the
functional descriptor is mostly enough to guarantee that a lambda will
not be compatible with a generic functional descriptor. I said mostly
because if the descriptor doesn't mention type-variables in the argument
part, then the check doesn't help and we're back to square one.
More information about the lambda-spec-observers