JDK-8056136 : Java compiler - generics nested type declaration compilation failure
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8u11
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux_redhat_6.0
  • CPU: x86
  • Submitted: 2014-08-20
  • Updated: 2014-12-09
  • Resolved: 2014-08-27
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
CentOS release 6.5 (Final)

EXTRA RELEVANT SYSTEM CONFIGURATION :
javac 1.8.0_20


A DESCRIPTION OF THE PROBLEM :
Create Test.java with following code


interface Iface<T1> {}

class Impl implements Iface<Impl> {}

class Acceptor<T2 extends Iface<T2>> {
    public Acceptor(T2 obj) {}
}

public class Test {
    public static void main(String[] args) {
        Acceptor<?> acceptor = new Acceptor<>(new Impl());
    }
} 



try to compile it

javac Test.java 
Test.java:12: error: incompatible types: cannot infer type arguments for Acceptor<>
        Acceptor<?> acceptor = new Acceptor<>(new Impl());
                                           ^
    reason: inference variable T2 has incompatible bounds
      equality constraints: Impl
      upper bounds: Iface<CAP#1>,Iface<T2>
  where T2 is a type-variable:
    T2 extends Iface<T2> declared in class Acceptor
  where CAP#1 is a fresh type-variable:
    CAP#1 extends Iface<CAP#1> from capture of ?
1 error



http://stackoverflow.com/questions/23063474/why-does-this-java-8-program-not-compile
https://bugs.openjdk.java.net/browse/JDK-8043926



REGRESSION.  Last worked in version 8u11

ADDITIONAL REGRESSION INFORMATION: 
release 1.8.0_20 isn't available in regression so marking it 11 it is there in 5, 11, 20 all minor releases for 1.8


REPRODUCIBILITY :
This bug can be reproduced always.


Comments
Works in 9 and 8u-dev.
27-08-2014