From eec88f4bd962c4dca59fa347c63c5f714eb384e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=91=E6=88=9F?= Date: Sat, 17 Apr 2021 19:52:32 +0800 Subject: [PATCH] should convert package prefix to slash separated format --- .../agent/transformer/TestableClassTransformer.java | 1 + .../java/com/alibaba/testable/agent/util/GlobalConfig.java | 6 +++--- .../java/com/alibaba/testable/core/constant/ConstPool.java | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/testable-agent/src/main/java/com/alibaba/testable/agent/transformer/TestableClassTransformer.java b/testable-agent/src/main/java/com/alibaba/testable/agent/transformer/TestableClassTransformer.java index 22a1f48..8ef08a9 100644 --- a/testable-agent/src/main/java/com/alibaba/testable/agent/transformer/TestableClassTransformer.java +++ b/testable-agent/src/main/java/com/alibaba/testable/agent/transformer/TestableClassTransformer.java @@ -49,6 +49,7 @@ public class TestableClassTransformer implements ClassFileTransformer { // Ignore system class and reloaded class return null; } + // className is in slash-separated format LogUtil.verbose("Handle class: " + className); byte[] bytes = shouldOmniEnhance(className) ? new OmniClassHandler().getBytes(classFileBuffer) : classFileBuffer; ClassNode cn = ClassUtil.getClassNode(className); diff --git a/testable-agent/src/main/java/com/alibaba/testable/agent/util/GlobalConfig.java b/testable-agent/src/main/java/com/alibaba/testable/agent/util/GlobalConfig.java index 611d82c..c397b8a 100644 --- a/testable-agent/src/main/java/com/alibaba/testable/agent/util/GlobalConfig.java +++ b/testable-agent/src/main/java/com/alibaba/testable/agent/util/GlobalConfig.java @@ -11,6 +11,8 @@ import java.util.List; import static com.alibaba.testable.agent.constant.ConstPool.PROPERTY_TEMP_DIR; import static com.alibaba.testable.agent.constant.ConstPool.PROPERTY_USER_DIR; +import static com.alibaba.testable.core.constant.ConstPool.COMMA; +import static com.alibaba.testable.core.constant.ConstPool.DOT; import static com.alibaba.testable.core.util.PathUtil.createFolder; /** @@ -22,8 +24,6 @@ public class GlobalConfig { private static final String DEBUG = "debug"; private static final String VERBOSE = "verbose"; private static final String DISABLE_LOG_FILE = "null"; - private static final String COMMA = ","; - private static final String DOT = "."; private static final String TESTABLE_AGENT_LOG = "testable-agent.log"; private static final String DEFAULT_MAVEN_OUTPUT_FOLDER = "target"; private static final String DEFAULT_GRADLE_OUTPUT_FOLDER = "gradle"; @@ -142,7 +142,7 @@ public class GlobalConfig { private static List parsePkgPrefixList(String prefixes) { List whiteList = new ArrayList(); for (String p : prefixes.split(COMMA)) { - whiteList.add(p.endsWith(DOT) ? p : p + DOT); + whiteList.add(ClassUtil.toSlashSeparatedName(p.endsWith(DOT) ? p : p + DOT)); } return whiteList; } diff --git a/testable-core/src/main/java/com/alibaba/testable/core/constant/ConstPool.java b/testable-core/src/main/java/com/alibaba/testable/core/constant/ConstPool.java index b553c71..857ebec 100644 --- a/testable-core/src/main/java/com/alibaba/testable/core/constant/ConstPool.java +++ b/testable-core/src/main/java/com/alibaba/testable/core/constant/ConstPool.java @@ -21,5 +21,6 @@ public class ConstPool { public static final String SLASH = "/"; public static final String DOLLAR = "$"; public static final String UNDERLINE = "_"; + public static final String COMMA = ","; }