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
Note: See
TracTickets for help on using
tickets.
