Skip to content

Problem with LambdaInstrumentationStrategy.ENABLED #1869

@ap-actoron

Description

@ap-actoron

Hello.

When instrumenting lambdas, i get the following Exception:

Exception in thread "main" java.lang.AbstractMethodError: Receiver class ByteBuddyLambdaTest$StringFunction$$Lambda$ByteBuddy$1/0x000002b6c81495c0 does not define or inherit an implementation of the resolved method 'java.lang.Object apply(java.lang.Object)' of interface ByteBuddyLambdaTest$StringFunction.
	at ByteBuddyLambdaTest.main(ByteBuddyLambdaTest.java:13)

Minimal code to reproduce the problem is as follows:

import java.util.function.Function;

import net.bytebuddy.agent.ByteBuddyAgent;
import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.agent.builder.AgentBuilder.LambdaInstrumentationStrategy;

public class ByteBuddyLambdaTest {	
	public static void main(String[] args) {
		new AgentBuilder.Default()
			.with(LambdaInstrumentationStrategy.ENABLED)
			.installOn(ByteBuddyAgent.install());
		
		StringFunction.TEST.apply("test");
	}
	
	interface StringFunction extends Function<String, String> {
	    StringFunction TEST = System::getProperty;
	}
}

It seems to be due to the interface extending a generified lambda (i.e. Function<String, String>).
Somehow the code produced by the LambdaInstrumentationStrategy doesn't contain the right parameter types, I guess?

Thanks in advance
Alex

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions