[code-reflection] RFR: Clean up support for boxing

Paul Sandoz psandoz at openjdk.org
Tue Apr 30 17:05:21 UTC 2024


On Tue, 30 Apr 2024 11:11:42 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> 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.

Looks good. When we get method patterns we may be able to revisit this design (and likely have a broader impact on the code model APIs)

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

Marked as reviewed by psandoz (Lead).

PR Review: https://git.openjdk.org/babylon/pull/67#pullrequestreview-2032034887


More information about the babylon-dev mailing list