use of com.shulie.instrument.simulator.api.filter.MultiClassNameFilter in project LinkAgent by shulieTech.
the class JadModule method processExactMatch.
private CommandResponse processExactMatch(Set<Class<?>> matchedClasses, Set<Class<?>> withInnerClasses, boolean sourceOnly) {
Class<?> c = matchedClasses.iterator().next();
Set<Class<?>> allClasses = new HashSet<Class<?>>(withInnerClasses);
allClasses.add(c);
final Set<String> classNames = toClassName(allClasses);
Filter filter = new MultiClassNameFilter(classNames, true);
DumpResult dumpResult = null;
try {
dumpResult = moduleEventWatcher.dump(filter, new NoActionProgress());
File classFile = dumpResult.getDumpResult().get(c.getName());
String source = Decompiler.decompile(classFile.getAbsolutePath(), simulatorConfig.getSimulatorVersion());
if (source != null) {
source = pattern.matcher(source).replaceAll("");
} else {
return CommandResponse.failure("can't decompile class file.");
}
if (sourceOnly) {
JadInfo jadInfo = new JadInfo();
jadInfo.setSource(source);
return CommandResponse.success(jadInfo);
}
JadInfo jadInfo = new JadInfo();
jadInfo.setClassloader(drawClassLoader(c));
jadInfo.setLocation(ClassUtils.getCodeSource(c.getProtectionDomain().getCodeSource()));
jadInfo.setSource(source);
return CommandResponse.success(jadInfo);
} catch (Throwable t) {
logger.error("SIMULATOR: jad: fail to decompile class: " + c.getName(), t);
return CommandResponse.failure(t);
} finally {
if (dumpResult != null) {
// 注销watchId
moduleEventWatcher.delete(dumpResult.getWatchId());
}
}
}
Aggregations