[code-reflection] RFR: Support conversions of primitives in testing context [v9]
Paul Sandoz
psandoz at openjdk.org
Wed Oct 30 22:17:43 UTC 2024
On Wed, 30 Oct 2024 00:28:42 GMT, Mourad Abbay <mabbay at openjdk.org> wrote:
>> Support conversions of primitives in testing context.
>
> Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision:
>
> Better names for methods in TestPrimitiveTypePatterns
src/java.base/share/classes/java/lang/reflect/code/op/ExtendedOp.java line 3179:
> 3177: || isWideningAndNarrowingPrimitiveConv(ps, pt)) {
> 3178: // e.g. int -> byte, narrowing
> 3179: // e,g. int -> float, widening that need check
Suggestion:
// e,g. int -> float, widening with need check
And rename `isWideningPrimitiveConvThatNeedCheck` to `isWideningPrimitiveConvWithCheck`.
src/java.base/share/classes/java/lang/reflect/code/op/ExtendedOp.java line 3187:
> 3185: }
> 3186: } else {
> 3187: // e.g. byte -> Byte, Number -> Double, ...
I think the primitive -> ref case, e.g., byte -> Byte, is not supported correctly. We need to box, which I believe is unconditional if from valid source. You can have another `else if (s instanceof PrimitiveType ps) { ... }`.
The boxing test is likely passing because the interpreter naturally boxes all primitive values and we don't differentiate between a primitive value and its box. Consider that a pragmatic limitation.
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/265#discussion_r1823435015
PR Review Comment: https://git.openjdk.org/babylon/pull/265#discussion_r1823488435
More information about the babylon-dev
mailing list