byte-buddy

Modify java.util class using byte-buddy-agent

旧巷老猫 提交于 2021-01-28 15:05:34
问题 Is it possible to add a field in java.util class using byte-buddy? I am trying to add a field in java.util.concurrent.FutureTask and intercept constructor and an arbitrary method to set and get the field value. In short, I am trying to add a field to FutureTask so that I can pass some value to child thread from parent even if they are running in a thread pool. isn't it possible to add a field in FutureTask? FutureTaskTransofrmer @Override protected ElementMatcher.Junction<TypeDescription>

Modify java.util class using byte-buddy-agent

白昼怎懂夜的黑 提交于 2021-01-28 15:02:56
问题 Is it possible to add a field in java.util class using byte-buddy? I am trying to add a field in java.util.concurrent.FutureTask and intercept constructor and an arbitrary method to set and get the field value. In short, I am trying to add a field to FutureTask so that I can pass some value to child thread from parent even if they are running in a thread pool. isn't it possible to add a field in FutureTask? FutureTaskTransofrmer @Override protected ElementMatcher.Junction<TypeDescription>

Modify java.util class using byte-buddy-agent

萝らか妹 提交于 2021-01-28 15:01:00
问题 Is it possible to add a field in java.util class using byte-buddy? I am trying to add a field in java.util.concurrent.FutureTask and intercept constructor and an arbitrary method to set and get the field value. In short, I am trying to add a field to FutureTask so that I can pass some value to child thread from parent even if they are running in a thread pool. isn't it possible to add a field in FutureTask? FutureTaskTransofrmer @Override protected ElementMatcher.Junction<TypeDescription>

Using Bytebuddy to intercept setter

☆樱花仙子☆ 提交于 2021-01-28 05:15:03
问题 lets asume i have a Interface like that: public interface User extends Element { String getName(); String getPassword(); } and a implementing class like that: public class BaseUser implements User { @Override public String getId() { return id; } @Override public String getName() { return name; } @Override public String getPassword() { return password; } public void setId(String id) { this.id = id; } public void setName(String name) { this.name = name; System.out.println("Set name to " + name)

Byte-Buddy: Method Interception InvocationHandler vs MethodDelegation to GeneralInterceptor

情到浓时终转凉″ 提交于 2021-01-27 15:51:18
问题 I am using Byte-Buddy to dynamically generate implementations of Java interface methods, and to delegate the calls to these methods to a single method of an existing proxy object. The first version was inspired by How to create a dynamic proxy using ByteBuddy It uses a Reflection InvocationHandler i.e. the concrete proxy class: implements the interface InvocationHandler overrides the method invoke() This works fine. Then re-reading the Byte-Buddy readme on Github I discovered an alternative

Byte-Buddy: Method Interception InvocationHandler vs MethodDelegation to GeneralInterceptor

夙愿已清 提交于 2021-01-27 15:21:13
问题 I am using Byte-Buddy to dynamically generate implementations of Java interface methods, and to delegate the calls to these methods to a single method of an existing proxy object. The first version was inspired by How to create a dynamic proxy using ByteBuddy It uses a Reflection InvocationHandler i.e. the concrete proxy class: implements the interface InvocationHandler overrides the method invoke() This works fine. Then re-reading the Byte-Buddy readme on Github I discovered an alternative

Classpath problems while Instrumenting Springboot application

▼魔方 西西 提交于 2020-12-30 14:32:27
问题 I have a springboot application which I'm trying to instrument using bytebuddy. I'm running into classpath issues which I'm not able to understand. Firstly, the following is other literature on this: https://github.com/raphw/byte-buddy/issues/473 https://github.com/raphw/byte-buddy/issues/87 Unable to instrument apache httpclient using javaagent for spring boot uber jar application https://github.com/raphw/byte-buddy/issues/109 https://github.com/raphw/byte-buddy/issues/473 https://github.com

Classpath problems while Instrumenting Springboot application

戏子无情 提交于 2020-12-30 14:32:15
问题 I have a springboot application which I'm trying to instrument using bytebuddy. I'm running into classpath issues which I'm not able to understand. Firstly, the following is other literature on this: https://github.com/raphw/byte-buddy/issues/473 https://github.com/raphw/byte-buddy/issues/87 Unable to instrument apache httpclient using javaagent for spring boot uber jar application https://github.com/raphw/byte-buddy/issues/109 https://github.com/raphw/byte-buddy/issues/473 https://github.com

Byte-buddy transform running multiple times for a single execution

心不动则不痛 提交于 2020-12-14 23:54:38
问题 I wrote a javaagent as below to capture the execution time of the execute method of the apache org.apache.http.client.HttpClient . It is capturing the time, but it's running three times. import java.lang.instrument.Instrumentation; import net.bytebuddy.agent.builder.AgentBuilder; import net.bytebuddy.implementation.MethodDelegation; import static net.bytebuddy.matcher.ElementMatchers.isMethod; import static net.bytebuddy.matcher.ElementMatchers.isAbstract; import static net.bytebuddy.matcher