Add dex2jar exception handler

This commit is contained in:
Nico Mexis 2023-07-20 21:58:04 +02:00
parent 555d68ab42
commit ebdf389724
No known key found for this signature in database
GPG key ID: 27D6E17CE092AB78

View file

@ -1,6 +1,10 @@
package the.bytecode.club.bytecodeviewer.util; package the.bytecode.club.bytecodeviewer.util;
import com.googlecode.d2j.dex.Dex2jar; 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 java.io.File;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
@ -38,7 +42,16 @@ public class Dex2Jar {
*/ */
public static synchronized void dex2Jar(File input, File output) { public static synchronized void dex2Jar(File input, File output) {
try { 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()); d2Jar.to(output.toPath());
} catch (com.googlecode.d2j.DexException e) { } catch (com.googlecode.d2j.DexException e) {
e.printStackTrace(); e.printStackTrace();