Project Lambda: Java Language Specification draft
Alex Buckley
Alex.Buckley at Sun.COM
Fri Jan 22 16:37:21 PST 2010
Alex Blewitt wrote:
> On 22 Jan 2010, at 22:55, Alex Buckley <Alex.Buckley at Sun.COM> wrote:
>
>> * Exceptions
>>
>> [11.2.1 Exception Analysis of Expressions]
>>
>> A lambda invocation expression on a lambda expression of type
>> #T(S1..Sm)(X1..Xn) can throw an exception type E iff either:
>>
>> - some expression of the argument list can throw E, or
>> - there exists an i in 1..n such that Xi is E.
>
> Does that mean the only way to throw a RuntimeException is if it is
> explicitly declared in the type?
No. The body of the lambda expression is able to throw whatever
unchecked exceptions it likes, akin to the body of a method. For the
purpose of exception checking, it is not the case that a method
invocation "can throw" a RuntimeException even if the method's body
contains 'throw new RuntimeException()'. Same for lambda invocation.
> Does it also prevent throwing an EOFException if you've only declared
> IOException in the list?
It shouldn't prevent it, but technically it does. I am reminded of some
changes to 11.2 that Neal raised years ago; time to sync them up.
Alex
More information about the lambda-dev
mailing list