From 2b27d477adbce24d3ddb77827ae72f058c5072fa Mon Sep 17 00:00:00 2001 From: wusheng Date: Mon, 13 Jun 2016 17:45:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AA=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interceptor/EnhanceClazz4Interceptor.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/EnhanceClazz4Interceptor.java b/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/EnhanceClazz4Interceptor.java index 49b570bf7..a32d58d99 100644 --- a/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/EnhanceClazz4Interceptor.java +++ b/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/EnhanceClazz4Interceptor.java @@ -1,8 +1,12 @@ package com.ai.cloud.skywalking.plugin.interceptor; -import com.ai.cloud.skywalking.plugin.PluginCfg; -import com.ai.cloud.skywalking.util.StringUtil; +import static net.bytebuddy.matcher.ElementMatchers.any; +import static net.bytebuddy.matcher.ElementMatchers.not; + +import java.util.List; + import net.bytebuddy.ByteBuddy; +import net.bytebuddy.description.method.MethodDescription; import net.bytebuddy.dynamic.ClassFileLocator; import net.bytebuddy.dynamic.DynamicType; import net.bytebuddy.dynamic.loading.ClassLoadingStrategy; @@ -13,13 +17,12 @@ import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatchers; import net.bytebuddy.pool.TypePool; import net.bytebuddy.pool.TypePool.Resolution; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import java.util.List; - -import static net.bytebuddy.matcher.ElementMatchers.any; -import static net.bytebuddy.matcher.ElementMatchers.not; +import com.ai.cloud.skywalking.plugin.PluginCfg; +import com.ai.cloud.skywalking.util.StringUtil; public class EnhanceClazz4Interceptor { private static Logger logger = LogManager @@ -116,7 +119,7 @@ public class EnhanceClazz4Interceptor { enhanceRules.append("\t" + ruleIdx++ + ". " + methodMatcher + "\n"); } logger.debug(enhanceRules); - ElementMatcher.Junction matcher = null; + ElementMatcher.Junction matcher = null; for (MethodMatcher methodMatcher : methodMatchers) { logger.debug("enhance class {} by rule: {}", enhanceOriginClassName, methodMatcher); @@ -129,7 +132,9 @@ public class EnhanceClazz4Interceptor { } - // TODO: not support static method now. will enhance it. + /** + * exclude static methods. + */ matcher = matcher.and(not(ElementMatchers.isStatic())); newClassBuilder = newClassBuilder.method(matcher).intercept( MethodDelegation.to(classMethodInterceptor));