[code-reflection] RFR: Cleanup JavaType factories [v2]
Maurizio Cimadamore
mcimadamore at openjdk.org
Fri May 3 09:32:30 UTC 2024
On Thu, 2 May 2024 18:04:09 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:
>> Maurizio Cimadamore has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - Update src/java.base/share/classes/java/lang/reflect/code/type/impl/MethodRefImpl.java
>>
>> Co-authored-by: Paul Sandoz <paul.d.sandoz at googlemail.com>
>> - Update src/java.base/share/classes/java/lang/reflect/code/type/impl/FieldRefImpl.java
>>
>> Co-authored-by: Paul Sandoz <paul.d.sandoz at googlemail.com>
>
> src/java.base/share/classes/java/lang/reflect/code/type/impl/FieldRefImpl.java line 107:
>
>> 105: static Class<?> resolve(MethodHandles.Lookup l, TypeElement t) throws ReflectiveOperationException {
>> 106: if (t instanceof JavaType jt) {
>> 107: return (Class<?>)jt.resolve(l);
>
> Suggestion:
>
> return (Class<?>)jt.erasure().resolve(l);
>
> ?
I will accept these suggestions. However, note that the code was left unchanged deliberately: I believe when we create method refs and field refs we use always an erased owner type. That said if we wanted to be stricter about this, perhaps we should consider swapping `JavaType` for `ClassDesc` for the owner, or checking the validity of the JavaType at construction.
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/71#discussion_r1588961374
More information about the babylon-dev
mailing list