changeset 351:a0b1c1b2efe6

only create annotated types when needed
author mali
date Thu, 19 Feb 2009 16:42:35 -0500
parents 925632235d9b
children f73117585740
files src/share/classes/com/sun/tools/javac/comp/Check.java src/share/classes/com/sun/tools/javac/comp/TransTypes.java src/share/classes/com/sun/tools/javac/parser/JavacParser.java
diffstat 3 files changed, 18 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Tue Feb 10 22:31:31 2009 -0500
+++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu Feb 19 16:42:35 2009 -0500
@@ -892,6 +892,10 @@
             }
         }
 
+        public void visitAnnotatedType(JCAnnotatedType tree) {
+            tree.underlyingType.accept(this);
+        }
+
         /** Default visitor method: do nothing.
          */
         public void visitTree(JCTree tree) {
--- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Tue Feb 10 22:31:31 2009 -0500
+++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Thu Feb 19 16:42:35 2009 -0500
@@ -742,14 +742,17 @@
      */
     public void visitTypeApply(JCTypeApply tree) {
         List<TypeAnnotations> ta = collectErasedAnnotations(tree.arguments);
-        // Delete all type parameters.
-        JCTree clazz = translate(tree.clazz, null);
-        JCAnnotatedType annotatedType =
-            make.at(tree.pos).AnnotatedType(List.<JCAnnotation>nil(),
-                    (JCExpression)clazz);
-        annotatedType.typeAnnotations.erased = ta;
-        result = annotatedType;
-        result.type = clazz.type;
+        if (!ta.isEmpty()) {
+            // Delete all type parameters.
+            JCTree clazz = translate(tree.clazz, null);
+            JCAnnotatedType annotatedType =
+                make.at(tree.pos).AnnotatedType(List.<JCAnnotation>nil(),
+                        (JCExpression)clazz);
+            annotatedType.typeAnnotations.erased = ta;
+            result = annotatedType;
+            result.type = clazz.type;
+        } else
+            result = tree;
     }
 
 /**************************************************************************
--- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Tue Feb 10 22:31:31 2009 -0500
+++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Feb 19 16:42:35 2009 -0500
@@ -606,7 +606,9 @@
         // by an array type, under the ARRAYS convention), wrap the underlying
         // type in a JCAnnotatedType with those annotations.
         if (!typeAnnotations.isEmpty()) {
-            result = F.AnnotatedType(typeAnnotations.next(), result);
+            List<JCAnnotation> annos = typeAnnotations.next();
+            if (!annos.isEmpty())
+                result = F.AnnotatedType(annos, result);
         }
 
         lastmode = mode;