[code-reflection] RFR: JavaRef extends TypeElement [v2]
Paul Sandoz
psandoz at openjdk.org
Wed Apr 30 23:07:03 UTC 2025
On Wed, 30 Apr 2025 21:31:20 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> Honestly, I wonder if the concept of `JavaRef` still carry its own weight. What it it was just `TypeElement`/`JavaType` ? What if the hierarchy of Java "types" was just flat? My feeling is that if we introduce distinctions, then it's easy to see cracks -- such as the fact that records are refs, but classes are not -- or the fact that a type-variable is both a refs (it points to a type var decl), but also not a ref (it represents a type-variable _use_).
It can go away if there are no suitable methods that are applicable to all refs. I was hoping there might be something around resolution or erasure. We could also relocate all the factory methods. I wish we could find a better name than `Ref`.
Record ref is needed for the modeling of record patterns, describing a record's components (types and names) so we can lower without appealing to reflection. I suspect we may need something similar for constructor patterns and member patterns. So when we model those maybe we might find a more general way of expressing the sequence of named parameters and the owner of those?
I suppose we could introduce `RecordType` as a sub class of `ClassType`, but there is no need to directly express the records components in any hierarchical relationship of that because they are not pertinent to the type itself e.g., the externalized form would not include them.
`TypeVariableType` is a curious beast, since it refers to the declaring owner that gives the type variable name its identity. It is clearly interchangeable with `java.lang.reflect.type.TypeVariable`.
-------------
PR Comment: https://git.openjdk.org/babylon/pull/416#issuecomment-2843634356
More information about the babylon-dev
mailing list