-
Type:
Sub-task
-
Resolution: Delivered
-
Priority:
P4
-
Affects Version/s: 26
-
Component/s: core-libs
In the `class` file format, the representable range of many integer values are narrower than that of the `int` primitive type in the Java programming language. Currently, the Class-File API truncates the most significant bytes of a user-provided `int` value upon writing to `class` file. Upon reading, the truncated value is zero or sign extended, depending on the type, back to an `int`, and may differ from the user-provided value. For instance, an `int` value `65536` would become `0` after this write-read to a `u2` value .
To prevent such error-prone usage, the Class-File API now performs eager validation of int values that would be lost after a truncation, including the size of lists. Such unrepresentable data will result in an IllegalArgumentException. Users who used such silent truncation should migrate to explicit truncation before passing data instead.
To prevent such error-prone usage, the Class-File API now performs eager validation of int values that would be lost after a truncation, including the size of lists. Such unrepresentable data will result in an IllegalArgumentException. Users who used such silent truncation should migrate to explicit truncation before passing data instead.
- relates to
-
JDK-8361635 Missing List length validation in the Class-File API
-
- Resolved
-