JDK-6556624 : Fails to accept program with Tj <: A constraint
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6
  • Priority: P5
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: generic
  • CPU: generic
  • Submitted: 2007-05-11
  • Updated: 2010-07-29
  • Resolved: 2010-07-29
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
Relates :  
Relates :  
Relates :  
Description
This program should continue to not compile:

import java.util.*;

class Test {

     private static <T> T method(Collection<? super T> arg) {
              return null;
     }

     private static void test5(Collection<?> arg) {
         Class<? extends String> c = method(arg).getClass();
     }
}
This program does not compile:

import java.util.*;

class Test {

     private static <T> T method(Collection<? super T> arg) {
              return null;
     }

     private static void test4(Collection<? super String> arg) {
         Class<? extends String> c = method(arg).getClass();
     }
     private static void test6(Collection<String> arg) {
         Class<? extends String> c = method(arg).getClass();
     }
}

Comments
EVALUATION Fixed in JDK 7 as side-effect of 6638712
29-07-2010

EVALUATION Filed specification CR 6556628.
11-05-2007

EVALUATION In method test4 and test6 the inference algorithm infers the constraint T <: String The JLS is not completely clear if this constraint is ever used, as it is only mentioned in the special rule for assignment conversion contexts.
11-05-2007