-
Bug
-
Resolution: Fixed
-
P3
-
21, 22
-
b20
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8323208 | 21.0.3-oracle | Vicente Arturo Romero Zaldivar | P3 | Resolved | Fixed | b02 |
JDK-8322395 | 21.0.3 | Aleksey Shipilev | P3 | Resolved | Fixed | b01 |
javac crashes on the following invalid input when annotation processing is enabled.
The correct error is reported with annotation processing disabled:
T.java:4: error: missing method body, or declare abstract
T(String one);
^
=== P.java
import java.util.Set;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.TypeElement;
@SupportedAnnotationTypes("*")
public class P extends AbstractProcessor {
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latestSupported();
}
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
return false;
}
}
=== T.java
enum T {
ONE("");
T(String one);
final String one;
}
===
$ javac P.java
$ javac -fullversion -processor P T.java
javac full version "21-ea+17-1421"
An exception has occurred in the compiler (21-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.
java.lang.NullPointerException: Cannot read field "stats" because "node.body" is null
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$1.visitMethodDef(JavacProcessingEnvironment.java:1648)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:912)
at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$1.scan(JavacPro
The correct error is reported with annotation processing disabled:
T.java:4: error: missing method body, or declare abstract
T(String one);
^
=== P.java
import java.util.Set;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.TypeElement;
@SupportedAnnotationTypes("*")
public class P extends AbstractProcessor {
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latestSupported();
}
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
return false;
}
}
=== T.java
enum T {
ONE("");
T(String one);
final String one;
}
===
$ javac P.java
$ javac -fullversion -processor P T.java
javac full version "21-ea+17-1421"
An exception has occurred in the compiler (21-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.
java.lang.NullPointerException: Cannot read field "stats" because "node.body" is null
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$1.visitMethodDef(JavacProcessingEnvironment.java:1648)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:912)
at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$1.scan(JavacPro
- backported by
-
JDK-8322395 NPE in JavacProcessingEnvironment for missing enum constructor body
- Resolved
-
JDK-8323208 NPE in JavacProcessingEnvironment for missing enum constructor body
- Resolved
- links to
-
Commit openjdk/jdk21u-dev/af6df774
-
Commit openjdk/jdk/01ea1eff
-
Review openjdk/jdk21u-dev/25
-
Review openjdk/jdk/15974
(1 links to)