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 {
|
||||
enhance(inst, resetClassFileTransformer, enhanceClassSet);
|
||||
enhance(inst, enhanceClassSet);
|
||||
logger.info("Success to reset classes: " + enhanceClassSet);
|
||||
} finally {
|
||||
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 {
|
||||
try {
|
||||
inst.addTransformer(transformer, true);
|
||||
int size = classes.size();
|
||||
Class<?>[] classArray = new Class<?>[size];
|
||||
arraycopy(classes.toArray(), 0, classArray, 0, size);
|
||||
if (classArray.length > 0) {
|
||||
inst.retransformClasses(classArray);
|
||||
}
|
||||
} finally {
|
||||
inst.removeTransformer(transformer);
|
||||
int size = classes.size();
|
||||
Class<?>[] classArray = new Class<?>[size];
|
||||
arraycopy(classes.toArray(), 0, classArray, 0, size);
|
||||
if (classArray.length > 0) {
|
||||
inst.retransformClasses(classArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user