Bug 132841

Summary: [1.5][compiler] Incorrectly compared method parameters when member types
Product: [Eclipse Project] JDT Reporter: Rémi Forax <forax>
Component: CoreAssignee: Kent Johnson <kent_johnson>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.2   
Target Milestone: 3.2 RC1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Rémi Forax CLA 2006-03-22 10:18:21 EST
The following code generate an AbstractMethodError at runtime :

----------------------------------------------------------------
import java.util.List;

public interface I<T> {
  List<T> f(T t);
}
----------------------------------------------------------------
import java.util.List;
public abstract class A<N extends A.NImpl> implements I<N> {
  public List<N> f(NImpl n) { // <--- oh oh, little trick
    return null;
  }
  
  static class NImpl {
  }
}
------------------------------------------------------------
public class B extends A<A.NImpl> {
}
------------------------------------------------------------
import java.util.List;

public class Test {
  public static <T> List<T> f(I<T> i,T t) {
    return i.f(t);
  }
  public static void main(String[] args) {
    I<?> i=new B();
    i.f(null);
  }
}

at runtime :
Exception in thread "main" java.lang.AbstractMethodError: bug2.B.f(Ljava/lang/Object;)Ljava/util/List;
	at bug2.Test.main(Test.java:11)

the bridge b.f() in not generated by eclipse compiler.

Rémi Forax
Comment 1 Kent Johnson CLA 2006-03-31 15:27:35 EST
Our comparison of the member type in public List<N> f(NImpl n) {...} to the substituted type in I.f(T) is causing the problem.
Comment 2 Kent Johnson CLA 2006-04-04 11:54:39 EDT
Added MethodVerifyTest 84

The issue with bridge methods was a side affect of the fact that we incorrectly compared the method parameters of A.f(NImpl) with I.f(T), which was substituted with the member type NImpl.
Comment 3 David Audel CLA 2006-04-14 04:47:50 EDT
Verified for 3.2RC1 with build I20060413-1718