Bug 81923

Summary: In certain cases generics seens to be applied before autoboxing.
Product: [Eclipse Project] JDT Reporter: Todor Boev <t_boev>
Component: CoreAssignee: Kent Johnson <kent_johnson>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 M5   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Todor Boev CLA 2004-12-27 05:20:16 EST
The following code compiles and executes fine with JDK 1.5.0_01 but does not 
compile with Eclipse 3.1M4:

public class Box<T> {
  private T t;

  public <A extends T> Box(A t) {
    this.t = t;
  }
  
  public String toString() {
    return "[" + t + "]";
  }
  
  public static void main(String[] args) { 
    //primitive type - error in eclipse
    System.out.println(new Box<Integer>(10));
    
    //primitive type - workarround for eclipse.
    System.out.println(new Box<Integer>(new Integer(10)));
    
    //reference type - fine everyware
    System.out.println(new Box<String>("alabala"));
  }
}

The compiler issues the following message:
"Bound mismatch: The generic constructor Box(A) of type Box<T> is not applicable 
for the arguments (int) since the type int is not a valid substitute for the 
bounded parameter <A extends T>"

Seems in this particular case the compiler applies generics on the primitive 
type (int) before it applies autoboxing to conver it to a valid reference type 
(Integer).
Comment 1 Kent Johnson CLA 2005-01-10 18:30:48 EST
Added AutoBoxing test078.
Comment 2 David Audel CLA 2005-02-16 05:47:53 EST
Verified in I20050215-2300