use of jadx.plugins.input.java.data.code.trycatch.JavaSingleCatch in project jadx by skylot.
the class JavaCodeReader method convertSingleCatches.
private static CatchData convertSingleCatches(List<JavaSingleCatch> list) {
int allHandler = -1;
for (JavaSingleCatch singleCatch : list) {
if (singleCatch.getType() == null) {
allHandler = singleCatch.getHandler();
list.remove(singleCatch);
break;
}
}
int len = list.size();
int[] handlers = new int[len];
String[] types = new String[len];
for (int i = 0; i < len; i++) {
JavaSingleCatch singleCatch = list.get(i);
handlers[i] = singleCatch.getHandler();
types[i] = singleCatch.getType();
}
return new CatchData(handlers, types, allHandler);
}
use of jadx.plugins.input.java.data.code.trycatch.JavaSingleCatch in project jadx by skylot.
the class JavaCodeReader method getTries.
@Override
public List<ITry> getTries() {
skipToTries();
int excTableLen = reader.readU2();
if (excTableLen == 0) {
return Collections.emptyList();
}
ConstPoolReader constPool = clsData.getConstPoolReader();
Map<JavaTryData, List<JavaSingleCatch>> tries = new HashMap<>(excTableLen);
for (int i = 0; i < excTableLen; i++) {
int start = reader.readU2();
int end = reader.readU2();
int handler = reader.readU2();
int type = reader.readU2();
JavaTryData tryData = new JavaTryData(start, end);
List<JavaSingleCatch> catches = tries.computeIfAbsent(tryData, k -> new ArrayList<>());
if (type == 0) {
catches.add(new JavaSingleCatch(handler, null));
} else {
catches.add(new JavaSingleCatch(handler, constPool.getClass(type)));
}
}
return tries.entrySet().stream().map(e -> {
JavaTryData tryData = e.getKey();
tryData.setCatch(convertSingleCatches(e.getValue()));
return tryData;
}).collect(Collectors.toList());
}
Aggregations