Bug 81017

Summary: [generics]Type erasure not performed for classes implementing generic interfaces
Product: [Eclipse Project] JDT Reporter: Christophe Avare <christophe.avare>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED DUPLICATE QA Contact:
Severity: blocker    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Christophe Avare CLA 2004-12-14 17:42:52 EST
Generic support is going better every day!
But the following case appears to be legal but is rejected:

Some interfaces:

interface IKey {
  String getKey();
}

interface IFactory<T extends IKey> {
  T create();
}

Based on a default (abstract) implementation of IFactory:

abstract class DefaultFactory<T extends IKey> implements IFactory<T> {
}

and a concrete implementation of IKey:
class Key implements IKey { ... }

I want to make a specialized factory for Key:

class KeyFactory extends DefaultFactory<Key> {
...
  public Key create() {...}
}

The create() method raises the compile error:

Type safety: The return type Key of the method create() of type KeyFactory needs
unchecked conversion to conform to the return type T of inherited method

This set of classes compiles and works as expected under the Sun javac.
Eclipse JDT behaves like if the method signature is not resolved through the
hierarchy of classes that implements generic interfaces.
Comment 1 Jerome Lanneluc CLA 2004-12-15 04:38:01 EST

*** This bug has been marked as a duplicate of 79687 ***