[code-reflection] RFR: Include boolean in primitive type conversions.

Paul Sandoz psandoz at openjdk.org
Tue Sep 17 18:53:20 UTC 2024


On Tue, 17 Sep 2024 07:25:58 GMT, Adam Sotona <asotona at openjdk.org> wrote:

> There is a big difference in `boolean` role in JLS and JVMS. While in JLS it is not allowed to cast between `boolean` and other primitive numeric types (obviously because it is not  a numeric type). On the other side in the bytecode it is very hard to differentiate between `byte`, `boolean`, `short`, `char` and `int`. `BytecodeLift` actually inserts an explicit `ConvOp` in the situations where the sub-int type detection failed and it needs to by adjusted on the fly. Explicit `ConvOp` works for conversions between primitive numeric types according to JLS, however `Interpreter` fails on `ConvOp` from and to booleans. `BytecodeGenerator` accepts such conversions (as Class-File API also directly supports conversions between all primitive types, see `CodeBuilder::conversion`).
> 
> I'm proposing to add `boolean` into the matrix of supported types for `ConvOp`.
> 
> Please review.
> 
> Thanks,
> Adam

Marked as reviewed by psandoz (Lead).

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

PR Review: https://git.openjdk.org/babylon/pull/232#pullrequestreview-2310586900


More information about the babylon-dev mailing list