Community
Participate
Working Groups
The following code fails when compiled using Eclipse (3.1M7) but runs when compiled with Sun's JDK. ---------- BaseFactory.java ------------- public abstract class BaseFactory <T> { public T create() throws Exception { return getType().newInstance(); } public abstract Class<T> getType(); } ---------- StringFactory.java ------------- public interface StringFactory { public String create() throws Exception; } ---------- StringFactoryImpl.java ------------- public class StringFactoryImpl extends BaseFactory<String> implements StringFactory { @Override public Class<String> getType() { return String.class; } public static void main(String[] args) throws Exception { String emptyString = new StringFactoryImpl().create(); System.out.printf("We have '%s' of type %s", emptyString, emptyString.getClass()); } } The error is: java.lang.VerifyError: (class: StringFactoryImpl, method: create signature: ()Ljava/lang/String;) Wrong return type in function
Reproduced
Problem comes from synthetic bridge method not issuing an exception attribute. Olivier: all synthetic methods should dump exception attributes if the binding carries any. Only bridge methods should currently specify any, but in theory more could do so as well.
Created attachment 21860 [details] Apply on HEAD
Thanks Olivier, indeed there was another more serious issue with missing checkcast in bridge method. Only do the cast when access method type is different from target method. Fixed. Added GenericTypeTest#test700.
Verified in I20050526-2000