Bug 87142 - Ambiguous methods and autoboxing
Summary: Ambiguous methods and autoboxing
Status: RESOLVED WORKSFORME
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 M6   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-04 09:58 EST by Christoph Lembeck CLA
Modified: 2005-03-17 06:36 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 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.