diff --git a/jadx-core/src/main/java/jadx/core/dex/attributes/nodes/MethodTypeVarsAttr.java b/jadx-core/src/main/java/jadx/core/dex/attributes/nodes/MethodTypeVarsAttr.java index e03a04633..ddc8eddcb 100644 --- a/jadx-core/src/main/java/jadx/core/dex/attributes/nodes/MethodTypeVarsAttr.java +++ b/jadx-core/src/main/java/jadx/core/dex/attributes/nodes/MethodTypeVarsAttr.java @@ -39,6 +39,9 @@ public class MethodTypeVarsAttr implements IAttribute { @Override public String toString() { + if (this == EMPTY) { + return "TYPE_VARS: EMPTY"; + } return "TYPE_VARS: " + typeVars; } } diff --git a/jadx-core/src/test/java/jadx/tests/api/IntegrationTest.java b/jadx-core/src/test/java/jadx/tests/api/IntegrationTest.java index 23becb7fa..477b08e41 100644 --- a/jadx-core/src/test/java/jadx/tests/api/IntegrationTest.java +++ b/jadx-core/src/test/java/jadx/tests/api/IntegrationTest.java @@ -40,6 +40,7 @@ import jadx.core.dex.nodes.MethodNode; import jadx.core.dex.nodes.RootNode; import jadx.core.utils.DebugChecks; import jadx.core.utils.Utils; +import jadx.core.utils.exceptions.JadxRuntimeException; import jadx.core.utils.files.FileUtils; import jadx.core.xmlgen.ResourceStorage; import jadx.core.xmlgen.entry.ResourceEntry; @@ -322,17 +323,18 @@ public abstract class IntegrationTest extends TestUtils { } try { limitExecTime(() -> checkMth.invoke(origCls.getConstructor().newInstance())); - } catch (Exception e) { - rethrow("Original check failed", e); + System.out.println("Source check: PASSED"); + } catch (Throwable e) { + throw new JadxRuntimeException("Source check failed", e); } // run 'check' method from decompiled class if (compile) { try { limitExecTime(() -> invoke(cls, "check")); - } catch (Exception e) { - rethrow("Decompiled check failed", e); + System.out.println("Decompiled check: PASSED"); + } catch (Throwable e) { + throw new JadxRuntimeException("Decompiled check failed", e); } - System.out.println("Auto check: PASSED"); } } catch (Exception e) { e.printStackTrace(); @@ -348,7 +350,7 @@ public abstract class IntegrationTest extends TestUtils { } catch (TimeoutException ex) { future.cancel(true); rethrow("Execution timeout", ex); - } catch (Exception ex) { + } catch (Throwable ex) { rethrow(ex.getMessage(), ex); } finally { executor.shutdownNow(); @@ -356,18 +358,15 @@ public abstract class IntegrationTest extends TestUtils { return null; } - private void rethrow(String msg, Throwable e) { + public static void rethrow(String msg, Throwable e) { if (e instanceof InvocationTargetException) { - Throwable cause = e.getCause(); - if (cause instanceof AssertionError) { - throw (AssertionError) cause; - } else { - fail(cause); - } + rethrow(msg, e.getCause()); } else if (e instanceof ExecutionException) { rethrow(e.getMessage(), e.getCause()); + } else if (e instanceof AssertionError) { + throw (AssertionError) e; } else { - fail(msg, e); + throw new RuntimeException(msg, e); } } diff --git a/jadx-core/src/test/java/jadx/tests/api/compiler/DynamicCompiler.java b/jadx-core/src/test/java/jadx/tests/api/compiler/DynamicCompiler.java index f73ab7b07..abfac92f3 100644 --- a/jadx-core/src/test/java/jadx/tests/api/compiler/DynamicCompiler.java +++ b/jadx-core/src/test/java/jadx/tests/api/compiler/DynamicCompiler.java @@ -15,10 +15,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import jadx.core.dex.nodes.ClassNode; +import jadx.tests.api.IntegrationTest; import static javax.tools.JavaCompiler.CompilationTask; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.fail; public class DynamicCompiler { @@ -71,8 +71,8 @@ public class DynamicCompiler { Method reflMth = getMethod(inst, methodName, types); assertNotNull(reflMth, "Failed to get method " + methodName + '(' + Arrays.toString(types) + ')'); return reflMth.invoke(inst, args); - } catch (Exception e) { - fail(e.getMessage(), e); + } catch (Throwable e) { + IntegrationTest.rethrow("Invoke error", e); return null; } }