RFR: 8202471: (ann) Cannot read type annotations on generic receiver type's type variables [v6]
Joel Borggrén-Franck
jfranck at openjdk.java.net
Mon Nov 16 10:33:58 UTC 2020
On Sun, 15 Nov 2020 23:25:22 GMT, Rafael Winterhalter <winterhalter at openjdk.org> wrote:
>> A method's or constructor's owner type might carry annotations on its potential type parameters but is never represented as parameterized type what makes these parameters inaccessible at runtime, despite the presence of parameter type annotations.
>
> Rafael Winterhalter has refreshed the contents of this pull request, and previous commits have been removed. The incremental views will show differences compared to the previous content of the PR.
src/java.base/share/classes/sun/reflect/generics/factory/CoreReflectionFactory.java line 93:
> 91: }
> 92:
> 93: public static Type ownerType(Class<?> c) {
This feels somewhat odd. How about, moving these back to Executable and rename `ownerType` to `resolveToType` ? I realise we can't get use getFactory() in executable but as you write, it isn't needed, it should be fine in this case to create it directly as in your v1. The reason is the semantics of this is somewhat unintuitive and is only used in the annotated receiver case.
test/jdk/java/lang/annotation/typeAnnotations/TestReceiverTypeParameterizedConstructorNested.java line 36:
> 34: import java.lang.reflect.Constructor;
> 35:
> 36: public class TestReceiverTypeParameterizedConstructorNested {
Suggestion, what I would like to test is that we can walk up the chain and find type parameters on the outermost owner. Same for Method.
-------------
PR: https://git.openjdk.java.net/jdk/pull/851
More information about the core-libs-dev
mailing list