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

Adam Sotona asotona at openjdk.org
Wed Sep 18 09:16:18 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

This pull request has now been integrated.

Changeset: 5b015c89
Author:    Adam Sotona <asotona at openjdk.org>
URL:       https://git.openjdk.org/babylon/commit/5b015c89c8995bd349bf0af9c13a165782884dbd
Stats:     47 lines in 1 file changed: 47 ins; 0 del; 0 mod

Include boolean in primitive type conversions.

Reviewed-by: psandoz

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

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


More information about the babylon-dev mailing list