byte-buddy

Byte Buddy Advice.OnMethodExit: constructor retransformation

China☆狼群 提交于 2021-02-11 15:30:15
问题 I'm trying to create Java Agent that will intercept FileInputStream/FileOutputStream constructors: import java.io.*; import java.lang.instrument.Instrumentation; import java.util.Arrays; import java.util.List; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.JarOutputStream; import net.bytebuddy.agent.builder.AgentBuilder; import net.bytebuddy.agent.builder.AgentBuilder.InitializationStrategy; import net.bytebuddy.agent.builder.AgentBuilder.Listener; import

Byte Buddy Advice.OnMethodExit: constructor retransformation

廉价感情. 提交于 2021-02-11 15:28:58
问题 I'm trying to create Java Agent that will intercept FileInputStream/FileOutputStream constructors: import java.io.*; import java.lang.instrument.Instrumentation; import java.util.Arrays; import java.util.List; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.JarOutputStream; import net.bytebuddy.agent.builder.AgentBuilder; import net.bytebuddy.agent.builder.AgentBuilder.InitializationStrategy; import net.bytebuddy.agent.builder.AgentBuilder.Listener; import

Bytebuddy - Intercept java.net.ServerSocket constructor

你离开我真会死。 提交于 2021-02-10 14:51:10
问题 Iam Trying to Intercept two methods and one constructor of java.net.ServerSocket . Intercepting the two methods getLocalPort and getInetAddress works fine. However, the class which should handle the constructor ServerSocket(int) is not triggered. My code to instrument (inside a different jar-file which is included to the mainproject): package instrumenting; public class Instrumenting { private static final String CLASS_NAME = "java.net.ServerSocket"; public static void instrument

Use of ByteBuddy's MemberSubstitution class

落花浮王杯 提交于 2021-02-08 10:55:18
问题 I am using ByteBuddy to substitute a field reference by another one into methods of a class. In another question I was suggested to use the class net.bytebuddy.asm.MemberSubstitution . I have been looking for examples about how to use this in mi java agent but a could not find any. I want to use the following code: MemberSubstitution.relaxed() .field(ElementMatchers.named("oneField")) .onRead() .replaceWith(otherField); My agent is: public class MyAgent { public static void premain(String arg

Use of ByteBuddy's MemberSubstitution class

北城以北 提交于 2021-02-08 10:54:33
问题 I am using ByteBuddy to substitute a field reference by another one into methods of a class. In another question I was suggested to use the class net.bytebuddy.asm.MemberSubstitution . I have been looking for examples about how to use this in mi java agent but a could not find any. I want to use the following code: MemberSubstitution.relaxed() .field(ElementMatchers.named("oneField")) .onRead() .replaceWith(otherField); My agent is: public class MyAgent { public static void premain(String arg

Use of ByteBuddy's MemberSubstitution class

柔情痞子 提交于 2021-02-08 10:53:26
问题 I am using ByteBuddy to substitute a field reference by another one into methods of a class. In another question I was suggested to use the class net.bytebuddy.asm.MemberSubstitution . I have been looking for examples about how to use this in mi java agent but a could not find any. I want to use the following code: MemberSubstitution.relaxed() .field(ElementMatchers.named("oneField")) .onRead() .replaceWith(otherField); My agent is: public class MyAgent { public static void premain(String arg

Can a method call be instrumented with ByteBuddy instead of the called method?

雨燕双飞 提交于 2021-02-04 14:19:45
问题 I would like to replace some AspectJ code that protects calls to java.lang.System from some user code. java.lang.System cannot/should not be instrumented. With AspectJ the solution is to instrument the calling code like the following example. The code that should be guarded will be instrumented while the code that is allowed is not. @Around("call(public long java.lang.System.currentTimeMillis()) && within(io.someuserdomain..*) && !within(io.someotherdomain..*)) def

Can a method call be instrumented with ByteBuddy instead of the called method?

守給你的承諾、 提交于 2021-02-04 14:19:29
问题 I would like to replace some AspectJ code that protects calls to java.lang.System from some user code. java.lang.System cannot/should not be instrumented. With AspectJ the solution is to instrument the calling code like the following example. The code that should be guarded will be instrumented while the code that is allowed is not. @Around("call(public long java.lang.System.currentTimeMillis()) && within(io.someuserdomain..*) && !within(io.someotherdomain..*)) def

Are ByteBuddy's field setting checks too strict?

白昼怎懂夜的黑 提交于 2021-01-29 07:52:52
问题 I am using MethodCall.setsField() to try to set an instance field on another instance. My generated class that is doing the field-setting, GC , is trying to set the value of an instance field in an instance of something it has created ( CI ). So the field's declaring type is CI ; my field-setting code resides in GC (which is in the same package as CI but otherwise unrelated to it). The ByteBuddy checks seem to indicate that although GC and CI are in the same package, GC must be assignable to

Modify java.util class using byte-buddy-agent

隐身守侯 提交于 2021-01-28 15:07:30
问题 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>