Bug 82287 - implementing multiple paramaterized interface cause no compiler error but a runtime exception.
Summary: implementing multiple paramaterized interface cause no compiler error but a r...
Status: RESOLVED DUPLICATE of bug 81824
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-05 17:06 EST by Daniel Le Berre CLA
Modified: 2005-01-05 17:17 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Le Berre CLA 2005-01-05 17:06:39 EST
After reading type erasure mechanics, I tried to write the following
class under Eclipse:

class Toto {}
class Strategy {}

class Toto implements Comparable<Toto>,Comparable<Strategy> {
    
    private int i;
    
    Toto(int i) {
        this.i = i;
    }
    
    /* (non-Javadoc)
     * @see java.lang.Comparable#compareTo(T)
     */
    public int compareTo(Toto t) {
         return t.i-i;
    }
    
    /* (non-Javadoc)
     * @see java.lang.Comparable#compareTo(T)
     */
    public int compareTo(Strategy st) {
         return -1;
    }

    public String toString() {
        return String.valueOf(i);
    }
}

It compiles without warning but throws a runtime exception:
Exception in thread "main" java.lang.ClassFormatError: Repetitive interface name
in class file Toto
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
	at Tigre.main(Tigre.java:107)

Using javac 
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)

I obtain the following error message:
src/Tigre.java:119: java.lang.Comparable cannot be inherited with different
arguments: <Toto> and <Strategy>
class Toto implements Comparable<Toto>,Comparable<Strategy> {
^
1 error
Comment 1 Olivier Thomann CLA 2005-01-05 17:17:28 EST

*** This bug has been marked as a duplicate of 81824 ***