diff --git a/skywalking-sniffer/skywalking-api/pom.xml b/skywalking-sniffer/skywalking-api/pom.xml
index 1649a624f..f57880769 100644
--- a/skywalking-sniffer/skywalking-api/pom.xml
+++ b/skywalking-sniffer/skywalking-api/pom.xml
@@ -35,6 +35,12 @@
byte-buddy
1.5.7
+
+ net.bytebuddy
+ byte-buddy-agent
+ 1.5.7
+ test
+
com.lmax
disruptor
diff --git a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/plugin/AbstractClassEnhancePluginDefineTest.java b/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/plugin/AbstractClassEnhancePluginDefineTest.java
new file mode 100644
index 000000000..e956292d5
--- /dev/null
+++ b/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/plugin/AbstractClassEnhancePluginDefineTest.java
@@ -0,0 +1,118 @@
+package com.a.eye.skywalking.api.plugin;
+
+import com.a.eye.skywalking.api.plugin.utility.ClassFileExtraction;
+
+import net.bytebuddy.agent.ByteBuddyAgent;
+import net.bytebuddy.agent.builder.AgentBuilder;
+import net.bytebuddy.description.type.TypeDescription;
+import net.bytebuddy.dynamic.DynamicType;
+import net.bytebuddy.dynamic.loading.ByteArrayClassLoader;
+import net.bytebuddy.dynamic.loading.PackageDefinitionStrategy;
+import net.bytebuddy.matcher.ElementMatchers;
+
+import org.hamcrest.CoreMatchers;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import java.lang.instrument.ClassFileTransformer;
+
+import static net.bytebuddy.matcher.ElementMatchers.none;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+@RunWith(PowerMockRunner.class)
+public class AbstractClassEnhancePluginDefineTest {
+ static final String WEAVE_CLASS = "com.a.eye.skywalking.api.plugin.TargetObject";
+ static final String INTERCEPTOR_CLASS = "com.a.eye.skywalking.api.plugin.MockPluginInterceptor";
+ static final String WEAVE_INSTANCE_METHOD_NAME = "instanceMethod";
+ static final String WEAVE_INSTANCE_WITH_EXCEPTION_METHOD_NAME = "instanceMethodWithException";
+ static final String WEAVE_STATIC_METHOD_NAME = "staticMethod";
+ private ClassLoader classLoader;
+
+ @Before
+ public void setUp() throws Exception {
+ classLoader = new ByteArrayClassLoader.ChildFirst(getClass().getClassLoader(),
+ ClassFileExtraction.of(TargetObject.class),
+ null,
+ ByteArrayClassLoader.PersistenceHandler.MANIFEST,
+ PackageDefinitionStrategy.NoOp.INSTANCE);
+ }
+
+ @Test
+ public void weaveInstanceMethod() throws Exception {
+ ByteBuddyAgent.install();
+ ClassFileTransformer classFileTransformer = new AgentBuilder.Default()
+ .with(AgentBuilder.PoolStrategy.Default.FAST)
+ .ignore(none())
+ .type(ElementMatchers.is(TargetObject.class), ElementMatchers.is(classLoader)).transform(new MockTargetObjectTransformer())
+ .installOnByteBuddyAgent();
+
+ try {
+ Class> type = classLoader.loadClass(TargetObject.class.getName());
+ assertThat(type.getDeclaredMethod(WEAVE_INSTANCE_METHOD_NAME).invoke(type.getDeclaredConstructor(String.class).newInstance("a"))
+ , CoreMatchers.