From ebdf3897248a986f53c682258b29b00e75f61fd2 Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Thu, 20 Jul 2023 21:58:04 +0200 Subject: [PATCH] Add dex2jar exception handler --- .../club/bytecodeviewer/util/Dex2Jar.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/Dex2Jar.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/Dex2Jar.java index 74d742d9..7632b088 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/Dex2Jar.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/Dex2Jar.java @@ -1,6 +1,10 @@ package the.bytecode.club.bytecodeviewer.util; import com.googlecode.d2j.dex.Dex2jar; +import com.googlecode.d2j.dex.DexExceptionHandler; +import com.googlecode.d2j.Method; +import com.googlecode.d2j.node.DexMethodNode; +import org.objectweb.asm.MethodVisitor; import java.io.File; import the.bytecode.club.bytecodeviewer.BytecodeViewer; @@ -38,7 +42,16 @@ public class Dex2Jar { */ public static synchronized void dex2Jar(File input, File output) { try { - Dex2jar d2Jar = Dex2jar.from(input); + Dex2jar d2Jar = Dex2jar.from(input) + .withExceptionHandler(new DexExceptionHandler() { + public void handleFileException(Exception e) { + e.printStackTrace(); + } + + public void handleMethodTranslateException(Method method, DexMethodNode methodNode, MethodVisitor mv, Exception e) { + e.printStackTrace(); + } + }); d2Jar.to(output.toPath()); } catch (com.googlecode.d2j.DexException e) { e.printStackTrace();