ASM Disassembler
Better Failing. Decompile to zip fallback added.
This commit is contained in:
parent
9391352953
commit
f94c03d178
|
@ -44,7 +44,7 @@ public enum Decompiler
|
|||
JD_DECOMPILER(new JDGUIDecompiler()), //java decompiler
|
||||
JADX_DECOMPILER(new JADXDecompiler()), //java decompiler
|
||||
|
||||
ASM_TEXTIFY_DISASSEMBLER(new ASMTextifierDisassembler()), //bytecode disassembler
|
||||
ASM_TEXTIFY_DISASSEMBLER(new ASMDisassembler()), //bytecode disassembler
|
||||
ASMIFIER_DECOMPILER(new ASMifierGenerator()), //bytecode disassembler / code gen
|
||||
JAVAP_DISASSEMBLER(new JavapDisassembler()); //bytecode disassembler
|
||||
|
||||
|
|
|
@ -21,19 +21,27 @@ package the.bytecode.club.bytecodeviewer.decompilers.impl;
|
|||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.util.Textifier;
|
||||
import org.objectweb.asm.util.TraceClassVisitor;
|
||||
import the.bytecode.club.bytecodeviewer.Constants;
|
||||
import the.bytecode.club.bytecodeviewer.api.ExceptionUI;
|
||||
import the.bytecode.club.bytecodeviewer.decompilers.AbstractDecompiler;
|
||||
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
|
||||
import the.bytecode.club.bytecodeviewer.util.ExceptionUtils;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import static the.bytecode.club.bytecodeviewer.Constants.NL;
|
||||
import static the.bytecode.club.bytecodeviewer.translation.TranslatedStrings.DEV_MODE_SIMULATED_ERROR;
|
||||
import static the.bytecode.club.bytecodeviewer.translation.TranslatedStrings.ERROR;
|
||||
|
||||
/**
|
||||
* Objectweb ASM Textifier output
|
||||
*
|
||||
* @author Thiakil
|
||||
*/
|
||||
public class ASMTextifierDisassembler extends AbstractDecompiler
|
||||
public class ASMDisassembler extends AbstractDecompiler
|
||||
{
|
||||
public ASMTextifierDisassembler()
|
||||
public ASMDisassembler()
|
||||
{
|
||||
super("ASM Disassembler", "asm");
|
||||
}
|
||||
|
@ -41,13 +49,35 @@ public class ASMTextifierDisassembler extends AbstractDecompiler
|
|||
@Override
|
||||
public String decompileClassNode(ClassNode cn, byte[] bytes)
|
||||
{
|
||||
StringWriter writer = new StringWriter();
|
||||
cn.accept(new TraceClassVisitor(null, new Textifier(), new PrintWriter(writer)));
|
||||
return writer.toString();
|
||||
String exception;
|
||||
|
||||
try
|
||||
{
|
||||
//create writer
|
||||
StringWriter writer = new StringWriter();
|
||||
|
||||
//initialize ASM-Textifier & parse class-file
|
||||
cn.accept(new TraceClassVisitor(null, new Textifier(), new PrintWriter(writer)));
|
||||
|
||||
//handle simulated errors
|
||||
if(Constants.DEV_FLAG_DECOMPILERS_SIMULATED_ERRORS)
|
||||
throw new RuntimeException(DEV_MODE_SIMULATED_ERROR.toString());
|
||||
|
||||
//return writer contents
|
||||
return writer.toString();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
exception = ExceptionUtils.exceptionToString(e);
|
||||
}
|
||||
|
||||
return "ASM Disassembler " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO + NL + NL
|
||||
+ TranslatedStrings.SUGGESTED_FIX_DECOMPILER_ERROR + NL + NL + exception;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decompileToZip(String sourceJar, String zipName)
|
||||
{
|
||||
decompileToZipFallBack(sourceJar, zipName);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user