Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6556624

Fails to accept program with Tj <: A constraint

XMLWordPrintable

    • generic
    • generic

      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();
           }
      }

            mcimadamore Maurizio Cimadamore
            ahe Peter Ahe
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: