The following program crashes the compiler if compiled with -Xlint:unchecked
class Test {
Object o = new Object() {
<Z> void m (Class<Z> x) {}
void test() {
m((Class)null);
}
};
}
Here's the stack-trace:
java.lang.NullPointerException
at com.sun.tools.javac.code.Kinds.kindName(Kinds.java:144)
at com.sun.tools.javac.comp.Attr.checkMethod(Attr.java:2415)
at com.sun.tools.javac.comp.Attr.checkId(Attr.java:2188)
at com.sun.tools.javac.comp.Attr.visitIdent(Attr.java:1860)
at com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:1687)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:379)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:396)
at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1304)
at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1299)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:379)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:403)
at com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1079)
at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1145)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:379)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:416)
at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:432)
at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:777)
at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:768)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:379)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:416)
at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:698)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:655)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:379)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:416)
at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:2795)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2721)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2657)
at com.sun.tools.javac.comp.Attr.visitClassDef(Attr.java:589)
at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:584)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:379)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:416)
at com.sun.tools.javac.comp.Attr.visitNewClass(Attr.java:1539)
at com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1350)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:379)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:396)
at com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:746)
at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:712)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:379)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:416)
at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:2795)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2721)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2657)
at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1122)
at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:848)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:810)
at com.sun.tools.javac.main.Main.compile(Main.java:400)
at com.sun.tools.javac.main.Main.compile(Main.java:318)
at com.sun.tools.javac.main.Main.compile(Main.java:309)
at com.sun.tools.javac.Main.compile(Main.java:82)
at com.sun.tools.javac.Main.main(Main.java:67)
class Test {
Object o = new Object() {
<Z> void m (Class<Z> x) {}
void test() {
m((Class)null);
}
};
}
Here's the stack-trace:
java.lang.NullPointerException
at com.sun.tools.javac.code.Kinds.kindName(Kinds.java:144)
at com.sun.tools.javac.comp.Attr.checkMethod(Attr.java:2415)
at com.sun.tools.javac.comp.Attr.checkId(Attr.java:2188)
at com.sun.tools.javac.comp.Attr.visitIdent(Attr.java:1860)
at com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:1687)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:379)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:396)
at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1304)
at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1299)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:379)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:403)
at com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1079)
at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1145)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:379)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:416)
at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:432)
at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:777)
at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:768)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:379)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:416)
at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:698)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:655)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:379)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:416)
at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:2795)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2721)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2657)
at com.sun.tools.javac.comp.Attr.visitClassDef(Attr.java:589)
at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:584)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:379)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:416)
at com.sun.tools.javac.comp.Attr.visitNewClass(Attr.java:1539)
at com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1350)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:379)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:396)
at com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:746)
at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:712)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:379)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:416)
at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:2795)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2721)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2657)
at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1122)
at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:848)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:810)
at com.sun.tools.javac.main.Main.compile(Main.java:400)
at com.sun.tools.javac.main.Main.compile(Main.java:318)
at com.sun.tools.javac.main.Main.compile(Main.java:309)
at com.sun.tools.javac.Main.compile(Main.java:82)
at com.sun.tools.javac.Main.main(Main.java:67)