On Mon, 25 Aug 2025 17:29:29 GMT, Jorn Vernee <jver...@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'`.
>
> src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java line 382:
> 
>> 380:      *     or {@code false} depending on whether the 
>> least-significant-bit
>> 381:      *     is 1 or 0 respectively.  If {@code value} is null, the zero 
>> value for
>> 382:      *     the {@code dstType} is returned.  Otherwise, a {@link 
>> ClassCastException}
> 
> Is 'zero value' a well-defined term?

Also, 'Otherwise' seems to refer to `If {@code value} is null` which I don't 
think is the intent? Maybe you could add another list item (`<li>`) With:


If {@code dstType} is a primitive type and the runtime type of {@code value} is 
<em>not</em> a primitive wrapper type, a {@link ClassCastException} is thrown

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26714#discussion_r2298698321

Reply via email to