-
Bug
-
Resolution: Duplicate
-
P3
-
11, 12, 13, 14
ADDITIONAL SYSTEM INFORMATION :
I don't think any of this is relevant. but
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.2 LTS"
NAME="Ubuntu"
VERSION="18.04.2 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.2 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
Linux bruce-VirtualBox 4.15.0-52-generic #56-Ubuntu SMP Tue Jun 4 22:49:08 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
(ubuntu running on virtualbox on Windows 10 enterprise host)
java version "12.0.1" 2019-04-16
Java(TM) SE Runtime Environment (build 12.0.1+12)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)
(also openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment (build 11.0.3+7-Ubuntu-1ubuntu218.04.1)
OpenJDK 64-Bit Server VM (build 11.0.3+7-Ubuntu-1ubuntu218.04.1, mixed mode)
)
but not on java version "1.8.0_192"
Java(TM) SE Runtime Environment (build 1.8.0_192-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.192-b12, mixed mode)
A DESCRIPTION OF THE PROBLEM :
Compiling code containing an anonymous class declaration with undefined superclass, used as an argument to a method call with an undefined target, which itself is an argument to a (known) method call and with the -Xlint:all option causes javac to throw a NullPointerException in jdk.compiler/com.sun.tools.javac.comp.Check.checkClassOverrideEqualsAndHash()
REGRESSION : Last worked in version 8u192
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac '-Xlint:all' JavacNpeInducer.java
with JavacNpeInducer.java as per 'Source code for an executable test case' below.
The this.equals() method call specifically is not required though some method call is. Originally it was List.add() but this.equals() also causes the failure and means no imports are required in the code.
The key cause seems to be -Xlint:all and an anonymous class declaration with undefined superclass, used as an argument to a method with an undefined target, which itself is an argument to a (known) method call.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
from java 1.8_192
src/JavacNpeInducer.java:4: error: cannot find symbol
undefined_SYMBOL.someMethod(new UndefinedClass() {})
^
symbol: class UndefinedClass
location: class JavacNpeInducer
src/JavacNpeInducer.java:4: error: cannot find symbol
undefined_SYMBOL.someMethod(new UndefinedClass() {})
^
symbol: variable undefined_SYMBOL
location: class JavacNpeInducer
2 errors
ACTUAL -
An exception has occurred in the compiler (12.0.1). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.NullPointerException
at jdk.compiler/com.sun.tools.javac.comp.Check.checkClassOverrideEqualsAndHash(Check.java:2090)
at jdk.compiler/com.sun.tools.javac.comp.Check.checkClassOverrideEqualsAndHashIfNeeded(Check.java:2080)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4778)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4704)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitClassDef(Attr.java:964)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:780)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:664)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:737)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitAnonymousClassDefinition(Attr.java:2582)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitNewClass(Attr.java:2473)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1764)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:664)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.visitNewClass(ArgumentAttr.java:328)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1764)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.attribArg(ArgumentAttr.java:199)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:662)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribArgs(Attr.java:764)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:2182)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1709)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:664)
at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:501)
at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:484)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.lambda$processArg$0(ArgumentAttr.java:222)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.processArg(ArgumentAttr.java:244)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.processArg(ArgumentAttr.java:221)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.visitApply(ArgumentAttr.java:315)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1709)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.attribArg(ArgumentAttr.java:199)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:662)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribArgs(Attr.java:764)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:2182)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1709)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:664)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:715)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1860)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1519)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:664)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:737)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:756)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1307)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1026)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:664)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:737)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1111)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:872)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:664)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:737)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4884)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4775)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4704)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attrib(Attr.java:4649)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1341)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:311)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:170)
at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)
(also for 11.0.3)
---------- BEGIN SOURCE ----------
public class JavacNpeInducer {
public void aMethod() {
this.equals(
undefined_SYMBOL.someMethod(new UndefinedClass() {})
);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
1/ Fix the imports in the code so that the symbols are no longer undefined.
2/ Or don't compile with -Xlint:all
FREQUENCY : always
I don't think any of this is relevant. but
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.2 LTS"
NAME="Ubuntu"
VERSION="18.04.2 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.2 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
Linux bruce-VirtualBox 4.15.0-52-generic #56-Ubuntu SMP Tue Jun 4 22:49:08 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
(ubuntu running on virtualbox on Windows 10 enterprise host)
java version "12.0.1" 2019-04-16
Java(TM) SE Runtime Environment (build 12.0.1+12)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)
(also openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment (build 11.0.3+7-Ubuntu-1ubuntu218.04.1)
OpenJDK 64-Bit Server VM (build 11.0.3+7-Ubuntu-1ubuntu218.04.1, mixed mode)
)
but not on java version "1.8.0_192"
Java(TM) SE Runtime Environment (build 1.8.0_192-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.192-b12, mixed mode)
A DESCRIPTION OF THE PROBLEM :
Compiling code containing an anonymous class declaration with undefined superclass, used as an argument to a method call with an undefined target, which itself is an argument to a (known) method call and with the -Xlint:all option causes javac to throw a NullPointerException in jdk.compiler/com.sun.tools.javac.comp.Check.checkClassOverrideEqualsAndHash()
REGRESSION : Last worked in version 8u192
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac '-Xlint:all' JavacNpeInducer.java
with JavacNpeInducer.java as per 'Source code for an executable test case' below.
The this.equals() method call specifically is not required though some method call is. Originally it was List.add() but this.equals() also causes the failure and means no imports are required in the code.
The key cause seems to be -Xlint:all and an anonymous class declaration with undefined superclass, used as an argument to a method with an undefined target, which itself is an argument to a (known) method call.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
from java 1.8_192
src/JavacNpeInducer.java:4: error: cannot find symbol
undefined_SYMBOL.someMethod(new UndefinedClass() {})
^
symbol: class UndefinedClass
location: class JavacNpeInducer
src/JavacNpeInducer.java:4: error: cannot find symbol
undefined_SYMBOL.someMethod(new UndefinedClass() {})
^
symbol: variable undefined_SYMBOL
location: class JavacNpeInducer
2 errors
ACTUAL -
An exception has occurred in the compiler (12.0.1). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.NullPointerException
at jdk.compiler/com.sun.tools.javac.comp.Check.checkClassOverrideEqualsAndHash(Check.java:2090)
at jdk.compiler/com.sun.tools.javac.comp.Check.checkClassOverrideEqualsAndHashIfNeeded(Check.java:2080)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4778)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4704)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitClassDef(Attr.java:964)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:780)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:664)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:737)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitAnonymousClassDefinition(Attr.java:2582)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitNewClass(Attr.java:2473)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1764)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:664)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.visitNewClass(ArgumentAttr.java:328)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1764)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.attribArg(ArgumentAttr.java:199)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:662)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribArgs(Attr.java:764)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:2182)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1709)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:664)
at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:501)
at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:484)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.lambda$processArg$0(ArgumentAttr.java:222)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.processArg(ArgumentAttr.java:244)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.processArg(ArgumentAttr.java:221)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.visitApply(ArgumentAttr.java:315)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1709)
at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.attribArg(ArgumentAttr.java:199)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:662)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribArgs(Attr.java:764)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:2182)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1709)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:664)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:715)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1860)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1519)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:664)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:737)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:756)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1307)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1026)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:664)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:737)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1111)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:872)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:664)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:737)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4884)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4775)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4704)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attrib(Attr.java:4649)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1341)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:311)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:170)
at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)
(also for 11.0.3)
---------- BEGIN SOURCE ----------
public class JavacNpeInducer {
public void aMethod() {
this.equals(
undefined_SYMBOL.someMethod(new UndefinedClass() {})
);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
1/ Fix the imports in the code so that the symbols are no longer undefined.
2/ Or don't compile with -Xlint:all
FREQUENCY : always
- duplicates
-
JDK-8242802 javac crashes when checking equals and hashCode in unresolvable anonymous class
- Resolved
- relates to
-
JDK-8197439 Crash with -XDfind=lambda for anonymous class in anonymous class.
- Resolved
-
JDK-8009138 javac, equals-hashCode warning tuning
- Closed