Exception transparency vs constructors
Neal Gafter
neal at gafter.com
Tue Jul 8 07:00:12 PDT 2008
Mark-
FYI, the new javac bug report is 6723444 and will appear at
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6723444 within a few
days.
Regards,
Neal
On Mon, Jul 7, 2008 at 1:22 AM, Neal Gafter <neal at gafter.com> wrote:
> Mark-
>
> This is indeed a bug in the underlying compiler. Generic constructors are
> pretty rare, and type parameters in throws clauses even more so. Apparently
> the combination doesn't currently work in javac. The following won't
> compile.
>
> *public class Hello {
> static class Foo<X> {}
>
> <X extends Throwable> Hello(Foo<X> foo) throws X {}
>
> public static void main(String[] args) throws Exception {
> new Hello(new Foo<Exception>());
> }
> }*
>
> I've reported this as a bug against javac.
>
> Regards,
> Neal
>
>
> On Thu, May 15, 2008 at 7:22 PM, Neal Gafter <neal at gafter.com> wrote:
>
>> Got it, thanks! I suspect some of these are symptoms of existing
>> problems, but either way I'll track them down.
>>
>> Regards,
>> Neal
>>
>>
>> On Thu, May 15, 2008 at 6:22 PM, Mark Mahieu <
>> mark at twistedbanana.demon.co.uk> wrote:
>>
>>> It looks like exception transparency isn't working quite right with
>>> constructors - I think the following class should compile, but it doesn't:
>>>
>>>
>>> public class ExTrans {
>>>
>>> <throws X> ExTrans({=> void throws X} block) throws X {
>>> block.invoke();
>>> }
>>>
>>> public static void main(String[] args) throws Exception {
>>> new ExTrans({=> throw new Exception(); });
>>> }
>>> }
>>>
>>>
>>>
>>> ExTrans.java:8: unreported exception X; must be caught or declared to be
>>> thrown
>>> new ExTrans({=> throw new Exception(); });
>>> ^
>>> 1 error
>>>
>>>
>>>
>>> Regards,
>>>
>>> Mark
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/closures-dev/attachments/20080708/7b428b8a/attachment.html
More information about the closures-dev
mailing list