On 03/20/2011 02:30 AM, Kirill Shirokov wrote:
> Hi,
>
> 1. Can the combiner method in MethodHandles.foldArguments() have the void 
> return type, so the combiner result is not passed to target?
>
> This would allow to easily add a debugging hook (or aspect) to a MethodHandle 
> call.

It should, even if the current implementation doesn't support that.
I'm happy that you raise that point, I have seen this problem but forget 
to report it to the EG.

> 2. Can I apply MethodHandles.filterReturnValue() to a void target method to 
> make the method return some value?
>
> With the current implementation, to add a void "hook" to a method handle, it 
> seems that I have to do the following:
>
> target = MethodHandles.foldArguments(
>      MethodHandles.dropArguments(target, 0),
>      MethodHandles.convertArguments(hook, MethodType.methodType(int.class, 
> target.parameterArray()))
> )
>
> Please correct me if I'm wrong.

You're right filterReturnValue() should also work with void target
as it's a convenient method that can be express using foldArguments.

> Thanks in advance!
>
> --Kirill

Rémi

_______________________________________________
mlvm-dev mailing list
[email protected]
http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev

Reply via email to