byte-buddy icon indicating copy to clipboard operation
byte-buddy copied to clipboard

Lambda Filtering Strategy

Open leobornlion opened this issue 6 months ago • 1 comments

Hey Rafael,

I have a use case where I want to intercept some methods (Like Thread.Sleep). But it looks like having the same methods defined in lambdas causes byte buddy to miss them. If I define them outside a lambda then they work flawlessly. My google search stumbled upon the LambdaInstrumentationStrategy.ENABLED which caused JVM failures and I was wondering if there is a way to narrow the scope of lambda instrumentation to my packages?

Thanks for the awesome project and help.

leobornlion avatar Jun 30 '25 06:06 leobornlion

Lambda metafactory is not really possible on modern JVMs anymore. I will likley deprecate the function.

Rather, instrument the classes that contain the lambdas, where the logic will be contained in a private method which you can instrument. You can easily try this with a sample class containing the lambda, to see how this is built up.

raphw avatar Jul 05 '25 11:07 raphw