Release Note: Class-File API Rejects Unrepresentable Integer Data

XMLWordPrintable

      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.

            Assignee:
            Chen Liang
            Reporter:
            Chen Liang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: