mirror of
https://gitee.com/arthas/arthas.git
synced 2024-11-30 11:17:39 +08:00
Remove the useless resetClassFileTransformer in Enhancer (#1786)
This commit is contained in:
parent
843a3ed0aa
commit
adf7725618
@ -442,16 +442,8 @@ public class Enhancer implements ClassFileTransformer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final ClassFileTransformer resetClassFileTransformer = new ClassFileTransformer() {
|
|
||||||
@Override
|
|
||||||
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined,
|
|
||||||
ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
enhance(inst, resetClassFileTransformer, enhanceClassSet);
|
enhance(inst, enhanceClassSet);
|
||||||
logger.info("Success to reset classes: " + enhanceClassSet);
|
logger.info("Success to reset classes: " + enhanceClassSet);
|
||||||
} finally {
|
} finally {
|
||||||
for (Class<?> resetClass : enhanceClassSet) {
|
for (Class<?> resetClass : enhanceClassSet) {
|
||||||
@ -464,18 +456,13 @@ public class Enhancer implements ClassFileTransformer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 批量增强
|
// 批量增强
|
||||||
private static void enhance(Instrumentation inst, ClassFileTransformer transformer, Set<Class<?>> classes)
|
private static void enhance(Instrumentation inst, Set<Class<?>> classes)
|
||||||
throws UnmodifiableClassException {
|
throws UnmodifiableClassException {
|
||||||
try {
|
int size = classes.size();
|
||||||
inst.addTransformer(transformer, true);
|
Class<?>[] classArray = new Class<?>[size];
|
||||||
int size = classes.size();
|
arraycopy(classes.toArray(), 0, classArray, 0, size);
|
||||||
Class<?>[] classArray = new Class<?>[size];
|
if (classArray.length > 0) {
|
||||||
arraycopy(classes.toArray(), 0, classArray, 0, size);
|
inst.retransformClasses(classArray);
|
||||||
if (classArray.length > 0) {
|
|
||||||
inst.retransformClasses(classArray);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
inst.removeTransformer(transformer);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user