Bug 101049 - Error when parametrized type extending final type as return value.
Summary: Error when parametrized type extending final type as return value.
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows 2000
: P3 major with 1 vote (vote)
Target Milestone: 3.1.1   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-21 10:18 EDT by Mikael Nordenberg CLA
Modified: 2005-09-26 10:59 EDT (History)
1 user (show)

See Also:


Attachments

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