Bug 87142

Summary: Ambiguous methods and autoboxing
Product: [Eclipse Project] JDT Reporter: Christoph Lembeck <christoph.lembeck>
Component: CoreAssignee: Kent Johnson <kent_johnson>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Christoph Lembeck CLA 2005-03-04 09:58:15 EST
Eclipse 3.1M5 indicates the method call in the following program as abiguous 
where Suns compiler does not. The original Java compiler identifies the equals
(int, int) method to be taken...

public class Test{
  public static void main(String[] args){
    equals(new Integer(42), 17); // can not be resolved by eclipse
  }
  public static void equals(Object a, Object b) {
    System.out.println("Object: " + a.equals(b));
  }
  public static void equals(int a, int b) {
    System.out.println("int: " + (a == b));
  }
}
Comment 1 Kent Johnson CLA 2005-03-06 14:22:56 EST

*** This bug has been marked as a duplicate of 85491 ***
Comment 2 Kent Johnson CLA 2005-03-10 15:49:59 EST
Actually its not a duplicate of bug 85491 since that one is varargs related.
Comment 3 Kent Johnson CLA 2005-03-10 16:04:43 EST
I tried this case with javac & this is the error I get:

3: reference to equals is ambiguous, both method equals
(java.lang.Object,java.lang.Object) in Test and method equals(int,int) in Test 
match equals(new Integer(42), 17);

What version/build # of javac are you using? I'm using javac 1.5.0_01.
Comment 4 Christoph Lembeck CLA 2005-03-17 06:36:28 EST
(In reply to comment #3)

> What version/build # of javac are you using? I'm using javac 1.5.0_01.

OK, i changed from version 1.5.0-rc-b63 to 1.5.0_02-b09 and now the compiler 
produces the same error message as eclipse.