Signature of MethodHandleInfo.reflectAs is not specific enough
ali.ebrahimi1781 at gmail.com
Sat Mar 1 10:17:52 UTC 2014
On Sat, Mar 1, 2014 at 12:16 AM, John Rose <john.r.rose at oracle.com> wrote:
> On Feb 25, 2014, at 3:13 AM, Ali Ebrahimi <ali.ebrahimi1781 at gmail.com>
> I know, this is too late, but I want to share my suggestion:
> public <T extends AccessibleObject&AnnotatedElement> T reflectAs(Class<?
> super T> expected, MethodHandles.Lookup lookup)
> Isn't this the same as
> public <T extends AccessibleObject> T reflectAs...
Oh, sorry, this is my bad.
I mean this:
public <T extends AccessibleObject&Member> T reflectAs(Class<? super T>
expected, MethodHandles.Lookup lookup)
> I think we considered AccessibleObject but rejected it as not buying
> anything significant compared with Member which is an interface.
> public <T extends Member & AnnotatedElement> T reflectAs...
I considered this case, but unfortunately compiler accepts following test
case with this signature:
String ss = reflectAs(String.class, MethodHandles.lookup()); //OK!!!!!!!
This seams as compiler bug, any way with <T extends
AccessibleObject&Member> compiler catches error.
Finally, one case that compiler accepts with both signature is:
Object mo = reflectAs(Object.class, MethodHandles.lookup());
Maybe I'm wrong for this, Dan Smith can better interpret this.
T inferred to Object and T is not within its bound
More information about the core-libs-dev