changeset 19491:887e13b16ccf

6983297: methods missing from NewArrayTree Reviewed-by: jjg
author vromero
date Sat, 10 Aug 2013 16:29:26 +0100
parents f6eae37b568d
children 767d7330011f
files langtools/src/share/classes/com/sun/source/tree/NewArrayTree.java langtools/src/share/classes/com/sun/source/util/TreeScanner.java langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java langtools/test/tools/javac/tree/SourceTreeScannerTest.java
diffstat 4 files changed, 17 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/langtools/src/share/classes/com/sun/source/tree/NewArrayTree.java	Sat Aug 10 16:26:50 2013 +0100
+++ b/langtools/src/share/classes/com/sun/source/tree/NewArrayTree.java	Sat Aug 10 16:29:26 2013 +0100
@@ -25,7 +25,7 @@
 
 package com.sun.source.tree;
 
-import java.util.List;
+import com.sun.tools.javac.util.List;
 
 /**
  * A tree node for an expression to create a new instance of an array.
@@ -48,4 +48,6 @@
     Tree getType();
     List<? extends ExpressionTree> getDimensions();
     List<? extends ExpressionTree> getInitializers();
+    List<? extends AnnotationTree> getAnnotations();
+    List<? extends List<? extends AnnotationTree>> getDimAnnotations();
 }
--- a/langtools/src/share/classes/com/sun/source/util/TreeScanner.java	Sat Aug 10 16:26:50 2013 +0100
+++ b/langtools/src/share/classes/com/sun/source/util/TreeScanner.java	Sat Aug 10 16:29:26 2013 +0100
@@ -285,6 +285,10 @@
         R r = scan(node.getType(), p);
         r = scanAndReduce(node.getDimensions(), p, r);
         r = scanAndReduce(node.getInitializers(), p, r);
+        r = scanAndReduce(node.getAnnotations(), p, r);
+        for (Iterable< ? extends Tree> dimAnno : node.getDimAnnotations()) {
+            r = scanAndReduce(dimAnno, p, r);
+        }
         return r;
     }
 
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Sat Aug 10 16:26:50 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Sat Aug 10 16:29:26 2013 +0100
@@ -1571,6 +1571,16 @@
         public Tag getTag() {
             return NEWARRAY;
         }
+
+        @Override
+        public List<JCAnnotation> getAnnotations() {
+            return annotations;
+        }
+
+        @Override
+        public List<List<JCAnnotation>> getDimAnnotations() {
+            return dimAnnotations;
+        }
     }
 
     /**
--- a/langtools/test/tools/javac/tree/SourceTreeScannerTest.java	Sat Aug 10 16:26:50 2013 +0100
+++ b/langtools/test/tools/javac/tree/SourceTreeScannerTest.java	Sat Aug 10 16:29:26 2013 +0100
@@ -140,13 +140,6 @@
                         // not part of public API
                         continue;
                     }
-                    if (JCTree.JCNewArray.class.isAssignableFrom(tree.getClass())
-                            && (f.getName().equals("annotations")
-                                || f.getName().equals("dimAnnotations"))) {
-                        // these fields are incorrectly missing from the public API
-                        // (CR 6983297)
-                        continue;
-                    }
                     try {
                         //System.err.println("FIELD: " + f.getName());
                         reflectiveScan(f.get(tree));