Modify

Ticket #234 (new defect)

Opened 8 years ago

Wrong exception checking for anonymous inner class constructors in GJ

Reported by: hauma Owned by: moschny
Priority: normal Milestone:
Component: gjc Version: 1.00
Severity: normal Keywords:
Cc:

Description

The following code should silently compile: A new anonymous inner class is constructed as subclass of A by calling its constructor A() that declares an exception to be thrown. This exception is declared to be thrown from the surronding method.

import java.io.IOException;

class A {
    A() throws IOException {}
}

class C {
    void bar() throws IOException {
        A x = new A() {};
    }
}

When compiling with GJ, the following error is reported. This indicates that the generated inner class constructor misses to declare IOException.

A.java:9: unreported exception: java.io.IOException; must be caught
or declared to be thrown

        A x = new A() {};
                      ^

Attachments

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as new
as The resolution will be set. Next status will be 'closed'
to The owner will be changed from moschny. Next status will be 'new'
The owner will be changed from moschny to anonymous. Next status will be 'assigned'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.