Bug 132831 - [1.5][compiler] Compiler generate brige when not needed
Summary: [1.5][compiler] Compiler generate brige when not needed
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 09:01 EST by Rémi Forax CLA
Modified: 2006-04-14 04:58 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 09:01:30 EST
The following code compiles with javac not with eclipse.
Eclipse compiler generate a bridge method that
generates an IllegalAccessError at runtime.

----------------------------------------
package fr.umlv.bridgebug;
abstract class A implements I{
  public A m() {
    return null;
  }
}
---------------------------------------
package fr.umlv.bridgebug;
public abstract class B extends A {
}
---------------------------------------
package fr.umlv.bridgebug;
public interface I {
  I m();
}
-------------------------------------
package fr.umlv.bridgebug.test;

import fr.umlv.bridgebug.B;
import fr.umlv.bridgebug.I;

public class C extends B {
    public static boolean test(I i) {
      return i.m()==null;
    }
    
    public static void main(String[] args) {
      I i=new C();
     System.out.println(test(i));
    }

}

the exception at runtime :

Exception in thread "main" java.lang.IllegalAccessError: tried to access class fr.umlv.bridgebug.A from class fr.umlv.bridgebug.test.C
	at fr.umlv.bridgebug.test.C.m(C.java:1)
	at fr.umlv.bridgebug.test.C.test(C.java:8)
	at fr.umlv.bridgebug.test.C.main(C.java:13)

Using javap, eclipse generated a bridge method m() in C ??
and the bridge method in B has I as return type I and not A.

Rémi Forax
Comment 1 Kent Johnson CLA 2006-04-04 11:51:25 EDT
Added MethodVerifyTest 83

We were mistakenly adding a bridge method to C because its superclasses are abstract.
Comment 2 David Audel CLA 2006-04-14 04:58:48 EDT
Verified for 3.2RC1 with build I20060413-1718