You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When AnnotatedMember#getDeclaringType() is called on a member of some AnnotatedType<T>, a AnnotatedType<? super T> is returned, because both getMethods and getFields are defined to return Set<AnnotatedX<? super T>>. I expect the underlying class to be the declaring class of the member in the sense of java.lang.reflect.Member#getDeclaringClass(), see https://issues.redhat.com/browse/WELD-2681.
EDIT: @mkouba commented on that WELD issue and corrected my understanding of what getDeclaringType() is supposed to do. Instead of a question, let me re-phrase it as a request. (My second questions remain)
Request:
Have the spec explain in more detail what AnnotatedType exactly gets returned by AnnotatedMember#getDeclaringType(), how that differs from Method.getDeclaringClass() and what annotations are expected to be present on this type (and its members, see below). Explain that the returned Set<AnnotatedMethod<? super T>> of AnnotatedType<T>#getMethods (and similar for getFields()) is always an instance of Set<AnnotatedMethod<T>> in practice, even if the interface suggests otherwise. Better yet, change the interface itself to correct the return type. (But assume that would be a breaking change.)
Question 2: Round trips
And come to think of it: Is it expected that "round-trips" work, i.e. should myAnnotatedMethod.getDeclaringType().filterMethods(m -> m.equals(myAnnotatedMethod)).findAny()
be guaranteed to be a non-empty Optional? Should maybe even myAnnotatedMethod.getDeclaringType().filterMethods(m -> m == myAnnotatedMethod).findAny()
be guaranteed to be non-empty?
If yes, then the AnnotatedType returned by getDeclaringType() must be a different instance every time a configurator is used to modify an AnnotatedMember, right? If no, what differences between myAnnotatedMethod and the corresponding AnnotatedMethod contained in myAnnotatedMethod.getDeclaringType().getMethods() are allowed and how does the container react if there are differences?
The text was updated successfully, but these errors were encountered:
When
AnnotatedMember#getDeclaringType()
is called on a member of someAnnotatedType<T>
, aAnnotatedType<? super T>
is returned, because bothgetMethods
andgetFields
are defined to returnSet<AnnotatedX<? super T>>
.I expect the underlying class to be the declaring class of the member in the sense of, see https://issues.redhat.com/browse/WELD-2681.java.lang.reflect.Member#getDeclaringClass()
EDIT: @mkouba commented on that WELD issue and corrected my understanding of what
getDeclaringType()
is supposed to do. Instead of a question, let me re-phrase it as a request. (My second questions remain)Request:
Have the spec explain in more detail what
AnnotatedType
exactly gets returned byAnnotatedMember#getDeclaringType()
, how that differs fromMethod.getDeclaringClass()
and what annotations are expected to be present on this type (and its members, see below). Explain that the returnedSet<AnnotatedMethod<? super T>>
ofAnnotatedType<T>#getMethods
(and similar forgetFields()
) is always an instance ofSet<AnnotatedMethod<T>>
in practice, even if the interface suggests otherwise. Better yet, change the interface itself to correct the return type. (But assume that would be a breaking change.)Question 2: Round trips
And come to think of it: Is it expected that "round-trips" work, i.e. should
myAnnotatedMethod.getDeclaringType().filterMethods(m -> m.equals(myAnnotatedMethod)).findAny()
be guaranteed to be a non-empty Optional? Should maybe even
myAnnotatedMethod.getDeclaringType().filterMethods(m -> m == myAnnotatedMethod).findAny()
be guaranteed to be non-empty?
If yes, then the
AnnotatedType
returned bygetDeclaringType()
must be a different instance every time a configurator is used to modify anAnnotatedMember
, right? If no, what differences betweenmyAnnotatedMethod
and the correspondingAnnotatedMethod
contained inmyAnnotatedMethod.getDeclaringType().getMethods()
are allowed and how does the container react if there are differences?The text was updated successfully, but these errors were encountered: