[code-reflection] RFR: Support conversions of primitives in testing context [v10]

Paul Sandoz psandoz at openjdk.org
Thu Oct 31 17:00:58 UTC 2024


On Thu, 31 Oct 2024 04:20:36 GMT, Mourad Abbay <mabbay at openjdk.org> wrote:

>> Support conversions of primitives in testing context.
>
> Mourad Abbay has updated the pull request incrementally with four additional commits since the last revision:
> 
>  - Avoid casting when identity reference conversion
>  - clarify comments
>  - Handle boxing conversions
>  - Apply suggestions

Please address the comments as appropriate before you integrate.

src/java.base/share/classes/java/lang/reflect/code/op/ExtendedOp.java line 3197:

> 3195:                         // e.g. byte -> Byte, boxing
> 3196:                         box = ct;
> 3197:                     }

Can you just replace with `ClassType box = ps.box().orElseThrow()` ? (keep the examples).

src/java.base/share/classes/java/lang/reflect/code/op/ExtendedOp.java line 3199:

> 3197:                     }
> 3198:                     c = invoke(MethodRef.method(box, "valueOf", box, ps), target);
> 3199:                 } else if (!Objects.equals(s, t)) {

Suggestion:

                } else if (!s.equals(t)) {

src/java.base/share/classes/java/lang/reflect/code/op/ExtendedOp.java line 3214:

> 3212:                 }
> 3213: 
> 3214:                 if (c != null) {

If `c` is `null` then i believe `p` is also `null`, but not the other way around. Can you place the `c != null` check before and embed in the `p != null` check to be clearer about the dependency?

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

Marked as reviewed by psandoz (Lead).

PR Review: https://git.openjdk.org/babylon/pull/265#pullrequestreview-2408543116
PR Review Comment: https://git.openjdk.org/babylon/pull/265#discussion_r1824831413
PR Review Comment: https://git.openjdk.org/babylon/pull/265#discussion_r1824831122
PR Review Comment: https://git.openjdk.org/babylon/pull/265#discussion_r1824826720


More information about the babylon-dev mailing list