generics - Why does this Java 8 program not compile? -


this program compiles fine in java 7 (or in java 8 -source 7), fails compile java 8:

interface iface<t> {} class impl implements iface<impl> {}  class acceptor<t extends iface<t>> {     public acceptor(t obj) {} }  public class main {     public static void main(string[] args) {         acceptor<?> acceptor = new acceptor<>(new impl());     } } 

result:

main.java:10: error: incompatible types: cannot infer type arguments acceptor<>         acceptor<?> acceptor = new acceptor<>(new impl());                                            ^     reason: inference variable t has incompatible bounds       equality constraints: impl       upper bounds: iface<cap#1>,iface<t>   t type-variable:     t extends iface<t> declared in class acceptor   cap#1 fresh type-variable:     cap#1 extends iface<cap#1> capture of ? 1 error 

in other words, backwards source incompatibility between java 7 , 8. i've gone through incompatibilities between java se 8 , java se 7 list did not found fit problem.

so, bug?

environment:

$ /usr/lib/jvm/java-8-oracle/bin/java -version java version "1.8.0" java(tm) se runtime environment (build 1.8.0-b132) java hotspot(tm) 64-bit server vm (build 25.0-b70, mixed mode) 

thanks report. looks bug. take care of , add better answer once have more information why happening. have filed bug entry jdk-8043926, track it.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -