Bug 132841 - [1.5][compiler] Incorrectly compared method parameters when member types
Summary: [1.5][compiler] Incorrectly compared method parameters when member types
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 RC1   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-22 10:18 EST by Rémi Forax CLA
Modified: 2006-04-14 04:47 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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