[code-reflection] RFR: Represents literals of type byte/short as permitted in the Java language [v2]

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Mar 12 18:20:14 UTC 2025


On Wed, 12 Mar 2025 18:15:37 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Mourad Abbay has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains two additional commits since the last revision:
>> 
>>  - Merge branch 'code-reflection' into fix-literal-type
>>  - Represents literals of type byte/short as permitted in the Java language.
>
> src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/ReflectMethods.java line 2332:
> 
>> 2330:                     // Capture applying rhs and operation
>> 2331:                     Function<Value, Value> scanRhs = (lhs) -> {
>> 2332:                         Value one = convert(append(numericOneValue(tree.type)), types.unboxedType(tree.type));
> 
> I don't get the call to `types.uboxedType` -- `tree.type` is passed to `numericOneValue` which seems to assume that the type is a primitive type, right?

Ah ok - I see:

                case CLASS -> numericOneValue(types.unboxedType(t));


So, `numericOneValue` also does unboxing. I think this code would be clearer by doing the unboxing first -- and then pass the unboxed type to both `numericOneValue` and `convert` (and then, we could remove the unboxing path from `numericOneValue` - and make that consistent with `defaultValue`).

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

PR Review Comment: https://git.openjdk.org/babylon/pull/351#discussion_r1992057794


More information about the babylon-dev mailing list