Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8260870

[type-restrictions] Generate RestrictedMethod attributes

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • repo-valhalla
    • repo-valhalla
    • tools
    • None

      Update the 'valhalla/type-restrictions' version of javac to generate class files with RestrictedMethod attributes.

      Attribute format:

      RestrictedMethod_attribute {
       u2 name_index;
       u4 length;
       u1 num_params;
       u2 restricted_param_type[num_params];
       u2 restricted_return_type;
      }

      'num_params' must match the number of parameters in the descriptor.

      Each 'restricted_param_type' and 'restricted_return_type' must be either 0 or a descriptor string (Utf8) in the constant pool that begins with Q. The corresponding type in the descriptor must be an L type.

      RestrictedType annotations:

      Type annotations of the form '@RestrictedType("QPoint;")', if applied to method/constructor parameter or return types, should have the effect of generating a RestrictedMethod attribute for that method in the class file, with the corresponding `restricted_param_type` or `restricted_return_type` value given by the annotation's value. Other param/return types may also contribute strings via annotations; those without the annotation should correspond to a '0' entry in the method's RestrictedMethod attribute.

      Note the alignment between descriptors and `num_params`: synthetic or implicit parameters count when deciding on the index of an annotated parameter type.

      XXflattenWithTypeRestrictions mode:

      If javac is invoked with argument `-XXflattenWithTypeRestrictions`, all primitive value types appearing in method signatures/returns are handled the same as primitive value types appearing as field types: the descriptor type is the reference type (`LPoint$val;`), while the RestrictedMethod attribute uses the value type (`QPoint;`).

            sadayapalam Srikanth Adayapalam (Inactive)
            dlsmith Dan Smith
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: