1.1 --- a/src/share/classes/com/sun/tools/javac/code/TargetType.java Fri Jun 26 19:12:41 2009 -0700 1.2 +++ b/src/share/classes/com/sun/tools/javac/code/TargetType.java Fri Jun 26 19:47:12 2009 -0700 1.3 @@ -53,25 +53,25 @@ 1.4 // 1.5 1.6 /** For annotations on typecasts. */ 1.7 - TYPECAST(0x00), 1.8 + TYPECAST(0x00, IsLocal), 1.9 1.10 /** For annotations on a type argument or nested array of a typecast. */ 1.11 - TYPECAST_GENERIC_OR_ARRAY(0x01, HasLocation), 1.12 + TYPECAST_GENERIC_OR_ARRAY(0x01, HasLocation, IsLocal), 1.13 1.14 /** For annotations on type tests. */ 1.15 - INSTANCEOF(0x02), 1.16 + INSTANCEOF(0x02, IsLocal), 1.17 1.18 /** For annotations on a type argument or nested array of a type test. */ 1.19 - INSTANCEOF_GENERIC_OR_ARRAY(0x03, HasLocation), 1.20 + INSTANCEOF_GENERIC_OR_ARRAY(0x03, HasLocation, IsLocal), 1.21 1.22 /** For annotations on object creation expressions. */ 1.23 - NEW(0x04), 1.24 + NEW(0x04, IsLocal), 1.25 1.26 /** 1.27 * For annotations on a type argument or nested array of an object creation 1.28 * expression. 1.29 */ 1.30 - NEW_GENERIC_OR_ARRAY(0x05, HasLocation), 1.31 + NEW_GENERIC_OR_ARRAY(0x05, HasLocation, IsLocal), 1.32 1.33 1.34 /** For annotations on the method receiver. */ 1.35 @@ -81,10 +81,10 @@ 1.36 //@Deprecated METHOD_RECEIVER_GENERIC_OR_ARRAY(0x07, HasLocation), 1.37 1.38 /** For annotations on local variables. */ 1.39 - LOCAL_VARIABLE(0x08), 1.40 + LOCAL_VARIABLE(0x08, IsLocal), 1.41 1.42 /** For annotations on a type argument or nested array of a local. */ 1.43 - LOCAL_VARIABLE_GENERIC_OR_ARRAY(0x09, HasLocation), 1.44 + LOCAL_VARIABLE_GENERIC_OR_ARRAY(0x09, HasLocation, IsLocal), 1.45 1.46 // handled by regular annotations 1.47 //@Deprecated METHOD_RETURN(0x0A), 1.48 @@ -138,17 +138,17 @@ 1.49 //@Deprecated THROWS_GENERIC_OR_ARRAY(0x17, HasLocation), 1.50 1.51 /** For annotations in type arguments of object creation expressions. */ 1.52 - NEW_TYPE_ARGUMENT(0x18), 1.53 - NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY(0x19, HasLocation), 1.54 + NEW_TYPE_ARGUMENT(0x18, IsLocal), 1.55 + NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY(0x19, HasLocation, IsLocal), 1.56 1.57 - METHOD_TYPE_ARGUMENT(0x1A), 1.58 - METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY(0x1B, HasLocation), 1.59 + METHOD_TYPE_ARGUMENT(0x1A, IsLocal), 1.60 + METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY(0x1B, HasLocation, IsLocal), 1.61 1.62 WILDCARD_BOUND(0x1C, HasBound), 1.63 WILDCARD_BOUND_GENERIC_OR_ARRAY(0x1D, HasBound, HasLocation), 1.64 1.65 - CLASS_LITERAL(0x1E), 1.66 - CLASS_LITERAL_GENERIC_OR_ARRAY(0x1F, HasLocation), 1.67 + CLASS_LITERAL(0x1E, IsLocal), 1.68 + CLASS_LITERAL_GENERIC_OR_ARRAY(0x1F, HasLocation, IsLocal), 1.69 1.70 METHOD_TYPE_PARAMETER(0x20, HasParameter), 1.71 1.72 @@ -218,6 +218,17 @@ 1.73 return flags.contains(HasBound); 1.74 } 1.75 1.76 + /** 1.77 + * Returns whether or not this TargetType represents an annotation whose 1.78 + * target is exclusively a tree in a method body 1.79 + * 1.80 + * Note: wildcard bound targets could target a local tree and a class 1.81 + * member declaration signature tree 1.82 + */ 1.83 + public boolean isLocal() { 1.84 + return flags.contains(IsLocal); 1.85 + } 1.86 + 1.87 public int targetTypeValue() { 1.88 return this.targetTypeValue; 1.89 } 1.90 @@ -261,6 +272,6 @@ 1.91 } 1.92 1.93 static enum TargetAttribute { 1.94 - HasLocation, HasParameter, HasBound; 1.95 + HasLocation, HasParameter, HasBound, IsLocal; 1.96 } 1.97 }