Commit fc58022d authored by Skylot's avatar Skylot

misc: show shorter exception stacktrace in code

parent ed9fe8a5
......@@ -17,10 +17,12 @@ import org.jetbrains.annotations.Nullable;
import jadx.api.JadxDecompiler;
import jadx.core.codegen.CodeWriter;
import jadx.core.dex.visitors.DepthTraversal;
public class Utils {
public static final String JADX_API_PACKAGE = JadxDecompiler.class.getPackage().getName();
private static final String JADX_API_PACKAGE = JadxDecompiler.class.getPackage().getName();
private static final String STACKTRACE_STOP_CLS_NAME = DepthTraversal.class.getName();
private Utils() {
}
......@@ -140,20 +142,16 @@ public class Utils {
private static void filter(Throwable th) {
StackTraceElement[] stackTrace = th.getStackTrace();
int cutIndex = -1;
int length = stackTrace.length;
for (int i = 0; i < length; i++) {
StackTraceElement stackTraceElement = stackTrace[i];
if (stackTraceElement.getClassName().startsWith(JADX_API_PACKAGE)) {
cutIndex = i;
} else if (cutIndex > 0) {
cutIndex = i;
break;
String clsName = stackTraceElement.getClassName();
if (clsName.equals(STACKTRACE_STOP_CLS_NAME)
|| clsName.startsWith(JADX_API_PACKAGE)) {
th.setStackTrace(Arrays.copyOfRange(stackTrace, 0, i));
return;
}
}
if (cutIndex > 0 && cutIndex < length) {
th.setStackTrace(Arrays.copyOfRange(stackTrace, 0, cutIndex));
}
}
public static <T, R> List<R> collectionMap(Collection<T> list, Function<T, R> mapFunc) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment