Bug 20302 - Problem with sub classes with contructors with exceptions
Problem with sub classes with contructors with exceptions
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: java
4.0.0
: P2 normal
: 4.3.0
Assigned To: Not yet assigned to anyone
: rejects-valid
Depends on: 28067
Blocks:
  Show dependency treegraph
 
Reported: 2005-03-03 17:30 UTC by steve
Modified: 2007-01-09 20:47 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-06-30 05:21:01


Attachments
Inner class test case (472 bytes, text/plain)
2005-03-03 17:32 UTC, steve
Details
Straigt sub class test case (306 bytes, text/plain)
2005-03-03 17:33 UTC, steve
Details

Note You need to log in before you can comment on or make changes to this bug.
Description steve 2005-03-03 17:31:00 UTC
GCJ does not handle compilation of sub classes with out explicitly defined
constructors to override the super class constructors when the constructors
throw exceptions.

[steve@helios steve]$ gcj Test.java -c Test.o
Test.java: In class 'Test$1':
Test.java: In constructor '(Test,java.io.ByteArrayInputStream)':
Test.java:9: error: Exception 'java.io.IOException' must be caught, or it must
be declared in the 'throws' clause of 'Test$1'.
           ObjectInputStream in = new ObjectInputStream(is)
                                                          ^
Test.java:9: error: Exception 'java.io.StreamCorruptedException' must be caught,
or it must be declared in the 'throws' clause of 'Test$1'.
           ObjectInputStream in = new ObjectInputStream(is)
                                                          ^
2 errors
[steve@helios steve]$ gcj Test2.java -c Test2.o
Test2.java: In class 'Test2':
Test2.java: In constructor '()':
Test2.java:3: error: Exception 'java.io.IOException' must be caught, or it must
be declared in the 'throws' clause of 'Test2'.
   class Test2 extends ObjectInputStream
        ^
1 error
Comment 1 steve 2005-03-03 17:32:49 UTC
Created attachment 8317 [details]
Inner class test case
Comment 2 steve 2005-03-03 17:33:32 UTC
Created attachment 8318 [details]
Straigt sub class test case
Comment 3 Andrew Pinski 2005-03-03 18:42:52 UTC
I think this is a dup of another bug, but I am too lazy to find the bug right now.
Comment 4 steve 2005-03-03 19:31:19 UTC
I have looked for this bug and did not see one.

15501 is similar but is not the same problem or is a subset of the problems
defined in my report.  As my bug also affects any Extends with Exceptions
defined in the super class constructor.

The work around is to add the overrideing constructors and call super(..)


Comment 5 Tom Tromey 2005-06-30 05:21:00 UTC
Note that Test2.java actually is invalid code.
Unlike anonymous constructors, implicit constructors are
not given any special treatment when it comes to 'throws'
clauses.

Test.java is valid code and should not be rejected.
Comment 6 Tom Tromey 2007-01-09 20:47:24 UTC
All gcj front end bugs have been fixed by the gcj-eclipse branch merge.
I'm mass-closing the affected PRs.
If you believe one of these was closed in error, please reopen it
with a note explaining why.
Thanks.