Hi,

The following code:

public class Test {

    static class X {
        public void x() { }
    }

    static class Y extends X {
    }

    public static void main(String[] args) throws Exception {
        MethodHandles.Lookup lookup = MethodHandles.lookup();
MethodHandle mh = lookup.findVirtual(Y.class, "x", MethodType.methodType(void.class, new Class[0]));
        MethodHandleInfo mhi = lookup.revealDirect(mh);
        System.out.println(mhi.getDeclaringClass().getSimpleName());
    }
}


...prints "Y". Is this correct? The javadoc for the method says:


/Returns the class in which the cracked method handle's underlying member was defined.//
//
//Returns://
//        the declaring class of the underlying member/


The "declaring" class of the underlying member (the method x()) is clearly not class Y, but class X, isn't it?

Regards, Peter

_______________________________________________
mlvm-dev mailing list
mlvm-dev@openjdk.java.net
http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev

Reply via email to