src/share/classes/com/sun/tools/classfile/TypeAnnotation.java

changeset 1571
af8417e590f4
parent 1563
bc456436c613
child 1755
ddb4a2bfcd82
     1.1 --- a/src/share/classes/com/sun/tools/classfile/TypeAnnotation.java	Mon Feb 04 18:08:53 2013 -0500
     1.2 +++ b/src/share/classes/com/sun/tools/classfile/TypeAnnotation.java	Sun Feb 17 16:44:55 2013 -0500
     1.3 @@ -86,12 +86,13 @@
     1.4          position.type = type;
     1.5  
     1.6          switch (type) {
     1.7 -        // type cast
     1.8 -        case CAST:
     1.9          // instanceof
    1.10          case INSTANCEOF:
    1.11          // new expression
    1.12          case NEW:
    1.13 +        // constructor/method reference receiver
    1.14 +        case CONSTRUCTOR_REFERENCE:
    1.15 +        case METHOD_REFERENCE:
    1.16              position.offset = cr.readUnsignedShort();
    1.17              break;
    1.18          // local variable
    1.19 @@ -142,9 +143,12 @@
    1.20          case METHOD_FORMAL_PARAMETER:
    1.21              position.parameter_index = cr.readUnsignedByte();
    1.22              break;
    1.23 +        // type cast
    1.24 +        case CAST:
    1.25          // method/constructor/reference type argument
    1.26          case CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT:
    1.27          case METHOD_INVOCATION_TYPE_ARGUMENT:
    1.28 +        case CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT:
    1.29          case METHOD_REFERENCE_TYPE_ARGUMENT:
    1.30              position.offset = cr.readUnsignedShort();
    1.31              position.type_index = cr.readUnsignedByte();
    1.32 @@ -153,10 +157,6 @@
    1.33          case METHOD_RETURN:
    1.34          case FIELD:
    1.35              break;
    1.36 -        // lambda formal parameter
    1.37 -        case LAMBDA_FORMAL_PARAMETER:
    1.38 -            position.parameter_index = cr.readUnsignedByte();
    1.39 -            break;
    1.40          case UNKNOWN:
    1.41              throw new AssertionError("TypeAnnotation: UNKNOWN target type should never occur!");
    1.42          default:
    1.43 @@ -177,13 +177,14 @@
    1.44          int n = 0;
    1.45          n += 1; // TargetType tag is a byte
    1.46          switch (pos.type) {
    1.47 -        // type cast
    1.48 -        case CAST:
    1.49          // instanceof
    1.50          case INSTANCEOF:
    1.51          // new expression
    1.52          case NEW:
    1.53 -            n += 2;
    1.54 +        // constructor/method reference receiver
    1.55 +        case CONSTRUCTOR_REFERENCE:
    1.56 +        case METHOD_REFERENCE:
    1.57 +            n += 2; // offset
    1.58              break;
    1.59          // local variable
    1.60          case LOCAL_VARIABLE:
    1.61 @@ -192,7 +193,7 @@
    1.62              n += 2; // table_length;
    1.63              int table_length = pos.lvarOffset.length;
    1.64              n += 2 * table_length; // offset
    1.65 -            n += 2 * table_length; // length;
    1.66 +            n += 2 * table_length; // length
    1.67              n += 2 * table_length; // index
    1.68              break;
    1.69          // exception parameter
    1.70 @@ -206,7 +207,7 @@
    1.71          // type parameter
    1.72          case CLASS_TYPE_PARAMETER:
    1.73          case METHOD_TYPE_PARAMETER:
    1.74 -            n += 1; // parameter_index;
    1.75 +            n += 1; // parameter_index
    1.76              break;
    1.77          // type parameter bound
    1.78          case CLASS_TYPE_PARAMETER_BOUND:
    1.79 @@ -226,9 +227,12 @@
    1.80          case METHOD_FORMAL_PARAMETER:
    1.81              n += 1; // parameter_index
    1.82              break;
    1.83 +        // type cast
    1.84 +        case CAST:
    1.85          // method/constructor/reference type argument
    1.86          case CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT:
    1.87          case METHOD_INVOCATION_TYPE_ARGUMENT:
    1.88 +        case CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT:
    1.89          case METHOD_REFERENCE_TYPE_ARGUMENT:
    1.90              n += 2; // offset
    1.91              n += 1; // type index
    1.92 @@ -237,10 +241,6 @@
    1.93          case METHOD_RETURN:
    1.94          case FIELD:
    1.95              break;
    1.96 -        // lambda formal parameter
    1.97 -        case LAMBDA_FORMAL_PARAMETER:
    1.98 -            n += 1; // parameter_index
    1.99 -            break;
   1.100          case UNKNOWN:
   1.101              throw new AssertionError("TypeAnnotation: UNKNOWN target type should never occur!");
   1.102          default:
   1.103 @@ -377,12 +377,13 @@
   1.104              sb.append(type);
   1.105  
   1.106              switch (type) {
   1.107 -            // type cast
   1.108 -            case CAST:
   1.109              // instanceof
   1.110              case INSTANCEOF:
   1.111              // new expression
   1.112              case NEW:
   1.113 +            // constructor/method reference receiver
   1.114 +            case CONSTRUCTOR_REFERENCE:
   1.115 +            case METHOD_REFERENCE:
   1.116                  sb.append(", offset = ");
   1.117                  sb.append(offset);
   1.118                  break;
   1.119 @@ -444,9 +445,12 @@
   1.120                  sb.append(", param_index = ");
   1.121                  sb.append(parameter_index);
   1.122                  break;
   1.123 +            // type cast
   1.124 +            case CAST:
   1.125              // method/constructor/reference type argument
   1.126              case CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT:
   1.127              case METHOD_INVOCATION_TYPE_ARGUMENT:
   1.128 +            case CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT:
   1.129              case METHOD_REFERENCE_TYPE_ARGUMENT:
   1.130                  sb.append(", offset = ");
   1.131                  sb.append(offset);
   1.132 @@ -457,12 +461,6 @@
   1.133              case METHOD_RETURN:
   1.134              case FIELD:
   1.135                  break;
   1.136 -            // lambda formal parameter
   1.137 -            case LAMBDA_FORMAL_PARAMETER:
   1.138 -                // TODO: also needs an offset?
   1.139 -                sb.append(", param_index = ");
   1.140 -                sb.append(parameter_index);
   1.141 -                break;
   1.142              case UNKNOWN:
   1.143                  sb.append(", position UNKNOWN!");
   1.144                  break;
   1.145 @@ -564,34 +562,37 @@
   1.146          /** For annotations on an exception parameter. */
   1.147          EXCEPTION_PARAMETER(0x42, true),
   1.148  
   1.149 -        /** For annotations on a typecast. */
   1.150 -        CAST(0x43, true),
   1.151 -
   1.152          /** For annotations on a type test. */
   1.153 -        INSTANCEOF(0x44, true),
   1.154 +        INSTANCEOF(0x43, true),
   1.155  
   1.156          /** For annotations on an object creation expression. */
   1.157 -        NEW(0x45, true),
   1.158 +        NEW(0x44, true),
   1.159 +
   1.160 +        /** For annotations on a constructor reference receiver. */
   1.161 +        CONSTRUCTOR_REFERENCE(0x45, true),
   1.162 +
   1.163 +        /** For annotations on a method reference receiver. */
   1.164 +        METHOD_REFERENCE(0x46, true),
   1.165 +
   1.166 +        /** For annotations on a typecast. */
   1.167 +        CAST(0x47, true),
   1.168  
   1.169          /** For annotations on a type argument of an object creation expression. */
   1.170 -        CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT(0x46, true),
   1.171 +        CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT(0x48, true),
   1.172  
   1.173          /** For annotations on a type argument of a method call. */
   1.174 -        METHOD_INVOCATION_TYPE_ARGUMENT(0x47, true),
   1.175 +        METHOD_INVOCATION_TYPE_ARGUMENT(0x49, true),
   1.176  
   1.177 -        /** For annotations on a lambda parameter type. */
   1.178 -        LAMBDA_FORMAL_PARAMETER(0x48, true),
   1.179 -
   1.180 -        /** For annotations on a method reference. */
   1.181 -        METHOD_REFERENCE(0x49, true),
   1.182 +        /** For annotations on a type argument of a constructor reference. */
   1.183 +        CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT(0x4A, true),
   1.184  
   1.185          /** For annotations on a type argument of a method reference. */
   1.186 -        METHOD_REFERENCE_TYPE_ARGUMENT(0x50, true),
   1.187 +        METHOD_REFERENCE_TYPE_ARGUMENT(0x4B, true),
   1.188  
   1.189          /** For annotations with an unknown target. */
   1.190          UNKNOWN(0xFF);
   1.191  
   1.192 -        private static final int MAXIMUM_TARGET_TYPE_VALUE = 0x50;
   1.193 +        private static final int MAXIMUM_TARGET_TYPE_VALUE = 0x4B;
   1.194  
   1.195          private final int targetTypeValue;
   1.196          private final boolean isLocal;

mercurial