JDK-8133916 : Regression in inference for array type with wildcard
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: os_x
  • CPU: x86
  • Submitted: 2015-08-17
  • Updated: 2017-01-06
  • Resolved: 2017-01-06
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 9
9Resolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
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);
}


Comments
Resolved in JDK-8159680.
06-01-2017

Specified behavior: Iterable<? super String>[] --> Iterable<? super e>[] reduces to Iterable<? super String> <: Iterable<? super e> reduces to { e <: String } Based on the error message, javac seems to be performing an unspecified capture step.
10-12-2015

Simplified test case: <E> void g(Iterable<? super E>[] xs) {} void test(Iterable<? super String>[] xs) { g(xs); } Compiles in 8, fails in 9 (after JDK-8033718).
10-12-2015

Change in behavior was introduced by JDK-8033718.
10-12-2015

- Checked this for JDK 7u85, 8u60, 9 ea b76 and could reproduce the issue. When compiled with JDK 9 ea b76, the results differ from JDK 8u60 and JDK 7u85. - Result: 7u85: OK 8: OK 8u60: OK 9 ea b76: FAIL - Output with JDK 8u60: > java Test one - Output with JDK 9 ea b76: > java Test two This seems related to JDK-8039214. Moving this up for further evaluation.
19-08-2015