-
Bug
-
Resolution: Duplicate
-
P2
-
None
-
9
-
generic
-
generic
Please refer to the following sample code.
This file can be compiled before jdk 9 b94 (JDK 8 can compile too). It looks a regression in javac (type inference?). I can reproduce on both Linux/mac, so looks to be OS independent.
I saw a bunch of changes on javac were integrated in jdk 9 b94. The following items may be related:
JDK-8067767
JDK-8046685
JDK-8142931
import java.util.stream.Stream;
public class TypeInfer {
public static <E extends Exception> void perform(Func<? extends E>... args) throws E {
perform(Stream.of(args));
}
public static <E extends Exception> void perform(Func<? extends E> args) throws E {
perform(Stream.of(args));
}
public static <E extends Exception> void perform(Stream<Func<? extends E>> list) throws E {
}
public interface Func<E extends Exception> {
void func();// throws E;
}
}
Javac output with jdk 9 after b94:
TypeInfer.java:4: error: unreported exception Exception; must be caught or declared to be thrown
perform(Stream.of(args));
^
Note: TypeInfer.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
2 warnings
This file can be compiled before jdk 9 b94 (JDK 8 can compile too). It looks a regression in javac (type inference?). I can reproduce on both Linux/mac, so looks to be OS independent.
I saw a bunch of changes on javac were integrated in jdk 9 b94. The following items may be related:
import java.util.stream.Stream;
public class TypeInfer {
public static <E extends Exception> void perform(Func<? extends E>... args) throws E {
perform(Stream.of(args));
}
public static <E extends Exception> void perform(Func<? extends E> args) throws E {
perform(Stream.of(args));
}
public static <E extends Exception> void perform(Stream<Func<? extends E>> list) throws E {
}
public interface Func<E extends Exception> {
void func();// throws E;
}
}
Javac output with jdk 9 after b94:
TypeInfer.java:4: error: unreported exception Exception; must be caught or declared to be thrown
perform(Stream.of(args));
^
Note: TypeInfer.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
2 warnings
- duplicates
-
JDK-8160244 skip capture conversion before subtyping if types are parameterizations of the same class or interface
- Open