提交 0794c1ee 编写于 作者: J jfranck

8062359: javac Attr crashes with NPE in TypeAnnotationsValidator visitNewClass

Reviewed-by: jlahoda, vromero
上级 88bafb52
......@@ -4503,14 +4503,15 @@ public class Attr extends JCTree.Visitor {
super.visitTypeTest(tree);
}
public void visitNewClass(JCNewClass tree) {
if (tree.clazz.hasTag(ANNOTATED_TYPE)) {
checkForDeclarationAnnotations(((JCAnnotatedType) tree.clazz).annotations,
tree.clazz.type.tsym);
}
if (tree.def != null) {
checkForDeclarationAnnotations(tree.def.mods.annotations, tree.clazz.type.tsym);
}
if (tree.clazz.type != null) {
if (tree.clazz != null && tree.clazz.type != null) {
if (tree.clazz.hasTag(ANNOTATED_TYPE)) {
checkForDeclarationAnnotations(((JCAnnotatedType) tree.clazz).annotations,
tree.clazz.type.tsym);
}
if (tree.def != null) {
checkForDeclarationAnnotations(tree.def.mods.annotations, tree.clazz.type.tsym);
}
validateAnnotatedType(tree.clazz, tree.clazz.type);
}
super.visitNewClass(tree);
......
/*
* @test /nodynamiccopyright/
* @bug 8062359
* @summary NullPointerException in Attr when type-annotating an anonymous
* inner class in an unresolvable class
* @compile/fail/ref=UnresolvableClassNPEInAttrTest.out -XDrawDiagnostics UnresolvableClassNPEInAttrTest.java
*/
public class UnresolvableClassNPEInAttrTest {
public static void main(String[] args) {
new Undefined() {
void test() {
new Object() {};
}
};
}
}
UnresolvableClassNPEInAttrTest.java:11:13: compiler.err.cant.resolve.location: kindname.class, Undefined, , , (compiler.misc.location: kindname.class, UnresolvableClassNPEInAttrTest, null)
1 error
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册