[code-reflection] RFR: Clean up support for boxing
Maurizio Cimadamore
mcimadamore at openjdk.org
Tue Apr 30 11:16:35 UTC 2024
This PR does a couple of things:
* it sharpens the types of the various `JavaType` constants to the correct sealed sub-interface
* it consolidates support for boxing/unboxing. More specifically there's now a pair of functions:
ClassType::unbox() -> Optional<PrimitiveType>
and
PrimitiveType::box() -> Optional<ClassType>
Note that both functions are partial: there are classes that are not wrappers (e.g. String) and there are primitive types that cannot be boxed (e.g. `void`).
I'm on the fence whether to use `Optional` for this, or just return null. Suggestions welcome.
-------------
Commit messages:
- Minor API tweaks
- Merge branch 'code-reflection' into cleanup_type_factories
- Initial push
Changes: https://git.openjdk.org/babylon/pull/67/files
Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=67&range=00
Stats: 100 lines in 5 files changed: 42 ins; 22 del; 36 mod
Patch: https://git.openjdk.org/babylon/pull/67.diff
Fetch: git fetch https://git.openjdk.org/babylon.git pull/67/head:pull/67
PR: https://git.openjdk.org/babylon/pull/67
More information about the babylon-dev
mailing list