- 
    Bug 
- 
    Resolution: Fixed
- 
     P4 P4
- 
    8, 9
- 
        b23
- 
        Verified
| Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build | 
|---|---|---|---|---|---|---|
| JDK-8064048 | 8u45 | Maurizio Cimadamore | P4 | Resolved | Fixed | b01 | 
| JDK-8043927 | 8u40 | Maurizio Cimadamore | P4 | Resolved | Fixed | b01 | 
| JDK-8070268 | emb-8u47 | Maurizio Cimadamore | P4 | Resolved | Fixed | team | 
                    This 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());
}
}
which is accepted by javac 7 is rejected by javac 8 with this error message:
Test.java:11: 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
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());
}
}
which is accepted by javac 7 is rejected by javac 8 with this error message:
Test.java:11: 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
- backported by
- 
                    JDK-8043927 javac, code valid in 7 is not compiling for 8 -           
- Resolved
 
-         
- 
                    JDK-8064048 javac, code valid in 7 is not compiling for 8 -           
- Resolved
 
-         
- 
                    JDK-8070268 javac, code valid in 7 is not compiling for 8 -           
- Resolved
 
-         
- duplicates
- 
                    JDK-8056136 Java compiler - generics nested type declaration compilation failure -           
- Closed
 
-         
- 
                    JDK-8079622 Classes with generics that compile on 1.7.0_75 fail in 1.8.0_31 -           
- Closed
 
-         
- relates to
- 
                    JDK-8081797 Type inference regression in Java 8's compiler -           
- Closed
 
-         
             (1 relates to)