Bug 77861

Summary: [1.5] Illegal class file generated with duplicate methods
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: CoreAssignee: Kent Johnson <kent_johnson>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jkassis-eclipseBugs
Version: 3.1   
Target Milestone: 3.1 M4   
Hardware: PC   
OS: Windows XP   
See Also: https://git.eclipse.org/r/78302
Whiteboard:

Description Markus Keller CLA 2004-11-04 11:59:44 EST
3.1M3 test pass

The following class gets compiled without errors:

  public class K implements Comparable<K> {
    public int compareTo(Object o) {
      return 0;
    }
    public int compareTo(K o) {
      return 1;
    }
  }

The class file gets 3 methods:
- public int compareTo(Object arg);
- public int compareTo(K arg);
- public bridge synthetic int compareTo(Object arg);

Using the class with ...
  class User {
    public static void main(String[] args) {
      K k= new K();
      k.compareTo(new K());
    }
  }
... gives a classloader exception:
Exception in thread "main" java.lang.ClassFormatError: Repetitive method
name/signature in class file k/K

javac1.5.0 resists to compile the source:
name clash: compareTo(java.lang.Object) in k.K and compareTo(T) in
java.lang.Comparable<k.K> have the same erasure, yet neither overrides the other
Comment 1 Kent Johnson CLA 2004-11-16 15:32:17 EST
Added MethodVerify test 18
Comment 2 Kent Johnson CLA 2004-11-24 16:59:54 EST
*** Bug 79250 has been marked as a duplicate of this bug. ***
Comment 3 Olivier Thomann CLA 2004-12-14 15:06:21 EST
Verified in 200412140800.
Now we report an error compiling K.
Comment 4 Olivier Thomann CLA 2004-12-14 15:06:34 EST
Verified in 200412140800.
Now we report an error compiling K.
Comment 5 Eclipse Genie CLA 2016-08-02 06:09:21 EDT
New Gerrit change created: https://git.eclipse.org/r/78302