ing a method with a known signature, but dynamic type
So I've been very into bytecode recently, and I want to learn how to use invokedynamic. I've already figured out how to link a static method through invokedynamic, but I have a more specific use case. I want to:
Currently my bootstrap method looks like this:
public static CallSite bootstrap(MethodHandles.Lookup caller, String name, MethodType methodType) throws Throwable {
return new ConstantCallSite(MethodHandles.lookup().findVirtual(null, name, methodType));
}
Where null is what I'm not sure about. I'm basically trying to invokevirtual on the object, but bypass the check to see if the method is actually there (since the statically-bound type of the object will be Object). (because invokevirtual-ing will throw an error if I pass in a class, and a method not in that class).
any help is appreciated!
Edit: Basically I'm trying to implement duck-typing of a sort.
链接地址: http://www.djcxy.com/p/63466.html上一篇: CMS或框架中的Live Analytics用户数据
下一篇: 一种具有已知签名但是是动态类型的方法