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

Chen Liang liach at openjdk.org
Mon Aug 25 17:46:40 UTC 2025


On Mon, 25 Aug 2025 17:31:42 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> 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

I use the same wording as `MethodHandles.explicitCastArguments` here. I recommend updating that method as well if you have such questions.

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

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


More information about the core-libs-dev mailing list