-
Sub-task
-
Resolution: Delivered
-
P4
-
9
-
Verified
The classfile format (see JVMS section 4.7.2) defines an attribute called `ConstantValue` which is used to describe the constant value associated with a given (constant) field. The layout of this attribute is as follows:
```
ConstantValue_attribute {
u2 attribute_name_index;
u4 attribute_length;
u2 constantvalue_index;
}
```
Historically, `javac` has never performed any kind of range validation of the value contained in the constant pool entry at `constantvalue_index`. As such, it is possible for a constant field of type e.g. `boolean` to have a constant value other than `0` or `1` (the only legal values allowed for a boolean). Starting from <version>, `javac` will start detecting ill-formed `ConstantValue` attributes, and report errors if out-of-range values are found.
```
ConstantValue_attribute {
u2 attribute_name_index;
u4 attribute_length;
u2 constantvalue_index;
}
```
Historically, `javac` has never performed any kind of range validation of the value contained in the constant pool entry at `constantvalue_index`. As such, it is possible for a constant field of type e.g. `boolean` to have a constant value other than `0` or `1` (the only legal values allowed for a boolean). Starting from <version>, `javac` will start detecting ill-formed `ConstantValue` attributes, and report errors if out-of-range values are found.