[code-reflection] RFR: 8337162: Support primitives in patterns
Paul Sandoz
psandoz at openjdk.org
Wed Oct 2 16:54:54 UTC 2024
On Wed, 2 Oct 2024 03:03:44 GMT, Mourad Abbay <mabbay at openjdk.org> wrote:
> Support primitives in patterns
You need to add test for all the primitive types.
What about `i instanceof Integer _` and `i instanceof Number _` will you address that in this PR a subsequent PR?
src/java.base/share/classes/java/lang/reflect/code/op/ExtendedOp.java line 3168:
> 3166: String mn = "is%sTo%sExact".formatted(s, t);
> 3167: MethodRef mref = MethodRef.method(ExactConversionsSupport.class, mn, boolean.class,
> 3168: st.toNominalDescriptor().resolveConstantDesc(MethodHandles.lookup()));
Lets avoid resolution of the primitive type, create the method reference from the type elements e.g.,
static final JavaType EXACT_CONVERSIONS_SUPPORT = JavaType.type(ExactConversionsSupport.class);
...
MethodRef mref = MethodRef.method(EXACT_CONVERSIONS_SUPPORT, mn, JavaType.BOOLEAN, st);
-------------
PR Review: https://git.openjdk.org/babylon/pull/246#pullrequestreview-2343499723
PR Review Comment: https://git.openjdk.org/babylon/pull/246#discussion_r1784882884
More information about the babylon-dev
mailing list