RFR: 8364751: ConstantBootstraps.explicitCast contradictory specification for null-to-primitive [v2]

Chen Liang liach at openjdk.org
Wed Aug 27 18:51:43 UTC 2025


On Wed, 27 Aug 2025 18:42:02 GMT, Chen Liang <liach at openjdk.org> wrote:

>> ConstantBootstraps.explicitCast behaves like a snippet of code in its specification. However, in the rest of the nominal spec, it incorrectly assumes a null `value` and a primitive `dstType` results in a ClassCastException instead of the zero value of that primitive type. This is inconsistent with that snippet and the actual code behavior.
>> 
>> The specification is fixed, the test for `explicitCast` is merged into the main `ConstantBootstraps` test, and a new unit test case for `value = null` and `dstType = char.class` is added, verifying the outcome is `'u0000'`.
>
> Chen Liang has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
> 
>  - Update wording and rendering again
>  - Merge branch 'master' of https://github.com/openjdk/jdk into doc/constboot-cast
>  - Update and consolidate tests
>  - 8364751: ConstantBootstraps.explicitCast violates doc contracts for null-to-int

In addition to the HTML list updates, @JornVernee I also added a remark about converting from `Boolean` to other primitives - there is an additional boolean-to-int after unboxing.

Please review the CSR as well.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/26714#issuecomment-3229366152


More information about the core-libs-dev mailing list