Summary: | No warning on bad method | ||
---|---|---|---|
Product: | gcc | Reporter: | David Welton <davidw> |
Component: | java | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | gcc-bugs, java-prs |
Priority: | P2 | Keywords: | accepts-invalid, patch |
Version: | 3.3.4 | ||
Target Milestone: | 4.3.0 | ||
Host: | Target: | ||
Build: | Known to work: | 4.3.0 | |
Known to fail: | 4.1.0 | Last reconfirmed: | 2005-03-04 15:04:44 |
Attachments: | Patch to not check inappropriate methods. |
Description
David Welton
2005-03-04 08:18:58 UTC
Confirmed, reduced self contained testcase: class t { public String toString() throws java.io.IOException {return "";} } A patch is here: http://gcc.gnu.org/ml/java-patches/2005-q1/msg00710.html Subject: Bug 20312 CVSROOT: /cvs/gcc Module name: gcc Changes by: rmathew@gcc.gnu.org 2005-03-10 18:40:28 Modified files: gcc/java : ChangeLog parse.y Log message: PR java/20312 * parse.y (checks_throws_clauses): Check exceptions list even when the base class does not come from a source file being compiled. (java_complete_lhs): Remove unused variable 'wfl'. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/ChangeLog.diff?cvsroot=gcc&r1=1.1570&r2=1.1571 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/parse.y.diff?cvsroot=gcc&r1=1.529&r2=1.530 Fixed in 4.1.0 and above. This patch can cause an ICE when the super-class is byte-compiled. If a byte-compiled method M in a super-class throws exception X, we try to emit an erroneous error message that M can't throw X (because we don't analyze the bytecode). Worse, because M doesn't have DECL_FUNCTION_WFL set, we get an ICE in parse_error_context. The problem is check_interface_throws_clauses, which seems to be doing way too much work ... it should be not be checking that "The exception must be a subclass of an exception thrown" in super-classes. Created attachment 8697 [details]
Patch to not check inappropriate methods.
A tentative patch to the problem I mentioned.
In 4.3.0 this is correctly flagged as an error. With the testcase in comment #1 we get: $ gcj -o t --main=t t.java t.java:3: error: Exception IOException is not compatible with throws clause in Object.toString() public String toString() throws java.io.IOException ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 problem (1 error) |