Bug 77861 - [1.5] Illegal class file generated with duplicate methods
Summary: [1.5] Illegal class file generated with duplicate methods
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M4   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 79250 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-11-04 11:59 EST by Markus Keller CLA
Modified: 2016-08-02 06:09 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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