[code-reflection] RFR: Update ReflectMethods.BodyScanner.coerce to handle null targetType
Maurizio Cimadamore
mcimadamore at openjdk.org
Mon Sep 1 10:37:00 UTC 2025
On Fri, 29 Aug 2025 23:39:40 GMT, Mourad Abbay <mabbay at openjdk.org> wrote:
> `ReflectMethods.BodyScanner.coerce` wasn't handling `null` targetType. For example, a `null` targetType may propagate to reach the method `coerce` when visiting case body of switch statement.
src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/ReflectMethods.java line 739:
> 737:
> 738: Value coerce(Value sourceValue, Type sourceType, Type targetType) {
> 739: if (targetType == null || targetType.hasTag(TypeTag.VOID)) {
Not sure about this -- as I'm not sure about `VOID`. E.g. this method should be called when we do have a target type. If there's no target type then there's nothing to coerce in the first place, and we shouldn't call this method. Can you describe more precisely why we end up with a `null` here?
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/536#discussion_r2313576167
More information about the babylon-dev
mailing list