Skip to content

Commit 6982a1e

Browse files
committed
improve InstrumentTransformer match className
1 parent f83a9e6 commit 6982a1e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

bytekit-core/src/main/java/com/alibaba/bytekit/asm/instrument/InstrumentTransformer.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ public byte[] transform(ClassLoader loader, String className, Class<?> classBein
3939
ClassNode originClassNode = null;
4040
ClassNode targetClassNode = null;
4141
ClassReader classReader = null;
42+
if (!instrumentConfigs.isEmpty() && className == null && classfileBuffer != null) {
43+
// 提前获取类名,避免在 matcher 多次解析字节码
44+
className = AsmUtils.className(classfileBuffer);
45+
}
4246
for (InstrumentConfig config : instrumentConfigs) {
4347
if (config.getClassMatcher().match(loader, className, classBeingRedefined, protectionDomain,
4448
classfileBuffer)) {

0 commit comments

Comments
 (0)