Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 322740

Summary: Compiler fails to report name clash
Product: [Eclipse Project] JDT Reporter: Srikanth Sankaran <srikanth_sankaran>
Component: CoreAssignee: Srikanth Sankaran <srikanth_sankaran>
Status: VERIFIED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: mauromol, Olivier_Thomann, stephan.herrmann
Version: 3.6   
Target Milestone: 3.7.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Srikanth Sankaran CLA 2010-08-16 00:07:25 EDT
From bug 322001 comment 14:

class Base  {
    boolean equalTo(Object other) {return false;}
}

interface EqualityComparable<T> {
    boolean equalTo(T other);
}

public class SomeClass extends Base implements EqualityComparable<String> {
    public boolean equalTo(String other) {
        return true;
    }
    public static void main(String args[]) {
        new SomeClass().equalTo(args);
    }
}

The program above contains a name clash between the
inherited method and the bridge method. Eclipse
fails to report the name clash. The generated code
fails at runtime instead with a CCE.

javac has the same bug too.
Comment 1 Srikanth Sankaran CLA 2011-05-16 05:39:30 EDT
(In reply to comment #0)
> From bug 322001 comment 14:

> javac has the same bug too.

As of 7b138, javac7 does report the name clash, so eclipse needs
to report too.
Comment 2 Srikanth Sankaran CLA 2011-05-16 06:26:54 EDT
The patch posted for bug 334306, fixes this issues also.
I'll close this as a duplicate of bug 334306 and add a
junit for the comment# 0 test case.

*** This bug has been marked as a duplicate of bug 334306 ***
Comment 3 Stephan Herrmann CLA 2011-06-30 07:12:30 EDT
Trying to verify this bug I can't find a version of ecj that actually
exhibits the bug. Could you please advise how I could reproduce the
bug to see what actually the fix fixed?

$ java -jar ~/jdt/ecj-3.6.jar -version
Eclipse Compiler for Java(TM) 0.A58, 3.6.0, Copyright IBM Corp 2000, 2010. All rights reserved.

$ java -jar ~/jdt/ecj-3.6.jar -1.5 SomeClass.java 
----------
1. ERROR in SomeClass.java (at line 9)
        public class SomeClass extends Base implements EqualityComparable<String> {
                     ^^^^^^^^^
Name clash: The method equalTo(T) of type EqualityComparable<T> has the same erasure as equalTo(Object) of type Base but does not override it
----------
1 problem (1 error)
Comment 4 Srikanth Sankaran CLA 2011-06-30 07:28:54 EDT
(In reply to comment #3)
> Trying to verify this bug I can't find a version of ecj that actually
> exhibits the bug. Could you please advise how I could reproduce the
> bug to see what actually the fix fixed?

I guess the only way to reproduce this is to test a version closer to
the date of the comment (2010-08-10). Unfortunately I don't have version
handy to test it myself.

Otherwise, you can also test it black box manner.
Comment 5 Stephan Herrmann CLA 2011-06-30 07:56:03 EDT
Verified that
- javac 1.6 exhibits this bug
- non of the following versions of ecj has this bug:
  3.6, 3.6.1, 3.6.2, 3.7Mx, 3.7.0
- Also 3.7 + the Java7 patch feature correctly reports the error, using
  "Eclipse Java Development Tools Patch for Java 7 Support (Beta) 1.0.0.v20110623-0900"