// The following code does not compile under openjdk-6, while it compiles under openjdk-7 and sun-jdk-6
// Error message:
//Test.java:[10,14] invalid inferred types for K,V; inferred type does not conform to declared bound(s)
// inferred: C
// bound(s): java.lang.String
// java -version
// java version "1.6.0_23"
// OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre11-0ubuntu1.11.10)
// OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)
// uname -srvmpio
// Linux 3.0.0-15-generic #24-Ubuntu SMP Mon Dec 12 15:23:55 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
public class Test {
public static void main(String[] args) {
newTreeMap(String.CASE_INSENSITIVE_ORDER);
}
public static <C, K extends C, V> TreeMap<K, V> newTreeMap(
@Nullable Comparator<C> comparator) {
// Ideally, the extra type parameter "C" shouldn't be necessary. It is a
// work-around of a compiler type inference quirk that prevents the
// following code from being compiled:
// Comparator<Class<?>> comparator = null;
// Map<Class<? extends Throwable>, String> map = newTreeMap(comparator);
return new TreeMap<K, V>(comparator);
}
}
// The following code does not compile under openjdk-6, while it compiles under openjdk-7 and sun-jdk-6
// Error message:
//Test.java:[10,14] invalid inferred types for K,V; inferred type does not conform to declared bound(s)
// inferred: C
// bound(s): java.lang.String
// java -version 0ubuntu1. 11.10)
// java version "1.6.0_23"
// OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre11-
// OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)
// uname -srvmpio
// Linux 3.0.0-15-generic #24-Ubuntu SMP Mon Dec 12 15:23:55 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
import javax.annotatio n.Nullable; Comparator;
import java.util.
import java.util.TreeMap;
public class Test { String. CASE_INSENSITIV E_ORDER) ;
public static void main(String[] args) {
newTreeMap(
}
public static <C, K extends C, V> TreeMap<K, V> newTreeMap( Class<? >> comparator = null; comparator) ;
@Nullable Comparator<C> comparator) {
// Ideally, the extra type parameter "C" shouldn't be necessary. It is a
// work-around of a compiler type inference quirk that prevents the
// following code from being compiled:
// Comparator<
// Map<Class<? extends Throwable>, String> map = newTreeMap(
return new TreeMap<K, V>(comparator);
}
}