1

there is a possibility to transform MethodHandle to the instance of LambdaForm via: LambdaMetaFactory.metafactory() and invoke it via invokeinterface call. I know that it is possible to make it for direct MethodHandle. Is it possible to do it for non-direct?

Why I want do it? I have a method m that makes 6 different calls to different composed methods called via invokedynamic. I see that my calls share same LambdaForm and it looks like there is a performance degradation.

Gilgamesz
  • 4,727
  • 3
  • 28
  • 63
  • Can you expand on your use-case a bit? Are you generating code (e.g. with ASM) to generate `invokedynamic` instructions? `LambdaForms` are initially shared, but as long as you go through an invoker lambda form the lambda form will be customized after 127 invokations. – Jorn Vernee Jul 19 '22 at 11:26
  • 1
    I once [wrote something like this](https://stackoverflow.com/questions/71224833/lambda-expressions-and-anonymous-classes-dont-work-when-loaded-as-hidden-classe/71249339#71249339) - it uses `MethodHandles.invokeExact` as direct MethodHandle and passes the non-direct MethodHandle as argument to the constructor. – Johannes Kuhn Jul 19 '22 at 12:17
  • 1
    @JohannesKuhn yeah, I did something similar [before](https://stackoverflow.com/a/53708132/2711488) – Holger Aug 25 '22 at 15:07

0 Answers0