changeset 1954:bf0c0c96388b

Allow TYPE_USE annotations on type parameter declarations.
author wmdietl
date Mon, 10 Dec 2012 15:03:06 -0800
parents cb7b7f789075
children 0b508089c9c5
files src/share/classes/com/sun/tools/javac/comp/Check.java test/tools/javac/annotations/typeAnnotations/failures/target/NotTypeParameter.java test/tools/javac/annotations/typeAnnotations/failures/target/NotTypeParameter.out test/tools/javac/annotations/typeAnnotations/newlocations/TypeParameters.java
diffstat 4 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Mon Dec 10 04:30:37 2012 -0800
+++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Mon Dec 10 15:03:06 2012 -0800
@@ -2877,7 +2877,7 @@
     }
 
     /** Is the annotation applicable to type annotations? */
-    boolean isTypeAnnotation(JCAnnotation a, boolean isTypeParameter) {
+    protected boolean isTypeAnnotation(JCAnnotation a, boolean isTypeParameter) {
         Attribute.Compound atTarget =
             a.annotationType.type.tsym.attribute(syms.annotationTargetType.tsym);
         if (atTarget == null) {
@@ -2897,7 +2897,7 @@
             }
             Attribute.Enum e = (Attribute.Enum) app;
 
-            if (!isTypeParameter && e.value.name == names.TYPE_USE)
+            if (e.value.name == names.TYPE_USE)
                 return true;
             else if (isTypeParameter && e.value.name == names.TYPE_PARAMETER)
                 return true;
--- a/test/tools/javac/annotations/typeAnnotations/failures/target/NotTypeParameter.java	Mon Dec 10 04:30:37 2012 -0800
+++ b/test/tools/javac/annotations/typeAnnotations/failures/target/NotTypeParameter.java	Mon Dec 10 15:03:06 2012 -0800
@@ -16,7 +16,7 @@
 @Target(ElementType.TYPE_USE)
 @interface A { }
 
-class TypeVariable<T> {
+class TypeVariable<@B T> {
   @B T test1() { return null; }
   void test2(@B T p) {}
 }
--- a/test/tools/javac/annotations/typeAnnotations/failures/target/NotTypeParameter.out	Mon Dec 10 04:30:37 2012 -0800
+++ b/test/tools/javac/annotations/typeAnnotations/failures/target/NotTypeParameter.out	Mon Dec 10 15:03:06 2012 -0800
@@ -1,5 +1,4 @@
 NotTypeParameter.java:13:3: compiler.err.annotation.type.not.applicable
-NotTypeParameter.java:12:18: compiler.err.annotation.type.not.applicable
 NotTypeParameter.java:20:3: compiler.err.annotation.type.not.applicable
 NotTypeParameter.java:21:14: compiler.err.annotation.type.not.applicable
-4 errors
+3 errors
--- a/test/tools/javac/annotations/typeAnnotations/newlocations/TypeParameters.java	Mon Dec 10 04:30:37 2012 -0800
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/TypeParameters.java	Mon Dec 10 15:03:06 2012 -0800
@@ -48,7 +48,13 @@
 class TwoAnnotatedB<@B("m") K, @B("m") V> { }
 class SecondAnnotatedB<K, @B("m") V extends @B("m") String> { }
 
+class OneAnnotatedC<@C K> { }
+class TwoAnnotatedC<@C K, @C V> { }
+class SecondAnnotatedC<K, @C V extends String> { }
+
 @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
 @interface A { }
 @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
 @interface B { String value(); }
+@Target(ElementType.TYPE_USE)
+@interface C { }