You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2019/05/17 11:46:16 UTC

[skywalking] branch j9vm created (now f676dec)

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a change to branch j9vm
in repository https://gitbox.apache.org/repos/asf/skywalking.git.


      at f676dec  Try to add new class location strategy.

This branch includes the following new commits:

     new f676dec  Try to add new class location strategy.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[skywalking] 01/01: Try to add new class location strategy.

Posted by wu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch j9vm
in repository https://gitbox.apache.org/repos/asf/skywalking.git

commit f676dec0cdfb77f08f7dd0513f91961a9cb7e5c9
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Fri May 17 19:46:06 2019 +0800

    Try to add new class location strategy.
---
 .../skywalking/apm/agent/SkyWalkingAgent.java      | 45 ++++++++++++----------
 1 file changed, 24 insertions(+), 21 deletions(-)

diff --git a/apm-sniffer/apm-agent/src/main/java/org/apache/skywalking/apm/agent/SkyWalkingAgent.java b/apm-sniffer/apm-agent/src/main/java/org/apache/skywalking/apm/agent/SkyWalkingAgent.java
index 516c1cd..fd935b9 100644
--- a/apm-sniffer/apm-agent/src/main/java/org/apache/skywalking/apm/agent/SkyWalkingAgent.java
+++ b/apm-sniffer/apm-agent/src/main/java/org/apache/skywalking/apm/agent/SkyWalkingAgent.java
@@ -18,27 +18,22 @@
 
 package org.apache.skywalking.apm.agent;
 
+import java.lang.instrument.Instrumentation;
+import java.util.List;
 import net.bytebuddy.ByteBuddy;
 import net.bytebuddy.agent.builder.AgentBuilder;
 import net.bytebuddy.description.NamedElement;
 import net.bytebuddy.description.type.TypeDescription;
-import net.bytebuddy.dynamic.DynamicType;
+import net.bytebuddy.dynamic.*;
 import net.bytebuddy.dynamic.scaffold.TypeValidation;
-import net.bytebuddy.matcher.ElementMatcher;
-import net.bytebuddy.matcher.ElementMatchers;
+import net.bytebuddy.matcher.*;
 import net.bytebuddy.utility.JavaModule;
-import org.apache.skywalking.apm.agent.core.boot.AgentPackageNotFoundException;
-import org.apache.skywalking.apm.agent.core.boot.ServiceManager;
-import org.apache.skywalking.apm.agent.core.conf.Config;
-import org.apache.skywalking.apm.agent.core.conf.ConfigNotFoundException;
-import org.apache.skywalking.apm.agent.core.conf.SnifferConfigInitializer;
-import org.apache.skywalking.apm.agent.core.logging.api.ILog;
-import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
+import org.apache.skywalking.apm.agent.core.boot.*;
+import org.apache.skywalking.apm.agent.core.conf.*;
+import org.apache.skywalking.apm.agent.core.logging.api.*;
 import org.apache.skywalking.apm.agent.core.plugin.*;
 
-import java.lang.instrument.Instrumentation;
-import java.util.List;
-
+import static net.bytebuddy.dynamic.ClassFileLocator.ForClassLoader.ofBootLoader;
 import static net.bytebuddy.matcher.ElementMatchers.*;
 
 /**
@@ -80,16 +75,24 @@ public class SkyWalkingAgent {
         new AgentBuilder.Default(byteBuddy)
             .ignore(
                 nameStartsWith("net.bytebuddy.")
-                .or(nameStartsWith("org.slf4j."))
-                .or(nameStartsWith("org.apache.logging."))
-                .or(nameStartsWith("org.groovy."))
-                .or(nameContains("javassist"))
-                .or(nameContains(".asm."))
-                .or(nameStartsWith("sun.reflect"))
-                .or(allSkyWalkingAgentExcludeToolkit())
-                .or(ElementMatchers.<TypeDescription>isSynthetic()))
+                    .or(nameStartsWith("org.slf4j."))
+                    .or(nameStartsWith("org.apache.logging."))
+                    .or(nameStartsWith("org.groovy."))
+                    .or(nameContains("javassist"))
+                    .or(nameContains(".asm."))
+                    .or(nameStartsWith("sun.reflect"))
+                    .or(allSkyWalkingAgentExcludeToolkit())
+                    .or(ElementMatchers.<TypeDescription>isSynthetic()))
             .type(pluginFinder.buildMatch())
             .transform(new Transformer(pluginFinder))
+            .with(new AgentBuilder.LocationStrategy.Compound(
+                new AgentBuilder.LocationStrategy() {
+                    @Override public ClassFileLocator classFileLocator(ClassLoader classLoader, JavaModule module) {
+                        return ofBootLoader();
+                    }
+                },
+                AgentBuilder.LocationStrategy.ForClassLoader.STRONG
+            ))
             .with(new Listener())
             .installOn(instrumentation);