is this a bug in MethodHandles.foldArguments?

28 views
Skip to first unread message

Jochen Theodorou

unread,
Jan 9, 2015, 10:07:28 AM1/9/15
to jvm-la...@googlegroups.com
Hi,

I am getting this error message:

java.lang.IllegalArgumentException: target and combiner types must
match: (Object,int)int != (Object,int)int

either the message is misleading or they do in fact match and the check
is wrong.

What I did do is easy:

MethodHandle get = MethodHandles.arrayElementGetter(arrayClass); //
(int[],int):int
MethodHandle fallback = MethodHandles.explicitCastArguments(get,
get.type().changeParameterType(0, Object.class)); // (Object,int):int
fallback = MethodHandles.foldArguments(fallback, normalizeIndex);

normalizeIndex has the signature (Object,int):int and is a direct method
handle of a static method.

bye Jochen

--
Jochen "blackdrag" Theodorou - Groovy Project Tech Lead
blog: http://blackdragsview.blogspot.com/
german groovy discussion newsgroup: de.comp.lang.misc
For Groovy programming sources visit http://groovy-lang.org

Reply all
Reply to author
Forward
0 new messages