On 04/21/2011 09:59 AM, Mark Roos wrote:
Thanks for the update ( even if the class names are not orthogonal to
invoke dynamic)
Two questions on usage
In your blog you used MH_GETSTATIC to access the bootstrap. Did you
mean to use MH_INVOKESTATIC ?
Yes !
I would like to use a bootstrap signature of: ( no trailing arguments)
* static*ConstantCallSite
bootStrapConstant(MethodHandles.Lookup callerLookup, String template,
MethodType type)
But I can't figure out how to invoke that in ASM. My current code is:
bsmType =
java.lang.invoke.MethodType./methodType/(ConstantCallSite.*class*,
Lookup.*class*, String.*class*, java.lang.invoke.MethodType.*class*,
Object.*class*);;
mv.visitInvokeDynamicInsn( bsmName, "()Lri/core/rtalk/RtObject;",
* new*MethodHandle(Opcodes./MH_INVOKESTATIC/,
"ri/core/rtalk/RtCallSite",
"bootStrapConstant",
bsmType.toMethodDescriptorString()),
(Object[]) *new*String[1]);
How would I change it for the above bootstrap?
Your bsmType declare a boostrap argument, the last parameter is an Object.
so bsmType should be:
bsmType =
java.lang.invoke.MethodType./methodType/(ConstantCallSite.*class*,
Lookup.*class*, String.*class*, java.lang.invoke.MethodType.*class*);
Now, the formal parameter corresponding to the boostrap arguments
in visitInvokeDynamicInsn is declared Object... , the elipsis/variadic
'...' accept 0 or more
arguments separated by a comma.
So you can write:
mv.visitInvokeDynamicInsn( bsmName, "()Lri/core/rtalk/RtObject;",
* new*MethodHandle(Opcodes./MH_INVOKESTATIC/,
"ri/core/rtalk/RtCallSite",
"bootStrapConstant",
bsmType.toMethodDescriptorString()));
By the way, I know how to recognize a Caml guy that write Java code,
take a look to the last characters of your first line of code. ;;)
thanks much
mark
Rémi
_______________________________________________
mlvm-dev mailing list
mlvm-dev@openjdk.java.net
http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev