I have this case:
public <@A1 S extends @A2 T> @A3 S myMethod() { ...}
and I'm trying to get the @A2
annotation on the bound T
.
This is what I'm seeing, assuming myMethod
is SomeClass.class.getDeclaredMethod("myMethod")
. Type casts removed for readability.
myMethod.getGenericReturnType().getAnnotations()
returns@A1
(as expected, I guess)myMethod.getGenericReturnType().getBounds()[0].getAnnotations()
returns nothing (?? shoudn't it be@A2
??)myMethod.getAnnotatedReturnType().getAnnotations()
returns@A3
(as expected, I guess)myMethod.getAnnotatedReturnType().getAnnotatedBounds()[0].getAnnotations()
returns nothing (as excepted, I guess)
It seems like @A2
got lost... and that doesn't sound sensible. Am I doing something wrong or is this indeed some bizarre behavior?
Aucun commentaire:
Enregistrer un commentaire