8062359: javac Attr crashes with NPE in TypeAnnotationsValidator visitNewClass
Reviewed-by: jlahoda, vromero
This commit is contained in:
parent
56e39629eb
commit
8bf55955df
@ -4490,14 +4490,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);
|
||||
|
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* @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() {};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
UnresolvableClassNPEInAttrTest.java:11:13: compiler.err.cant.resolve.location: kindname.class, Undefined, , , (compiler.misc.location: kindname.class, UnresolvableClassNPEInAttrTest, null)
|
||||
1 error
|
Loading…
x
Reference in New Issue
Block a user