Bug 101049

Summary: Error when parametrized type extending final type as return value.
Product: [Eclipse Project] JDT Reporter: Mikael Nordenberg <mikael>
Component: CoreAssignee: Kent Johnson <kent_johnson>
Status: VERIFIED FIXED QA Contact:
Severity: major    
Priority: P3 CC: mlists
Version: 3.1   
Target Milestone: 3.1.1   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Mikael Nordenberg CLA 2005-06-21 10:18:24 EDT
The following code creates an error in eclipse RC3, but compiles using Sun JDK1.5:

1: interface BaseClass<T> {
2:   <U extends T> U getItem();
3: }

4: class SubClass implements BaseClass<Boolean> {
5:   public <U extends Boolean> U getItem() {...}
6: }

Line 5 gives a warning: 
"The type parameter U should not be bounded by the final type Boolean"
As a consequence Eclipse does not think SubClass is implementing BaseClass.

Not that if using "Add unimplemented methods" to create the stub in SubClass,
this (line #5) is the signature eclipse creates.
Comment 1 Mikael Nordenberg CLA 2005-06-21 11:33:16 EDT
The previous example shows the problem, but might be considered stupid,
so here's another example that don't compile showing that it really is a serious
bug:

interface Factory<T> {
  <U extends T> U create(Class<U> c);
}

class BooleanFactory implements Factory<Boolean> {
  <U extends Boolean> U create(Class<U> c) {
    try {
      return c.newInstance();
    } catch(Exception e) {
      return null;
    }
  }
}
Comment 2 Philipe Mulet CLA 2005-06-22 16:25:48 EDT
Too late for considering it for 3.1.
Will consider it for 3.1.1 as it has no obvious workaround.

Comment 3 Kent Johnson CLA 2005-09-19 15:39:15 EDT
Added MethodVerify test070
Comment 4 Olivier Thomann CLA 2005-09-26 10:59:59 EDT
Verified for 3.1.1 using M20050923-1430.