Signature of MethodHandleInfo.reflectAs is not specific enough
forax at univ-mlv.fr
Sun Nov 10 22:29:29 UTC 2013
The is a stupid issue with the signature of MethodHandleInfo.reflectAs,
j.l.r.Field, Method or Constructor implement two interfaces Member and
AnnotatedElement, with the current signature, the code
works but the code
Because there is no way to do an 'or' between several bounds of
a type variable, I think that the signature of reflectAs should be
changed from :
public <T extends Member> T reflectAs(Class<T> expected, Lookup lookup);
public <T> T reflectAs(Class<T> expected, Lookup lookup);
and the javadoc should be modified to explain that a Member or
valid bounds of T.
As a side effect, the signature of MethodHandles.reflectAs(Class<T>,
should be updated accordingly.
There is a workaround, one can write:
but it's at best weird.
More information about the core-libs-dev