Passing InvokeDynamic.lambda to MethodCall.

115 views
Skip to first unread message

Remi Turk

unread,
Mar 12, 2021, 3:16:07 PM3/12/21
to Byte Buddy
Hi everyone,

In the hope that pseudo-code speaks a thousand words. I have this working:

  .defineMethod("getOne", ...).intercept(InvokeDynamic.lambda(...)
  .defineMethod("getTwo", ...).intercept(InvokeDynamic.lambda(...)
  .method(...).intercept(
      MethodCall.invoke(...)
      .withMethodCall(MethodCall.invoke(named("getOne")))
      .withMethodCall(MethodCall.invoke(named("getTwo"))))

However, this way I'm having two methods for each lambda: One containing the actual lambda body and one doing nothing but calling InvokeDynamic.lambda.
What I can't seem to get to work is something like the following:

  .method(...)
  .intercept(
      MethodCall.invoke(...)
      .withMethodCall(InvokeDynamic.lambda(...))
      .withMethodCall(InvokeDynamic.lambda(...)))

This doesn't work because although MethodCall has a lot of .with* methods, none of them accepts an Implementation in general or an InvokeDynamic in particular.

Am I missing something obvious or is this currently just not supported?

Kind regards,
Remi

Remi Turk

unread,
Mar 12, 2021, 3:17:04 PM3/12/21
to Byte Buddy
And of course I forget to link to the repo where I've got a complete example: https://github.com/remiturk/bytebuddy-experiments/blob/main/src/test/java/nl/cornerstone/bytebuddy/Test1.java

Laird Nelson

unread,
Mar 12, 2021, 3:47:53 PM3/12/21
to Byte Buddy
It's basically not supported so far as I know.  You might be able to get where you want to go using with(StackManipulation, TypeDescription), but there's pain there.


Best,
Laird

Remi Turk

unread,
Mar 17, 2021, 1:08:41 PM3/17/21
to Laird Nelson, Byte Buddy
Hi Laird,

Thanks for the update. Tells me I should stop looking for it and start implementing it myself ;)

Cheers, Remi

--
You received this message because you are subscribed to a topic in the Google Groups "Byte Buddy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/byte-buddy/xcQIFPasoxw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to byte-buddy+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/byte-buddy/9445c307-8298-4e04-a8d3-4f8183b363b5n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages