changeset 356:60eefa3207d5

1. properly validate all type annotations 2. support ElementKind.TYPE_PARAMETER
author mali
date Fri, 27 Feb 2009 12:02:15 -0500
parents f7d2ff026493
children 0251523b778d
files src/share/classes/com/sun/tools/javac/comp/Attr.java src/share/classes/com/sun/tools/javac/comp/Check.java src/share/classes/com/sun/tools/javac/util/Names.java src/share/classes/java/lang/annotation/ElementType.java test/tools/javac/typeAnnotations/MultipleTargets.java test/tools/javac/typeAnnotations/TypeParameterTarget.java test/tools/javac/typeAnnotations/TypeUseTarget.java test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateAnnotationValue.java test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.java test/tools/javac/typeAnnotations/failures/common/typeArgs/InvalidLocation.java test/tools/javac/typeAnnotations/failures/common/typeArgs/MissingAnnotationValue.java test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateAnnotationValue.java test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.java test/tools/javac/typeAnnotations/failures/common/wildcards/InvalidLocation.java test/tools/javac/typeAnnotations/failures/common/wildcards/MissingAnnotationValue.java test/tools/javac/typeAnnotations/failures/target/NotTypeParameter.java test/tools/javac/typeAnnotations/failures/target/NotTypeUse.java
diffstat 17 files changed, 426 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Fri Feb 27 11:58:51 2009 -0500
+++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Fri Feb 27 12:02:15 2009 -0500
@@ -687,8 +687,6 @@
             localEnv.info.scope.leave();
             result = tree.type = m.type;
             chk.validateAnnotations(tree.mods.annotations, m);
-            reAttribTypeParameters(tree.typarams);
-            chk.validateTypeAnnotations(tree.receiver.annotations);
         }
         finally {
             chk.setLint(prevLint);
@@ -2520,7 +2518,7 @@
     }
 
     public void visitTypeParameter(JCTypeParameter tree) {
-        chk.validateTypeAnnotations(tree.annotations);
+        chk.validateTypeAnnotations(tree.annotations, true);
         TypeVar a = (TypeVar)tree.type;
         Set<Type> boundSet = new HashSet<Type>();
         if (a.bound.isErroneous())
@@ -2607,7 +2605,6 @@
 
     public void visitAnnotatedType(JCAnnotatedType tree) {
         result = tree.type = attribType(tree.getUnderlyingType(), env);
-        chk.validateTypeAnnotations(tree.annotations);
     }
 
     public void visitErroneous(JCErroneous tree) {
@@ -2721,7 +2718,6 @@
 
         // Validate type parameters, supertype and interfaces.
         attribBounds(tree.typarams);
-        reAttribTypeParameters(tree.typarams);
         chk.validate(tree.typarams, env);
         chk.validate(tree.extending, env);
         chk.validate(tree.implementing, env);
@@ -2799,6 +2795,9 @@
             (c.flags() & ABSTRACT) == 0) {
             checkSerialVersionUID(tree, c);
         }
+
+        // Check type annotations applicability rules
+        validateTypeAnnotations(tree);
     }
         // where
         /** check if a class is a subtype of Serializable, if that is available. */
@@ -2842,26 +2841,17 @@
         return types.capture(type);
     }
 
-    /**
-     * Type parameters are attributed before annotation attribution happens
-     * (and before class bodies are attributed too).  Thus we cannot validate
-     * type annotations on type parameters or their bounds then.
-     *
-     * Thus, we revisit these parameters only during regular attribution
-     * and we only validate the type annotations.
-     */
-    private final void reAttribTypeParameters(List<JCTypeParameter> params) {
-        for (JCTypeParameter typeParam : params)
-            typeParam.accept(typeParameterRevisitor);
+    private final void validateTypeAnnotations(JCTree tree) {
+        tree.accept(typeAnnotationsValidator);
     }
-    private final JCTree.Visitor typeParameterRevisitor =
+    private final JCTree.Visitor typeAnnotationsValidator =
         new TreeScanner() {
         public void visitAnnotatedType(JCAnnotatedType tree) {
-            chk.validateTypeAnnotations(tree.annotations);
+            chk.validateTypeAnnotations(tree.annotations, false);
             super.visitAnnotatedType(tree);
         }
         public void visitTypeParameter(JCTypeParameter tree) {
-            chk.validateTypeAnnotations(tree.annotations);
+            chk.validateTypeAnnotations(tree.annotations, true);
             super.visitTypeParameter(tree);
         }
     };
--- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Fri Feb 27 11:58:51 2009 -0500
+++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Fri Feb 27 12:02:15 2009 -0500
@@ -1784,10 +1784,10 @@
 
     /** Check the type annotations
      */
-    public void validateTypeAnnotations(List<JCAnnotation> annotations) {
+    public void validateTypeAnnotations(List<JCAnnotation> annotations, boolean isTypeParameter) {
         if (skipAnnotations) return;
         for (JCAnnotation a : annotations)
-            validateTypeAnnotation(a);
+            validateTypeAnnotation(a, isTypeParameter);
     }
 
     /** Check an annotation of a symbol.
@@ -1804,7 +1804,7 @@
         }
     }
 
-    public void validateTypeAnnotation(JCAnnotation a) {
+    public void validateTypeAnnotation(JCAnnotation a, boolean isTypeParameter) {
         if (a.type == null) {
             // annotation hasn't been attributed yet
             // TODO: ensure that we call this method eventually
@@ -1812,7 +1812,7 @@
         }
         validateAnnotation(a);
 
-        if (!isTypeAnnotation(a))
+        if (!isTypeAnnotation(a, isTypeParameter))
             log.error(a.pos(), "annotation.type.not.applicable");
     }
 
@@ -1835,7 +1835,7 @@
     }
 
     /** Is the annotation applicable to type annotations */
-    boolean isTypeAnnotation(JCAnnotation a) {
+    boolean isTypeAnnotation(JCAnnotation a, boolean isTypeParameter) {
         Attribute.Compound atTarget =
             a.annotationType.type.tsym.attribute(syms.annotationTargetType.tsym);
         if (atTarget == null) return true;
@@ -1845,7 +1845,9 @@
         for (Attribute app : arr.values) {
             if (!(app instanceof Attribute.Enum)) return true; // recovery
             Attribute.Enum e = (Attribute.Enum) app;
-            if (e.value.name == names.TYPE_USE)
+            if (!isTypeParameter && e.value.name == names.TYPE_USE)
+                return true;
+            else if (isTypeParameter && e.value.name == names.TYPE_PARAMETER)
                 return true;
         }
         return false;
--- a/src/share/classes/com/sun/tools/javac/util/Names.java	Fri Feb 27 11:58:51 2009 -0500
+++ b/src/share/classes/com/sun/tools/javac/util/Names.java	Fri Feb 27 12:02:15 2009 -0500
@@ -115,6 +115,7 @@
     public final Name getClass;
     public final Name TYPE;
     public final Name TYPE_USE;
+    public final Name TYPE_PARAMETER;
     public final Name FIELD;
     public final Name METHOD;
     public final Name PARAMETER;
@@ -224,6 +225,7 @@
 
         TYPE = fromString("TYPE");
         TYPE_USE = fromString("TYPE_USE");
+        TYPE_PARAMETER = fromString("TYPE_PARAMETER");
         FIELD = fromString("FIELD");
         METHOD = fromString("METHOD");
         PARAMETER = fromString("PARAMETER");
--- a/src/share/classes/java/lang/annotation/ElementType.java	Fri Feb 27 11:58:51 2009 -0500
+++ b/src/share/classes/java/lang/annotation/ElementType.java	Fri Feb 27 12:02:15 2009 -0500
@@ -25,6 +25,9 @@
     /** Uses of a type */
     TYPE_USE,
 
+    /** type parameters */
+    TYPE_PARAMETER,
+
     /** Field declaration (includes enum constants) */
     FIELD,
 
--- a/test/tools/javac/typeAnnotations/MultipleTargets.java	Fri Feb 27 11:58:51 2009 -0500
+++ b/test/tools/javac/typeAnnotations/MultipleTargets.java	Fri Feb 27 12:02:15 2009 -0500
@@ -32,7 +32,7 @@
 import java.lang.annotation.Target;
 import java.lang.annotation.ElementType;
 
-class TypeUseTarget<@A K extends @A Object> {
+class TypeUseTarget<K extends @A Object> {
   @A void voidMethod() { }
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/TypeParameterTarget.java	Fri Feb 27 12:02:15 2009 -0500
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @summary check that type annotations may appear on all type parameter
+ * @author Mahmood Ali
+ * @compile TypeParameterTarget.java
+ */
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+class TypeUseTarget<@A K extends Object> {
+  String[] field;
+
+  <@A K, @A V> String genericMethod(K k) { return null; }
+}
+
+interface MyInterface { }
+
+@interface MyAnnotation { }
+
+@Target(ElementType.TYPE_PARAMETER)
+@interface A { }
--- a/test/tools/javac/typeAnnotations/TypeUseTarget.java	Fri Feb 27 11:58:51 2009 -0500
+++ b/test/tools/javac/typeAnnotations/TypeUseTarget.java	Fri Feb 27 12:02:15 2009 -0500
@@ -32,7 +32,7 @@
 import java.lang.annotation.ElementType;
 
 @A
-class TypeUseTarget<@A K extends @A Object> {
+class TypeUseTarget<K extends @A Object> {
   @A String @A [] field;
 
   @A String test(@A String param, @A String @A ... vararg) @A {
@@ -41,7 +41,7 @@
     return (@A String) null;
   }
 
-  <@A K> @A String genericMethod(K k) { return null; }
+  <K> @A String genericMethod(K k) { return null; }
 }
 
 @A
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateAnnotationValue.java	Fri Feb 27 12:02:15 2009 -0500
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @summary check for duplicate annotation values for type parameter
+ * @author Mahmood Ali
+ * @compile/fail DuplicateAnnotationValue.java
+ */
+class DuplicateAnnotationValue<K> {
+  DuplicateAnnotationValue(@A<value = 2, value = 1) String> l;
+}
+
+@interface A { int value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.java	Fri Feb 27 12:02:15 2009 -0500
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @summary check for duplicate annotations
+ * @author Mahmood Ali
+ * @compile/fail DuplicateTypeAnnotation.java
+ */
+
+class DuplicateTypeAnno<K> {
+  DuplicateTypeAnno<@A @A String> l;
+}
+
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/typeArgs/InvalidLocation.java	Fri Feb 27 12:02:15 2009 -0500
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @summary check for invalid annotatins given the target
+ * @author Mahmood Ali
+ * @compile/fail InvalidLocation.java
+ */
+
+class InvalidLocation<K> {
+  InvalidLocation<@A String> l;
+}
+
+@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/typeArgs/MissingAnnotationValue.java	Fri Feb 27 12:02:15 2009 -0500
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @summary check for missing annotation value
+ * @author Mahmood Ali
+ * @compile/fail MissingAnnotationValue.java
+ */
+class MissingAnnotationValue<K> {
+  MissingAnnotationValue<@A String> l;
+}
+
+@interface A { int field(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateAnnotationValue.java	Fri Feb 27 12:02:15 2009 -0500
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @summary check for duplicate annotation values for type parameter
+ * @author Mahmood Ali
+ * @compile/fail DuplicateAnnotationValue.java
+ */
+class DuplicateAnnotationValue<K> {
+  DuplicateAnnotationValue(@A<value = 2, value = 1) ?> l;
+}
+
+@interface A { int value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.java	Fri Feb 27 12:02:15 2009 -0500
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @summary check for duplicate annotations
+ * @author Mahmood Ali
+ * @compile/fail DuplicateTypeAnnotation.java
+ */
+
+class DuplicateTypeAnno<K> {
+  DuplicateTypeAnno<@A @A ?> l;
+}
+
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/wildcards/InvalidLocation.java	Fri Feb 27 12:02:15 2009 -0500
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @summary check for invalid annotatins given the target
+ * @author Mahmood Ali
+ * @compile/fail InvalidLocation.java
+ */
+
+class InvalidLocation<K> {
+  InvalidLocation<@A ?> l;
+}
+
+@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/wildcards/MissingAnnotationValue.java	Fri Feb 27 12:02:15 2009 -0500
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @summary check for missing annotation value
+ * @author Mahmood Ali
+ * @compile/fail MissingAnnotationValue.java
+ */
+class MissingAnnotationValue<K> {
+  MissingAnnotationValue<@A ?> l;
+}
+
+@interface A { int field(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/target/NotTypeParameter.java	Fri Feb 27 12:02:15 2009 -0500
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @summary test invalid location of TypeUse
+ * @author Mahmood Ali
+ * @compile/fail NotTypeParameter.java
+ */
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+class VoidMethod<@A K> {
+  @A void test() { }
+}
+
+@Target(ElementType.TYPE_USE)
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/target/NotTypeUse.java	Fri Feb 27 12:02:15 2009 -0500
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @summary test invalid location of TypeUse
+ * @author Mahmood Ali
+ * @compile/fail NotTypeUse.java
+ */
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+class VoidMethod {
+  @A void test() { }
+}
+
+@Target(ElementType.TYPE)
+@interface A { }