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

Adam Sotona asotona at openjdk.org
Tue Sep 17 07:30:51 UTC 2024


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

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

Commit messages:
 - Include boolean in primitive type conversions.

Changes: https://git.openjdk.org/babylon/pull/232/files
  Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=232&range=00
  Stats: 47 lines in 1 file changed: 47 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/babylon/pull/232.diff
  Fetch: git fetch https://git.openjdk.org/babylon.git pull/232/head:pull/232

PR: https://git.openjdk.org/babylon/pull/232


More information about the babylon-dev mailing list