JDK-6468384 : Problem with underconstrained type variables
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2006-09-07
  • Updated: 2010-04-06
  • Resolved: 2008-02-26
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7Resolved
Related Reports
Duplicate :  
Description
This program does not compile:

import java.util.LinkedHashSet;
import java.util.Set;

public class GenericsTest {

    public class A {};

    public class B extends A {};

    public static void main(String[] args) {
        GenericsTest g = new GenericsTest();
        Set<A> set = g.newSet(g.new B());
    }

    public <T, V extends T> Set<T> newSet(V... objects) {
        Set<T> set = new LinkedHashSet<T>();
        for (T t : objects) {
            set.add(t);
        }
        return set;
    }

}

Comments
EVALUATION This bug is a duplicate of bug 6278587 that has already been fixed and integrated in jdk7 b05.
26-02-2008

EVALUATION This is a bug. The compiler should infer A for T and B for V.
16-10-2006