Exception transparency vs constructors
Mark Mahieu
mark at twistedbanana.demon.co.uk
Wed Jul 9 20:23:57 PDT 2008
LOL, I thought this all sounded a bit familiar. It seems I actually
bothered to get this working for CICE expressions - where it's even
*less* useful, because you can't pass an argument to the constructor
so need an explicit type argument - and never noticed it didn't work
for regular 'new' expressions. I even have a jtreg test for it.
Guess I must have a thing for generic constructors :)
On 8 Jul 2008, at 15:30, Mark Mahieu wrote:
> Thanks for the info.
>
> Regards,
> Mark
>
> On 8 Jul 2008, at 15:00, Neal Gafter wrote:
>
>> 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/20080710/a7c6bd70/attachment.html
More information about the closures-dev
mailing list