-
Bug
-
Resolution: Unresolved
-
P2
-
None
-
24, 25
The following program crashes javac on JDK 24 and newer, previous versions correctly report an error for the invalid input.
The reproducer was minimized by my colleage Liz Looney.
```
import java.lang.System.Logger.Level;
import java.lang.Thread.State;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
public final class ShowJavacBug {
private static final Consumer<String> A_CONSUMER = null;
private static final Supplier<String> B_SUPPLIER = null;
private static final Consumer<String> C_CONSUMER = null;
private final List<String> items = new ArrayList<>();
public void getItems() {
items.stream()
.filter(
buildPredicate(
String.class,
A_CONSUMER,
// Missing: B_SUPPLIER,
C_CONSUMER,
buildSupplier(
// Missing: String.class,
State.class, Level.class, (State state) -> Level.ALL)));
}
private static <T> Predicate<T> buildPredicate(
Class<T> tClass,
Consumer<T> aConsumer,
Supplier<T> bSupplier,
Consumer<T> cConsumer,
Supplier<T> dSupplier) {
return null;
}
private static <T, A, B> Supplier<String> buildSupplier(
Class<T> tClass, Class<A> aClass, Class<B> bClass, Function<A, B> function) {
return null;
}
}
```
$ javac -fullversion -XDdev ShowJavacBug.java
javac full version "23.0.2+7-58"
ShowJavacBug.java:20: error: incompatible types: cannot infer type-variable(s) T
buildPredicate(
^
(argument mismatch; Consumer<String> cannot be converted to Supplier<T>)
where T is a type-variable:
T extends Object declared in method <T>buildPredicate(Class<T>,Consumer<T>,Supplier<T>,Consumer<T>,Supplier<T>)
1 error
$ javac -fullversion -XDdev ShowJavacBug.java
javac full version "25-ea+34-3482"
An exception has occurred in the compiler (25-ea). Please file a bug against the Java compiler via the Java bug reporting page (https://bugreport.java.com) after checking the Bug Database (https://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
com.sun.tools.javac.comp.Resolve$AbstractMethodCheck$SharedInapplicableMethodException
at jdk.compiler/com.sun.tools.javac.comp.Resolve$AbstractMethodCheck.getMethodCheckFailure(Resolve.java:875)
at jdk.compiler/com.sun.tools.javac.comp.Resolve$AbstractMethodCheck.reportMC(Resolve.java:847)
at jdk.compiler/com.sun.tools.javac.comp.Resolve$4$1.report(Resolve.java:961)
at jdk.compiler/com.sun.tools.javac.comp.Attr.checkMethod(Attr.java:4992)
at jdk.compiler/com.sun.tools.javac.comp.AttrRecover.doRecovery(AttrRecover.java:195)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:753)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:770)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1463)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1136)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:677)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:751)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1244)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:960)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:677)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:751)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:5664)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:5550)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:5365)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attrib(Attr.java:5302)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1346)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:968)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:319)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:178)
at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:66)
at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:52)
The reproducer was minimized by my colleage Liz Looney.
```
import java.lang.System.Logger.Level;
import java.lang.Thread.State;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
public final class ShowJavacBug {
private static final Consumer<String> A_CONSUMER = null;
private static final Supplier<String> B_SUPPLIER = null;
private static final Consumer<String> C_CONSUMER = null;
private final List<String> items = new ArrayList<>();
public void getItems() {
items.stream()
.filter(
buildPredicate(
String.class,
A_CONSUMER,
// Missing: B_SUPPLIER,
C_CONSUMER,
buildSupplier(
// Missing: String.class,
State.class, Level.class, (State state) -> Level.ALL)));
}
private static <T> Predicate<T> buildPredicate(
Class<T> tClass,
Consumer<T> aConsumer,
Supplier<T> bSupplier,
Consumer<T> cConsumer,
Supplier<T> dSupplier) {
return null;
}
private static <T, A, B> Supplier<String> buildSupplier(
Class<T> tClass, Class<A> aClass, Class<B> bClass, Function<A, B> function) {
return null;
}
}
```
$ javac -fullversion -XDdev ShowJavacBug.java
javac full version "23.0.2+7-58"
ShowJavacBug.java:20: error: incompatible types: cannot infer type-variable(s) T
buildPredicate(
^
(argument mismatch; Consumer<String> cannot be converted to Supplier<T>)
where T is a type-variable:
T extends Object declared in method <T>buildPredicate(Class<T>,Consumer<T>,Supplier<T>,Consumer<T>,Supplier<T>)
1 error
$ javac -fullversion -XDdev ShowJavacBug.java
javac full version "25-ea+34-3482"
An exception has occurred in the compiler (25-ea). Please file a bug against the Java compiler via the Java bug reporting page (https://bugreport.java.com) after checking the Bug Database (https://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
com.sun.tools.javac.comp.Resolve$AbstractMethodCheck$SharedInapplicableMethodException
at jdk.compiler/com.sun.tools.javac.comp.Resolve$AbstractMethodCheck.getMethodCheckFailure(Resolve.java:875)
at jdk.compiler/com.sun.tools.javac.comp.Resolve$AbstractMethodCheck.reportMC(Resolve.java:847)
at jdk.compiler/com.sun.tools.javac.comp.Resolve$4$1.report(Resolve.java:961)
at jdk.compiler/com.sun.tools.javac.comp.Attr.checkMethod(Attr.java:4992)
at jdk.compiler/com.sun.tools.javac.comp.AttrRecover.doRecovery(AttrRecover.java:195)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:753)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:770)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1463)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1136)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:677)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:751)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1244)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:960)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:677)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:751)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:5664)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:5550)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:5365)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attrib(Attr.java:5302)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1346)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:968)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:319)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:178)
at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:66)
at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:52)
- caused by
-
JDK-8328536 javac - crash on unknown type referenced in yield statement
-
- Resolved
-