code manipulation : 바이트 코드 변경하기(javaagent)

This commit is contained in:
haerong22
2021-02-18 22:16:32 +09:00
parent edd21fce02
commit 41890753df
3 changed files with 84 additions and 4 deletions

View File

@@ -0,0 +1,16 @@
package org.example;
import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.implementation.FixedValue;
import net.bytebuddy.matcher.ElementMatchers;
import java.lang.instrument.Instrumentation;
public class MasulsaAgent {
public static void premain(String agentArgs, Instrumentation inst) {
new AgentBuilder.Default()
.type(ElementMatchers.any())
.transform((builder, typeDescription, classLoader, javaModule) -> builder.method(ElementMatchers.named("pullOut")).intercept(FixedValue.value("Rabbit!!"))).installOn(inst);
}
}