changeset 2263:4e9f487137b9

T8008751: type-annotation on array level in nested class results in NPE. This seems to happen during a deferred Attr. Guard against NPEs. Is there a nicer way to check for deferred Attr and stop work sooner?
author wmdietl
date Sat, 23 Feb 2013 23:09:34 -0800
parents 09b9ea06bc9a
children de1519daf492
files src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java	Sat Feb 23 19:15:52 2013 -0800
+++ b/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java	Sat Feb 23 23:09:34 2013 -0800
@@ -825,6 +825,11 @@
                         // not care about inner types.
                         JCAnnotatedType atypetree = (JCAnnotatedType) frame;
                         final Type utype = atypetree.underlyingType.type;
+                        if (utype == null) {
+                            // This might happen during DeferredAttr;
+                            // we will be back later.
+                            return;
+                        }
                         Symbol tsym = utype.tsym;
                         if (tsym.getKind().equals(ElementKind.TYPE_PARAMETER) ||
                                 utype.getKind().equals(TypeKind.WILDCARD) ||
@@ -1154,7 +1159,11 @@
         private static void setTypeAnnotationPos(List<JCAnnotation> annotations,
                 TypeAnnotationPosition position) {
             for (JCAnnotation anno : annotations) {
-                ((Attribute.TypeCompound) anno.attribute).position = position;
+                // attribute might be null during DeferredAttr;
+                // we will be back later.
+                if (anno.attribute != null) {
+                    ((Attribute.TypeCompound) anno.attribute).position = position;
+                }
             }
         }
     }