Duplicate :
|
|
Relates :
|
|
Relates :
|
FULL PRODUCT VERSION : java version "1.9.0-ea" Java(TM) SE Runtime Environment (build 1.9.0-ea-b74) Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b74, mixed mode) ADDITIONAL OS VERSION INFORMATION : Darwin x86_64 A DESCRIPTION OF THE PROBLEM : The included program has different behaviour when compiled with the jdk9 javac than with earlier versions. Specifically, javac9 resolves the invocation inside f() as g(Object...), and javac8 resolves g(M[]). This is probably related to https://bugs.openjdk.java.net/browse/JDK-8039214. REGRESSION. Last worked in version 8u60 ADDITIONAL REGRESSION INFORMATION: java version "1.8.0_60-ea" Java(TM) SE Runtime Environment (build 1.8.0_60-ea-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.60-b12, mixed mode) STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : $JAVA_8_HOME/bin/javac Test.java $JAVA_8_HOME/bin/java Test one $JAVA_9_HOME/bin/javac Test.java $JAVA_9_HOME/bin/java Test two EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - I expected the same behaviour from both compilers. ACTUAL - The program behaved differently when compiled with javac9. REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- public class Test { interface M<T> {} public static void main(String[] args) { f((M<Object>) null); } static <T> void f(M<? super T>... xs) { g(xs); } public static <E> void g(M<? super E>... xs) { System.err.println("one"); } public static <E> void g(E... xs) { System.err.println("two"); } } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : Explicit type parameters: static <T> void f(M<? super T>... xs) { Test.<M<? super T>>g(xs); }
|