-
Bug
-
Resolution: Fixed
-
P4
-
8u11
-
b31
-
x86_64
-
windows_7
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8085398 | emb-9 | Unassigned | P4 | Resolved | Fixed | team |
JDK-8064059 | 8u45 | Paul Govereau | P4 | Resolved | Fixed | b01 |
JDK-8061314 | 8u40 | Paul Govereau | P4 | Resolved | Fixed | b12 |
JDK-8070279 | emb-8u47 | Unassigned | P4 | Resolved | Fixed | team |
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
It might be related to
ADDITIONAL REGRESSION INFORMATION:
The problem was first observed with EA builds of Java 8 (before official release of jdk8).
I did not have clue what part of code it was but now I know.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile attached code:
javac TooMuchForACompiler.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Code compiles successfully (or produces reasonable error message).
ACTUAL -
NullPointerException in a compiler
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Error message for jdk8u11 (official release)
java.lang.NullPointerException
at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.trackable(Flow.java:1476)
at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.visitVarDef(Flow.java:1801)
at com.sun.tools.javac.comp.Flow$AssignAnalyzer.visitVarDef(Flow.java:2516)
at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:846)
at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:389)
at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scan(Flow.java:1367)
at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.visitLambda(Flow.java:2225)
Error message for jdk8u20 EA:
java.lang.NullPointerException
at com.sun.tools.javac.code.Scope.includes(Scope.java:296)
at com.sun.tools.javac.comp.Flow$1.trackable(Flow.java:247)
at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.visitVarDef(Flow.java:1832)
at com.sun.tools.javac.comp.Flow$AssignAnalyzer.visitVarDef(Flow.java:2569)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.function.Consumer;
public class TooMuchForACompiler {
public interface Supplier<T, E extends Exception> {
T get() throws E;
}
public static <T, E extends Exception> T produceAndConsume(Supplier<T, E> supplier, Consumer<E> handler) {
try {
return supplier.get();
} catch (Exception e) {
handler.accept((E) e);
}
return null;
}
public static void main(String... args) {
produceAndConsume(() -> -1, i -> System.out.println(i.getMessage()));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Assign one of lambdas to a variable.
public static void main(String... args) {
Supplier<Integer, RuntimeException> supplier = () -> -1;
produceAndConsume(supplier, i -> System.out.println(i.getMessage()));
}
- backported by
-
JDK-8061314 NullPointerException when compiling specific code.
-
- Resolved
-
-
JDK-8064059 NullPointerException when compiling specific code.
-
- Resolved
-
-
JDK-8070279 NullPointerException when compiling specific code.
-
- Resolved
-
-
JDK-8085398 NullPointerException when compiling specific code.
-
- Resolved
-
- duplicates
-
JDK-8068368 NullPointerException while compiling with Apache Maven
-
- Closed
-
-
JDK-8059922 NPE in Scope.includes with exception inference
-
- Closed
-
-
JDK-8072580 Information:java: An exception has occurred in the compiler (1.8.0_25)
-
- Closed
-
-
JDK-8165569 Lambdas throwing NPE
-
- Closed
-
-
JDK-8171067 The implementation and usage of ThrowableFunctions causes an internal compiler error
-
- Closed
-
- relates to
-
JDK-8042741 Java 8 compiler throws NullPointerException depending location in source file
-
- Resolved
-