-
Enhancement
-
Resolution: Fixed
-
P3
-
repo-valhalla
-
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;`).
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;`).
- relates to
-
JDK-8253312 [type-restrictions] Enable JVM experiments in specialization under an opt-in mode
-
- Resolved
-
-
JDK-8255856 [type-restrictions] Generate RestrictedField attributes from annotations
-
- Resolved
-