Throwable

Raffaello Giulietti raffaello.giulietti at gmail.com
Wed Aug 19 02:36:26 PDT 2009


Charles Oliver Nutter wrote:
> On Tue, Aug 18, 2009 at 6:29 AM, Raffaello
> Giulietti<raffaello.giulietti at gmail.com> wrote:
>> The language compiler complains about an
>> unreported exception Throwable; must be caught or declared to be thrown
>> in using both InvokeDynamic and the (invisible) MethodHandle.invoke()
>>
>> Why is this so?
>> What about an (unchecked) RuntimeException instead?
> 
> I believe this was added because in theory the target of invokedynamic
> or a Method handle could produce any Throwable in the system, and so
> in order for you to be able to propagate or handle those throwables,
> it must throw Throwable.
> 
> - Charlie
> _______________________________________________
> mlvm-dev mailing list
> mlvm-dev at openjdk.java.net
> http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev

Yes, this is the first reason that comes to mind.

But it is not technically necessary. The JVM spec doesn't mandate that
methods declare the exceptions they throw. And since InvokeDynamic and
MethodHandle are quite special Java classes known to the language
compiler, the throws declaration could be avoided even in the language
for these cases.

As you might guess, I'm not a close friend of checked exceptions ;-)




More information about the mlvm-dev mailing list