changeset 299:fec632145153

further refactoring to TargetType
author Mahmood Ali <mali@csail.mit.edu>
date Sun, 07 Dec 2008 14:50:38 -0500
parents 6a7183f1d29a
children 20f954ba3059
files src/share/classes/com/sun/tools/javac/comp/TargetType.java
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/comp/TargetType.java	Sun Dec 07 10:34:07 2008 -0500
+++ b/src/share/classes/com/sun/tools/javac/comp/TargetType.java	Sun Dec 07 14:50:38 2008 -0500
@@ -141,12 +141,14 @@
     @Deprecated CLASS_TYPE_PARAMETER_GENERIC_OR_ARRAY(0x23, HAS_LOCATION | HAS_PARAMETER),
 
     /** For annotations with an unknown target. */
-    UNKNOWN(0xFF, NO_ATTRIBUTE);
+    UNKNOWN(-1, NO_ATTRIBUTE);
 
-    private final byte targetTypeValue;
+    private final int targetTypeValue;
     private final int flags;
 
     TargetType(int targetTypeValue, int flags) {
+        assert targetTypeValue >= Byte.MIN_VALUE;
+        assert targetTypeValue <= Byte.MAX_VALUE;
         this.targetTypeValue = (byte)targetTypeValue;
         this.flags = flags;
     }
@@ -166,7 +168,7 @@
         if (hasLocation())
             return this;
         else
-            return values()[targetTypeValue() + 1];
+            return fromTargetTypeValue(targetTypeValue() + 1);
     }
 
     /**
@@ -195,9 +197,11 @@
         return this.targetTypeValue;
     }
 
-    public static TargetType fromTargetTypeValue(byte tag) {
+    public static TargetType fromTargetTypeValue(int tag) {
         if (tag == UNKNOWN.targetTypeValue)
             return UNKNOWN;
+        if (tag < 0 || tag >= values().length)
+            throw new IllegalArgumentException("Unknown TargetType: " + tag);
         return values()[tag];
     }