Bug 96646 - [1.5][compiler] VerifyError - Generics and Interfaces - "Wrong return type in function"
Summary: [1.5][compiler] VerifyError - Generics and Interfaces - "Wrong return type in...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 critical (vote)
Target Milestone: 3.1 RC1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-25 13:09 EDT by Bryan Barkley CLA
Modified: 2005-05-27 10:42 EDT (History)
0 users

See Also:


Attachments
Apply on HEAD (2.77 KB, patch)
2005-05-26 16:39 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bryan Barkley CLA 2005-05-25 13:09:27 EDT
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
Comment 1 Philipe Mulet CLA 2005-05-26 10:01:55 EDT
Reproduced
Comment 2 Philipe Mulet CLA 2005-05-26 16:06:40 EDT
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.
Comment 3 Olivier Thomann CLA 2005-05-26 16:39:46 EDT
Created attachment 21860 [details]
Apply on HEAD
Comment 4 Philipe Mulet CLA 2005-05-26 16:56:39 EDT
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.
Comment 5 Olivier Thomann CLA 2005-05-27 10:42:19 EDT
Verified in I20050526-2000