changeset 20240:1818352eef49

8022567: Javac Should Generate Warnings For Raw Array Type Reviewed-by: jjg
author jlahoda
date Thu, 19 Sep 2013 17:05:08 +0200
parents 3cedbfa2946b
children 1e178dbe29c1
files langtools/src/share/classes/com/sun/tools/javac/comp/Check.java langtools/test/tools/javac/warnings/6747671/T6747671.java langtools/test/tools/javac/warnings/6747671/T6747671.out
diffstat 3 files changed, 23 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu Sep 19 17:05:32 2013 +0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu Sep 19 17:05:08 2013 +0200
@@ -1245,6 +1245,7 @@
      */
     class Validator extends JCTree.Visitor {
 
+        boolean checkRaw;
         boolean isOuter;
         Env<AttrContext> env;
 
@@ -1254,7 +1255,7 @@
 
         @Override
         public void visitTypeArray(JCArrayTypeTree tree) {
-            tree.elemtype.accept(this);
+            validateTree(tree.elemtype, checkRaw, isOuter);
         }
 
         @Override
@@ -1345,15 +1346,20 @@
         }
 
         public void validateTree(JCTree tree, boolean checkRaw, boolean isOuter) {
-            try {
-                if (tree != null) {
-                    this.isOuter = isOuter;
+            if (tree != null) {
+                boolean prevCheckRaw = this.checkRaw;
+                this.checkRaw = checkRaw;
+                this.isOuter = isOuter;
+
+                try {
                     tree.accept(this);
                     if (checkRaw)
                         checkRaw(tree, env);
+                } catch (CompletionFailure ex) {
+                    completionError(tree.pos(), ex);
+                } finally {
+                    this.checkRaw = prevCheckRaw;
                 }
-            } catch (CompletionFailure ex) {
-                completionError(tree.pos(), ex);
             }
         }
 
--- a/langtools/test/tools/javac/warnings/6747671/T6747671.java	Thu Sep 19 17:05:32 2013 +0400
+++ b/langtools/test/tools/javac/warnings/6747671/T6747671.java	Thu Sep 19 17:05:08 2013 +0200
@@ -1,6 +1,6 @@
 /**
  * @test /nodynamiccopyright/
- * @bug 6747671
+ * @bug 6747671 8022567
  * @summary -Xlint:rawtypes
  * @compile/ref=T6747671.out -XDrawDiagnostics -Xlint:rawtypes T6747671.java
  */
@@ -32,4 +32,11 @@
         A a2 = new A() {};//raw warning (2)
         a2.new Z() {};//raw warning
     }
+
+    @TA B @TA[] arr = new @TA B @TA [0];//JDK-8022567: raw warning (2)
+    Class<B[]> classes1;//no warning
+    Class<B>[] classes2;//no warning
+
+    @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE_USE)
+    @interface TA { }
 }
--- a/langtools/test/tools/javac/warnings/6747671/T6747671.out	Thu Sep 19 17:05:32 2013 +0400
+++ b/langtools/test/tools/javac/warnings/6747671/T6747671.out	Thu Sep 19 17:05:08 2013 +0200
@@ -7,4 +7,6 @@
 T6747671.java:32:9: compiler.warn.raw.class.use: T6747671.A, T6747671<E>.A<X>
 T6747671.java:32:20: compiler.warn.raw.class.use: T6747671.A, T6747671<E>.A<X>
 T6747671.java:33:16: compiler.warn.raw.class.use: T6747671.A.Z, T6747671<E>.A<X>.Z<Y>
-9 warnings
+T6747671.java:36:9: compiler.warn.raw.class.use: @T6747671.TA T6747671.B, T6747671.B<X>
+T6747671.java:36:27: compiler.warn.raw.class.use: T6747671.B, T6747671.B<X>
+11 warnings