Bug 99986 - [compiler] Exception signature mismatch with multiply-inherited methods
Summary: [compiler] Exception signature mismatch with multiply-inherited methods
Status: VERIFIED DUPLICATE of bug 79798
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.5 M4   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-14 11:39 EDT by Derek Inksetter CLA
Modified: 2008-12-08 22:00 EST (History)
1 user (show)

See Also:


Attachments
Testcase (4.61 KB, patch)
2008-11-25 14:53 EST, Kent Johnson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Derek Inksetter CLA 2005-06-14 11:39:17 EDT
If I have two interfaces with the same method, but with mismatching exception
signatures, it's legal for me to have an implementation of those two interfaces
that has a method with no exception thrown in its signature.  It's also legal
for me to have an intermediate interface that inherits from the two other
interfaces.

class AException extends Exception { }
class BException extends Exception { }

interface A {
    public void xyz() throws AException;
}
 
interface B {
    public void xyz() throws BException;
}
 
interface C extends A, B { }
 
class D implements C {
    public void xyz() {
        System.out.println("In XYZ");
    }
}

If I have a caller that uses the implementation type, it's clear that the caller
shouldn't expect an exception to be thrown.  If, however the caller uses the
intervening interface type, Eclipse and javac seem to differ on the interpretation.

public class InheritenceTest {

    public static void main(String[] args) {
        C c = new D();
        c.xyz();
    }
}

In that bit of sample code, javac (Sun 1.5.0_03) compiles it and runs with no
trouble.  Eclipse gives an error saying "Unhandled exception type AException"
and refuses to build.
Comment 1 Olivier Thomann CLA 2006-10-06 16:41:34 EDT
Reproduced in HEAD.
----------
1. ERROR in D:\tests_sources\InheritenceTest.java (at line 5)
	c.xyz();
	^^^^^^^
Unhandled exception type AException
----------
1 problem (1 error)

javac 1.4 and 1.5 don't report any error.
Comment 2 Olivier Thomann CLA 2006-10-06 16:42:07 EDT
jikes 1.22 doesn't report any error as well.
Comment 3 Philipe Mulet CLA 2008-10-03 11:04:06 EDT
This is a dup of 79798 addressed in 3.4.0.
Kent - pls close it properly, added regression test if needed.
Comment 4 Kent Johnson CLA 2008-11-25 14:53:33 EST
Created attachment 118689 [details]
Testcase
Comment 5 Kent Johnson CLA 2008-11-25 14:55:05 EST
Test released for 3.5M4

*** This bug has been marked as a duplicate of bug 79798 ***
Comment 6 Olivier Thomann CLA 2008-12-08 22:00:01 EST
Verified for 3.5M4 using I20081208-1800