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
{{ message }}
This repository has been archived by the owner on Nov 26, 2021. It is now read-only.
UnresolvedTypeVariableException: An exact type is requested, but the type contains a type variable that cannot be resolved.
Variable: T from public java.lang.annotation.Annotation Parent.getAnnotation(java.lang.Class)
Hint: This is usually caused by trying to get an exact type when a generic method who's type parameters are not given is involved.
The same call does not fail if the containing type is not parameterized.
Furthermore, would it be possible to add a resolveReturnType(Method m, Object[] args) that could return the actual type for such signatures <T extends Annotation> T getAnnotation(Class<T> clazz) when the arguments are given?
The text was updated successfully, but these errors were encountered:
@leonard84 I believe this is intentional, as the exact return type was requested and could not be determined.
In case you care, I maintain a fork of this project, and it has a family of methods that allow incomplete type resolution.
For this specific case, you could use GenericTypeReflector.getReturnType(m, Class.class) which would return T extends Annotation. From there you could use (the recently added) reduceBounded to get Annotation. getExactX and getX methods behave identically apart from the latter leaving unresolvable variables as they are. reduceBounded recursively replaces all bounded types (variables, wildcards and captures) with their first bound. Since first bound isn't really a well defined thing, especially for captures, I intend to add an overload that accepts custom strategy for reducing bounds.
I hope that helps.
Hi,
I encountered the following problem:
Given
this call will fail
The same call does not fail if the containing type is not parameterized.
Furthermore, would it be possible to add a
resolveReturnType(Method m, Object[] args)
that could return the actual type for such signatures<T extends Annotation> T getAnnotation(Class<T> clazz)
when the arguments are given?The text was updated successfully, but these errors were encountered: