Decompiler Cleanup

This commit is contained in:
Konloch 2021-07-03 22:59:42 -07:00
parent 231fc93298
commit 08304d3db1
11 changed files with 121 additions and 134 deletions

View file

@ -200,12 +200,12 @@ public class CommandLineInput {
Thread.sleep(5 * 1000);
if (target.equalsIgnoreCase("all")) {
Decompiler.PROCYON.getDecompiler().decompileToZip(tempZip.getAbsolutePath(), output.getAbsolutePath());
Decompiler.PROCYON_DECOMPILER.getDecompiler().decompileToZip(tempZip.getAbsolutePath(), output.getAbsolutePath());
} else {
try {
ClassNode cn = BytecodeViewer.getClassNode(target);
final ClassWriter cw = accept(cn);
String contents = Decompiler.PROCYON.getDecompiler().decompileClassNode(cn, cw.toByteArray());
String contents = Decompiler.PROCYON_DECOMPILER.getDecompiler().decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(output.getAbsolutePath(), contents, false);
} catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
@ -218,12 +218,12 @@ public class CommandLineInput {
Thread.sleep(5 * 1000);
if (target.equalsIgnoreCase("all")) {
Decompiler.CFR.getDecompiler().decompileToZip(tempZip.getAbsolutePath(), output.getAbsolutePath());
Decompiler.CFR_DECOMPILER.getDecompiler().decompileToZip(tempZip.getAbsolutePath(), output.getAbsolutePath());
} else {
try {
ClassNode cn = BytecodeViewer.getClassNode(target);
final ClassWriter cw = accept(cn);
String contents = Decompiler.CFR.getDecompiler().decompileClassNode(cn, cw.toByteArray());
String contents = Decompiler.CFR_DECOMPILER.getDecompiler().decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(output.getAbsolutePath(), contents, false);
} catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
@ -236,12 +236,12 @@ public class CommandLineInput {
Thread.sleep(5 * 1000);
if (target.equalsIgnoreCase("all")) {
Decompiler.FERNFLOWER.getDecompiler().decompileToZip(tempZip.getAbsolutePath(), output.getAbsolutePath());
Decompiler.FERNFLOWER_DECOMPILER.getDecompiler().decompileToZip(tempZip.getAbsolutePath(), output.getAbsolutePath());
} else {
try {
ClassNode cn = BytecodeViewer.getClassNode(target);
final ClassWriter cw = accept(cn);
String contents = Decompiler.FERNFLOWER.getDecompiler().decompileClassNode(cn, cw.toByteArray());
String contents = Decompiler.FERNFLOWER_DECOMPILER.getDecompiler().decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(output.getAbsolutePath(), contents, false);
} catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
@ -254,12 +254,12 @@ public class CommandLineInput {
Thread.sleep(5 * 1000);
if (target.equalsIgnoreCase("all")) {
Decompiler.KRAKATAU.getDecompiler().decompileToZip(tempZip.getAbsolutePath(), output.getAbsolutePath());
Decompiler.KRAKATAU_DECOMPILER.getDecompiler().decompileToZip(tempZip.getAbsolutePath(), output.getAbsolutePath());
} else {
try {
ClassNode cn = BytecodeViewer.getClassNode(target);
final ClassWriter cw = accept(cn);
String contents = Decompiler.KRAKATAU.getDecompiler().decompileClassNode(cn, cw.toByteArray());
String contents = Decompiler.KRAKATAU_DECOMPILER.getDecompiler().decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(output.getAbsolutePath(), contents, false);
} catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
@ -278,7 +278,7 @@ public class CommandLineInput {
try {
ClassNode cn = BytecodeViewer.getClassNode(target);
final ClassWriter cw = accept(cn);
String contents = Decompiler.KRAKATAU_BYTECODE.getDecompiler().decompileClassNode(cn, cw.toByteArray());
String contents = Decompiler.KRAKATAU_DISASSEMBLER.getDecompiler().decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(output.getAbsolutePath(), contents, false);
} catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
@ -297,7 +297,7 @@ public class CommandLineInput {
try {
ClassNode cn = BytecodeViewer.getClassNode(target);
final ClassWriter cw = accept(cn);
String contents = Decompiler.JDGUI.getDecompiler().decompileClassNode(cn, cw.toByteArray());
String contents = Decompiler.JD_DECOMPILER.getDecompiler().decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(output.getAbsolutePath(), contents, false);
} catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
@ -316,7 +316,7 @@ public class CommandLineInput {
try {
ClassNode cn = BytecodeViewer.getClassNode(target);
final ClassWriter cw = accept(cn);
String contents = Decompiler.SMALI.getDecompiler().decompileClassNode(cn, cw.toByteArray());
String contents = Decompiler.SMALI_DISASSEMBLER.getDecompiler().decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(output.getAbsolutePath(), contents, false);
} catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
@ -335,7 +335,7 @@ public class CommandLineInput {
try {
ClassNode cn = BytecodeViewer.getClassNode(target);
final ClassWriter cw = accept(cn);
String contents = Decompiler.JADX.getDecompiler().decompileClassNode(cn, cw.toByteArray());
String contents = Decompiler.JADX_DECOMPILER.getDecompiler().decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(output.getAbsolutePath(), contents, false);
} catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);

View file

@ -4,6 +4,7 @@ import javax.swing.JFrame;
import me.konloch.kontainer.io.DiskReader;
import me.konloch.kontainer.io.DiskWriter;
import the.bytecode.club.bytecodeviewer.decompilers.Decompiler;
import the.bytecode.club.bytecodeviewer.gui.theme.LAFTheme;
import the.bytecode.club.bytecodeviewer.gui.theme.RSTATheme;
import the.bytecode.club.bytecodeviewer.translation.Language;
@ -211,9 +212,9 @@ public class SettingsSerializer
DiskWriter.writeNewLine(settingsName,
String.valueOf(BytecodeViewer.viewer.updateCheck.isSelected()), false);
DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.viewPane1.getSelectedViewer()), false);
DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.viewPane2.getSelectedViewer()), false);
DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.viewPane3.getSelectedViewer()), false);
DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.viewPane1.getSelectedDecompiler().ordinal()), false);
DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.viewPane2.getSelectedDecompiler().ordinal()), false);
DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.viewPane3.getSelectedDecompiler().ordinal()), false);
DiskWriter.writeNewLine(settingsName,
String.valueOf(BytecodeViewer.viewer.refreshOnChange.isSelected()), false);
@ -409,9 +410,9 @@ public class SettingsSerializer
BytecodeViewer.viewer.debugHelpers.setSelected(asBoolean(78));
//79 is deprecated
BytecodeViewer.viewer.updateCheck.setSelected(asBoolean(80));
BytecodeViewer.viewer.viewPane1.setSelectedViewer(asInt(81));
BytecodeViewer.viewer.viewPane2.setSelectedViewer(asInt(82));
BytecodeViewer.viewer.viewPane3.setSelectedViewer(asInt(83));
BytecodeViewer.viewer.viewPane1.setSelectedDecompiler(Decompiler.values()[asInt(81)]);
BytecodeViewer.viewer.viewPane2.setSelectedDecompiler(Decompiler.values()[asInt(82)]);
BytecodeViewer.viewer.viewPane3.setSelectedDecompiler(Decompiler.values()[asInt(83)]);
BytecodeViewer.viewer.refreshOnChange.setSelected(asBoolean(84));

View file

@ -251,7 +251,7 @@ public class BytecodeViewer {
* @return The wrapped Krakatau Decompiler instance
*/
public static InternalDecompiler getKrakatauDecompiler() {
return Decompiler.KRAKATAU.getDecompiler();
return Decompiler.KRAKATAU_DECOMPILER.getDecompiler();
}
/**
@ -260,7 +260,7 @@ public class BytecodeViewer {
* @return The wrapped Procyon Decompiler instance
*/
public static InternalDecompiler getProcyonDecompiler() {
return Decompiler.PROCYON.getDecompiler();
return Decompiler.PROCYON_DECOMPILER.getDecompiler();
}
/**
@ -269,7 +269,7 @@ public class BytecodeViewer {
* @return The wrapped CFR Decompiler instance
*/
public static InternalDecompiler getCFRDecompiler() {
return Decompiler.CFR.getDecompiler();
return Decompiler.CFR_DECOMPILER.getDecompiler();
}
/**
@ -278,7 +278,7 @@ public class BytecodeViewer {
* @return The wrapped FernFlower Decompiler instance
*/
public static InternalDecompiler getFernFlowerDecompiler() {
return Decompiler.FERNFLOWER.getDecompiler();
return Decompiler.FERNFLOWER_DECOMPILER.getDecompiler();
}
/**
@ -287,7 +287,7 @@ public class BytecodeViewer {
* @return The wrapped Krakatau Disassembler instance
*/
public static InternalDecompiler getKrakatauDisassembler() {
return Decompiler.KRAKATAU_BYTECODE.getDecompiler();
return Decompiler.KRAKATAU_DISASSEMBLER.getDecompiler();
}
/**
@ -296,7 +296,7 @@ public class BytecodeViewer {
* @return The wrapped JD-GUI Decompiler instance
*/
public static InternalDecompiler getDJGUIDecompiler() {
return Decompiler.JDGUI.getDecompiler();
return Decompiler.JD_DECOMPILER.getDecompiler();
}
/**
@ -305,7 +305,7 @@ public class BytecodeViewer {
* @return The wrapped JADX Decompiler instance
*/
public static InternalDecompiler getJADXDecompiler() {
return Decompiler.JADX.getDecompiler();
return Decompiler.JADX_DECOMPILER.getDecompiler();
}
/**

View file

@ -5,7 +5,6 @@ import the.bytecode.club.bytecodeviewer.decompilers.bytecode.ClassNodeDecompiler
import the.bytecode.club.bytecodeviewer.gui.components.DecompilerViewComponent;
import javax.swing.*;
import java.util.HashMap;
/***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
@ -32,45 +31,34 @@ import java.util.HashMap;
*/
public enum Decompiler
{
NONE(0, "None", null, (JRadioButtonMenuItem) null),
PROCYON(1, "Procyon Decompiler", new ProcyonDecompiler(), new DecompilerViewComponent("Procyon")),
CFR(2, "CFR Decompiler", new CFRDecompiler(), new DecompilerViewComponent("Procyon")),
FERNFLOWER(3, "FernFlower Decompiler", new FernFlowerDecompiler(), new DecompilerViewComponent("Procyon")),
BYTECODE(4, "Bytecode Disassembler", new ClassNodeDecompiler(), new JRadioButtonMenuItem("Bytecode")),
HEXCODE(5, "Hexcode Viewer", null, new JRadioButtonMenuItem("Hexcode")),
SMALI(6, "Smali Decompiler", new SmaliDisassembler(), new DecompilerViewComponent("Smali")),
KRAKATAU(7, "Krakatau Decompiler", new KrakatauDecompiler(), BytecodeViewer.krakatau),
KRAKATAU_BYTECODE(8, "Krakatau Disassembler", new KrakatauDisassembler(), BytecodeViewer.krakatau),
JDGUI(9, "JD-GUI Decompiler", new JDGUIDecompiler(), new DecompilerViewComponent("Bytecode")),
JADX(10, "JADX Decompiler", new JADXDecompiler(), new DecompilerViewComponent("JADX")),
ASMTextify(11, "ASM Disassembler", new ASMTextifierDecompiler(), new DecompilerViewComponent("ASM Textify")),
NONE("None", null, (JRadioButtonMenuItem) null),
PROCYON_DECOMPILER("Procyon Decompiler", new ProcyonDecompiler(), new DecompilerViewComponent("Procyon")),
CFR_DECOMPILER("CFR Decompiler", new CFRDecompiler(), new DecompilerViewComponent("Procyon")),
FERNFLOWER_DECOMPILER("FernFlower Decompiler", new FernFlowerDecompiler(), new DecompilerViewComponent("Procyon")),
BYTECODE_DISASSEMBLER("Bytecode Disassembler", new ClassNodeDecompiler(), new JRadioButtonMenuItem("Bytecode")),
HEXCODE_VIEWER("Hexcode Viewer", null, new JRadioButtonMenuItem("Hexcode")),
SMALI_DISASSEMBLER("Smali Decompiler", new SmaliDisassembler(), new DecompilerViewComponent("Smali")),
KRAKATAU_DECOMPILER("Krakatau Decompiler", new KrakatauDecompiler(), BytecodeViewer.krakatau),
KRAKATAU_DISASSEMBLER("Krakatau Disassembler", new KrakatauDisassembler(), BytecodeViewer.krakatau),
JD_DECOMPILER("JD-GUI Decompiler", new JDGUIDecompiler(), new DecompilerViewComponent("Bytecode")),
JADX_DECOMPILER("JADX Decompiler", new JADXDecompiler(), new DecompilerViewComponent("JADX")),
ASM_TEXTIFY_DISASSEMBLER("ASM Disassembler", new ASMTextifierDecompiler(), new DecompilerViewComponent("ASM Textify")),
;
private final int decompilerIndex;
private final String decompilerName;
private final InternalDecompiler decompiler;
private final DecompilerViewComponent decompilerSelectComponent;
private final JRadioButtonMenuItem basicSelectComponent;
public static final HashMap<Integer, Decompiler> decompilersByIndex = new HashMap<>();
static
{
for(Decompiler d : values())
decompilersByIndex.put(d.decompilerIndex, d);
}
Decompiler(int decompilerIndex, String decompilerName, InternalDecompiler decompiler, DecompilerViewComponent decompilerSelectComponent) {
this.decompilerIndex = decompilerIndex;
Decompiler(String decompilerName, InternalDecompiler decompiler, DecompilerViewComponent decompilerSelectComponent) {
this.decompilerName = decompilerName;
this.decompiler = decompiler;
this.decompilerSelectComponent = decompilerSelectComponent;
this.basicSelectComponent = null;
}
Decompiler(int decompilerIndex, String decompilerName, InternalDecompiler decompiler, JRadioButtonMenuItem basicSelectComponent)
Decompiler(String decompilerName, InternalDecompiler decompiler, JRadioButtonMenuItem basicSelectComponent)
{
this.decompilerIndex = decompilerIndex;
this.decompilerName = decompilerName;
this.decompiler = decompiler;
this.decompilerSelectComponent = null;
@ -85,11 +73,6 @@ public enum Decompiler
group.add(basicSelectComponent);
}
public int getDecompilerIndex()
{
return decompilerIndex;
}
public String getDecompilerName()
{
return decompilerName;

View file

@ -43,7 +43,7 @@ public class MethodsRenderer extends JLabel implements ListCellRenderer<Object>
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected,
boolean cellHasFocus)
{
MethodParser methods = paneUpdaterThread.viewer.methods.get(paneUpdaterThread.decompilerViewIndex);
MethodParser methods = paneUpdaterThread.viewer.methods.get(paneUpdaterThread.resourceViewPanel.decompiler.ordinal());
MethodParser.Method method = methods.getMethod((Integer) value);
setText(method.toString());
return this;

View file

@ -72,77 +72,77 @@ public class DecompilerSelectionPane
menu.add(asmTextify);
}
public int getSelectedViewer()
public Decompiler getSelectedDecompiler()
{
if (group.isSelected(none.getModel()))
return 0;
return Decompiler.NONE;
else if (group.isSelected(procyon.getJava().getModel()))
return 1;
return Decompiler.PROCYON_DECOMPILER;
else if (group.isSelected(CFR.getJava().getModel()))
return 2;
return Decompiler.CFR_DECOMPILER;
else if (group.isSelected(fern.getJava().getModel()))
return 3;
return Decompiler.FERNFLOWER_DECOMPILER;
else if (group.isSelected(bytecode.getModel()))
return 4;
return Decompiler.BYTECODE_DISASSEMBLER;
else if (group.isSelected(hexcode.getModel()))
return 5;
return Decompiler.HEXCODE_VIEWER;
else if (group.isSelected(smali.getJava().getModel()))
return 6;
return Decompiler.SMALI_DISASSEMBLER;
else if (group.isSelected(krakatau.getJava().getModel()))
return 7;
return Decompiler.KRAKATAU_DECOMPILER;
else if (group.isSelected(krakatau.getBytecode().getModel()))
return 8;
return Decompiler.KRAKATAU_DISASSEMBLER;
else if (group.isSelected(JD.getJava().getModel()))
return 9;
return Decompiler.JD_DECOMPILER;
else if (group.isSelected(JADX.getJava().getModel()))
return 10;
return Decompiler.JADX_DECOMPILER;
else if (group.isSelected(asmTextify.getModel()))
return 11;
return Decompiler.ASM_TEXTIFY_DISASSEMBLER;
System.out.println("DEFAULTING TO NULL");
//default to none
return 0;
return Decompiler.NONE;
}
public void setSelectedViewer(int decompiler)
public void setSelectedDecompiler(Decompiler decompiler)
{
switch (decompiler)
{
case 0:
case NONE:
group.setSelected(none.getModel(), true);
break;
case 1:
case PROCYON_DECOMPILER:
group.setSelected(procyon.getJava().getModel(), true);
break;
case 2:
case CFR_DECOMPILER:
group.setSelected(CFR.getJava().getModel(), true);
break;
case 3:
case FERNFLOWER_DECOMPILER:
group.setSelected(fern.getJava().getModel(), true);
break;
case 4:
case BYTECODE_DISASSEMBLER:
group.setSelected(bytecode.getModel(), true);
break;
case 5:
case HEXCODE_VIEWER:
group.setSelected(hexcode.getModel(), true);
break;
case 6:
case SMALI_DISASSEMBLER:
group.setSelected(smali.getJava().getModel(), true);
break;
case 7:
case KRAKATAU_DECOMPILER:
group.setSelected(krakatau.getJava().getModel(), true);
break;
case 8:
case KRAKATAU_DISASSEMBLER:
group.setSelected(krakatau.getBytecode().getModel(), true);
break;
case 9:
case JD_DECOMPILER:
group.setSelected(JD.getJava().getModel(), true);
break;
case 10:
case JADX_DECOMPILER:
group.setSelected(JADX.getJava().getModel(), true);
break;
case 11:
case ASM_TEXTIFY_DISASSEMBLER:
group.setSelected(asmTextify.getModel(), true);
break;
}

View file

@ -1,5 +1,6 @@
package the.bytecode.club.bytecodeviewer.gui.resourceviewer;
import the.bytecode.club.bytecodeviewer.decompilers.Decompiler;
import the.bytecode.club.bytecodeviewer.gui.components.SearchableRSyntaxTextArea;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ClassViewer;
import the.bytecode.club.bytecodeviewer.gui.util.PaneUpdaterThread;
@ -34,7 +35,7 @@ public class ResourceViewPanel
public final JPanel panel = new JPanel(new BorderLayout());
public ClassViewer viewer;
public int decompilerViewIndex = -1;
public Decompiler decompiler = Decompiler.NONE;
public SearchableRSyntaxTextArea textArea;
public PaneUpdaterThread updateThread;
public final int panelIndex;

View file

@ -48,7 +48,7 @@ public class ResourceViewProcessing extends PaneUpdaterThread
public ResourceViewProcessing(ResourceViewPanel resourceViewPanel, ClassViewer cv, byte[] b, boolean isPanelEditable, JButton button)
{
super(cv, resourceViewPanel.panelIndex, resourceViewPanel.decompilerViewIndex);
super(cv, resourceViewPanel);
this.resourceViewPanel = resourceViewPanel;
this.b = b;
this.isPanelEditable = isPanelEditable;
@ -57,16 +57,16 @@ public class ResourceViewProcessing extends PaneUpdaterThread
}
@Override
public void doShit()
public void processDisplay()
{
try
{
BytecodeViewer.viewer.updateBusyStatus(true);
if (resourceViewPanel.decompilerViewIndex > 0)
if (resourceViewPanel.decompiler != Decompiler.NONE)
{
//hex viewer
if (resourceViewPanel.decompilerViewIndex == 5)
if (resourceViewPanel.decompiler == Decompiler.HEXCODE_VIEWER)
{
final ClassWriter cw = new ClassWriter(0);
viewer.cn.accept(cw);
@ -81,7 +81,7 @@ public class ResourceViewProcessing extends PaneUpdaterThread
}
else
{
final Decompiler decompiler = Decompiler.decompilersByIndex.get(resourceViewPanel.decompilerViewIndex);
final Decompiler decompiler = resourceViewPanel.decompiler;
//perform decompiling inside of this thread
final String decompiledSource = decompiler.getDecompiler().decompileClassNode(viewer.cn, b);

View file

@ -1,5 +1,6 @@
package the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer;
import the.bytecode.club.bytecodeviewer.decompilers.Decompiler;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.ResourcePanelCompileMode;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.ResourceViewPanel;
import the.bytecode.club.bytecodeviewer.gui.hexviewer.JHexEditor;
@ -104,24 +105,24 @@ public class ClassViewer extends ResourceViewer
{
sp.setResizeWeight(0.5);
if (resourceViewPanel2.decompilerViewIndex != 0 && resourceViewPanel1.decompilerViewIndex != 0) {
if (resourceViewPanel2.decompiler != Decompiler.NONE && resourceViewPanel1.decompiler != Decompiler.NONE) {
setDividerLocation(sp, 0.5);
} else if (resourceViewPanel1.decompilerViewIndex != 0) {
} else if (resourceViewPanel1.decompiler != Decompiler.NONE) {
setDividerLocation(sp, 1);
} else if (resourceViewPanel2.decompilerViewIndex != 0) {
} else if (resourceViewPanel2.decompiler != Decompiler.NONE) {
sp.setResizeWeight(1);
setDividerLocation(sp, 0);
} else {
setDividerLocation(sp, 0);
}
if (resourceViewPanel3.decompilerViewIndex != 0) {
if (resourceViewPanel3.decompiler != Decompiler.NONE) {
sp2.setResizeWeight(0.7);
setDividerLocation(sp2, 0.7);
if ((resourceViewPanel2.decompilerViewIndex == 0 && resourceViewPanel1.decompilerViewIndex != 0)
|| (resourceViewPanel1.decompilerViewIndex == 0 && resourceViewPanel2.decompilerViewIndex != 0)) {
if ((resourceViewPanel2.decompiler == Decompiler.NONE && resourceViewPanel1.decompiler != Decompiler.NONE)
|| (resourceViewPanel1.decompiler == Decompiler.NONE && resourceViewPanel2.decompiler != Decompiler.NONE)) {
setDividerLocation(sp2, 0.5);
} else if (resourceViewPanel1.decompilerViewIndex == 0) {
} else if (resourceViewPanel1.decompiler == Decompiler.NONE) {
setDividerLocation(sp2, 0);
}
} else {
@ -175,11 +176,11 @@ public class ClassViewer extends ResourceViewer
BytecodeViewer.viewer.updateBusyStatus(false);
if (resourceViewPanel1.decompilerViewIndex > 0)
if (resourceViewPanel1.decompiler != Decompiler.NONE)
resourceViewPanel1.updateThread.startNewThread();
if (resourceViewPanel2.decompilerViewIndex > 0)
if (resourceViewPanel2.decompiler != Decompiler.NONE)
resourceViewPanel2.updateThread.startNewThread();
if (resourceViewPanel3.decompilerViewIndex > 0)
if (resourceViewPanel3.decompiler != Decompiler.NONE)
resourceViewPanel3.updateThread.startNewThread();
}, "ClassViewer Temp Dump");
t.start();
@ -246,9 +247,9 @@ public class ClassViewer extends ResourceViewer
}
public void setPanes() {
resourceViewPanel1.decompilerViewIndex = BytecodeViewer.viewer.viewPane1.getSelectedViewer();
resourceViewPanel2.decompilerViewIndex = BytecodeViewer.viewer.viewPane2.getSelectedViewer();
resourceViewPanel3.decompilerViewIndex = BytecodeViewer.viewer.viewPane3.getSelectedViewer();
resourceViewPanel1.decompiler = BytecodeViewer.viewer.viewPane1.getSelectedDecompiler();
resourceViewPanel2.decompiler = BytecodeViewer.viewer.viewPane2.getSelectedDecompiler();
resourceViewPanel3.decompiler = BytecodeViewer.viewer.viewPane3.getSelectedDecompiler();
}
public boolean isPanel1Editable() {

View file

@ -13,8 +13,10 @@ import javax.swing.event.ChangeListener;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.fife.ui.rtextarea.RTextScrollPane;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.decompilers.Decompiler;
import the.bytecode.club.bytecodeviewer.gui.components.MethodsRenderer;
import the.bytecode.club.bytecodeviewer.gui.components.SearchableRSyntaxTextArea;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.ResourceViewPanel;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ClassViewer;
import the.bytecode.club.bytecodeviewer.util.MethodParser;
@ -48,20 +50,18 @@ import static the.bytecode.club.bytecodeviewer.gui.resourceviewer.TabbedPane.BLA
public abstract class PaneUpdaterThread implements Runnable
{
public final ClassViewer viewer;
public final int paneIndex;
public final int decompilerViewIndex;
public final ResourceViewPanel resourceViewPanel;
public SearchableRSyntaxTextArea updateUpdaterTextArea;
public JComboBox<Integer> methodsList;
private Thread thread;
public PaneUpdaterThread(ClassViewer viewer, int paneIndex, int decompilerViewIndex)
public PaneUpdaterThread(ClassViewer viewer, ResourceViewPanel resourceViewPanel)
{
this.viewer = viewer;
this.paneIndex = paneIndex;
this.decompilerViewIndex = decompilerViewIndex;
this.resourceViewPanel = resourceViewPanel;
}
public abstract void doShit();
public abstract void processDisplay();
public void startNewThread()
{
@ -72,10 +72,10 @@ public abstract class PaneUpdaterThread implements Runnable
@Override
public void run()
{
if(decompilerViewIndex == 0)
if(resourceViewPanel.decompiler == Decompiler.NONE)
return;
doShit();
processDisplay();
//this still freezes the swing UI
synchronizePane();
@ -114,7 +114,7 @@ public abstract class PaneUpdaterThread implements Runnable
@Override
public void caretUpdate(CaretEvent e)
{
MethodParser methods = viewer.methods.get(paneIndex);
MethodParser methods = viewer.methods.get(resourceViewPanel.panelIndex);
if (methods != null)
{
int methodLine = methods.findActiveMethod(updateUpdaterTextArea.getCaretLineNumber());
@ -133,7 +133,7 @@ public abstract class PaneUpdaterThread implements Runnable
panes = 3;
for (int i = 0; i < panes; i++) {
if (i != paneIndex) {
if (i != resourceViewPanel.panelIndex) {
ClassViewer.selectMethod(viewer, i, methods.getMethod(methodLine));
}
}
@ -159,7 +159,7 @@ public abstract class PaneUpdaterThread implements Runnable
activeViewLine;
int activeLineDelta = -1;
MethodParser.Method activeMethod = null;
MethodParser activeMethods = viewer.methods.get(paneIndex);
MethodParser activeMethods = viewer.methods.get(resourceViewPanel.panelIndex);
if (activeMethods != null) {
int activeMethodLine = activeMethods.findActiveMethod(activeLine);
if (activeMethodLine != -1) {
@ -169,7 +169,7 @@ public abstract class PaneUpdaterThread implements Runnable
}
}
for (int i = 0; i < panes; i++) {
if (i != paneIndex) {
if (i != resourceViewPanel.panelIndex) {
int setLine = -1;
RSyntaxTextArea area = null;
@ -213,7 +213,8 @@ public abstract class PaneUpdaterThread implements Runnable
public void synchronizePane()
{
if(decompilerViewIndex == 5 || decompilerViewIndex < 0)
if(resourceViewPanel.decompiler == Decompiler.HEXCODE_VIEWER
|| resourceViewPanel.decompiler == Decompiler.NONE)
return;
SwingUtilities.invokeLater(()->
@ -223,7 +224,7 @@ public abstract class PaneUpdaterThread implements Runnable
updateUpdaterTextArea.addCaretListener(caretListener);
});
final MethodParser methods = viewer.methods.get(paneIndex);
final MethodParser methods = viewer.methods.get(resourceViewPanel.panelIndex);
for (int i = 0; i < updateUpdaterTextArea.getLineCount(); i++)
{
String lineText = updateUpdaterTextArea.getLineText(i);
@ -252,7 +253,7 @@ public abstract class PaneUpdaterThread implements Runnable
int line = (int) Objects.requireNonNull(methodsList.getSelectedItem());
RSyntaxTextArea area = null;
switch (paneIndex)
switch (resourceViewPanel.panelIndex)
{
case 0:
area = viewer.resourceViewPanel1.updateThread.updateUpdaterTextArea;

View file

@ -83,7 +83,7 @@ public class ResourceDecompiling
if (result == 0) {
Thread t12 = new Thread(() -> {
try {
Decompiler.PROCYON.getDecompiler().decompileToZip(tempZip.getAbsolutePath(),
Decompiler.PROCYON_DECOMPILER.getDecompiler().decompileToZip(tempZip.getAbsolutePath(),
MiscUtils.append(javaSucks, "-proycon.zip"));
BytecodeViewer.viewer.updateBusyStatus(false);
} catch (Exception e) {
@ -94,7 +94,7 @@ public class ResourceDecompiling
Thread t2 = new Thread(() -> {
try {
BytecodeViewer.viewer.updateBusyStatus(true);
Decompiler.CFR.getDecompiler().decompileToZip(tempZip.getAbsolutePath(),
Decompiler.CFR_DECOMPILER.getDecompiler().decompileToZip(tempZip.getAbsolutePath(),
MiscUtils.append(javaSucks, "-CFR.zip"));
BytecodeViewer.viewer.updateBusyStatus(false);
} catch (Exception e) {
@ -105,7 +105,7 @@ public class ResourceDecompiling
Thread t3 = new Thread(() -> {
try {
BytecodeViewer.viewer.updateBusyStatus(true);
Decompiler.FERNFLOWER.getDecompiler().decompileToZip(tempZip.getAbsolutePath(),
Decompiler.FERNFLOWER_DECOMPILER.getDecompiler().decompileToZip(tempZip.getAbsolutePath(),
MiscUtils.append(javaSucks, "-fernflower.zip"));
BytecodeViewer.viewer.updateBusyStatus(false);
} catch (Exception e) {
@ -116,7 +116,7 @@ public class ResourceDecompiling
Thread t4 = new Thread(() -> {
try {
BytecodeViewer.viewer.updateBusyStatus(true);
Decompiler.KRAKATAU.getDecompiler().decompileToZip(tempZip.getAbsolutePath(),
Decompiler.KRAKATAU_DECOMPILER.getDecompiler().decompileToZip(tempZip.getAbsolutePath(),
MiscUtils.append(javaSucks, "-kraktau.zip"));
BytecodeViewer.viewer.updateBusyStatus(false);
} catch (Exception e) {
@ -128,7 +128,7 @@ public class ResourceDecompiling
if (result == 1) {
Thread t12 = new Thread(() -> {
try {
Decompiler.PROCYON.getDecompiler().decompileToZip(tempZip.getAbsolutePath(), path);
Decompiler.PROCYON_DECOMPILER.getDecompiler().decompileToZip(tempZip.getAbsolutePath(), path);
BytecodeViewer.viewer.updateBusyStatus(false);
} catch (Exception e) {
new ExceptionUI(e);
@ -139,7 +139,7 @@ public class ResourceDecompiling
if (result == 2) {
Thread t12 = new Thread(() -> {
try {
Decompiler.CFR.getDecompiler().decompileToZip(tempZip.getAbsolutePath(), path);
Decompiler.CFR_DECOMPILER.getDecompiler().decompileToZip(tempZip.getAbsolutePath(), path);
BytecodeViewer.viewer.updateBusyStatus(false);
} catch (Exception e) {
new ExceptionUI(e);
@ -150,7 +150,7 @@ public class ResourceDecompiling
if (result == 3) {
Thread t12 = new Thread(() -> {
try {
Decompiler.FERNFLOWER.getDecompiler().decompileToZip(tempZip.getAbsolutePath(), path);
Decompiler.FERNFLOWER_DECOMPILER.getDecompiler().decompileToZip(tempZip.getAbsolutePath(), path);
BytecodeViewer.viewer.updateBusyStatus(false);
} catch (Exception e) {
new ExceptionUI(e);
@ -162,7 +162,7 @@ public class ResourceDecompiling
if (result == 4) {
Thread t12 = new Thread(() -> {
try {
Decompiler.KRAKATAU.getDecompiler().decompileToZip(tempZip.getAbsolutePath(), path);
Decompiler.KRAKATAU_DECOMPILER.getDecompiler().decompileToZip(tempZip.getAbsolutePath(), path);
BytecodeViewer.viewer.updateBusyStatus(false);
} catch (Exception e) {
new ExceptionUI(e);
@ -245,28 +245,28 @@ public class ResourceDecompiling
try {
DiskWriter.replaceFile(MiscUtils.append(file, "-proycon.java"),
Decompiler.PROCYON.getDecompiler().decompileClassNode(cn, cw.toByteArray()), false);
Decompiler.PROCYON_DECOMPILER.getDecompiler().decompileClassNode(cn, cw.toByteArray()), false);
} catch (Exception e) {
e.printStackTrace();
}
try {
DiskWriter.replaceFile(MiscUtils.append(file, "-CFR.java"),
Decompiler.CFR.getDecompiler().decompileClassNode(cn, cw.toByteArray()), false);
Decompiler.CFR_DECOMPILER.getDecompiler().decompileClassNode(cn, cw.toByteArray()), false);
} catch (Exception e) {
e.printStackTrace();
}
try {
DiskWriter.replaceFile(MiscUtils.append(file, "-fernflower.java"),
Decompiler.FERNFLOWER.getDecompiler().decompileClassNode(cn, cw.toByteArray()), false);
Decompiler.FERNFLOWER_DECOMPILER.getDecompiler().decompileClassNode(cn, cw.toByteArray()), false);
} catch (Exception e) {
e.printStackTrace();
}
try {
DiskWriter.replaceFile(MiscUtils.append(file, "-kraktau.java"),
Decompiler.KRAKATAU.getDecompiler().decompileClassNode(cn, cw.toByteArray()), false);
Decompiler.KRAKATAU_DECOMPILER.getDecompiler().decompileClassNode(cn, cw.toByteArray()), false);
} catch (Exception e) {
e.printStackTrace();
}
@ -294,7 +294,7 @@ public class ResourceDecompiling
} catch (InterruptedException ignored) {
}
}
String contents = Decompiler.PROCYON.getDecompiler().decompileClassNode(cn, cw.toByteArray());
String contents = Decompiler.PROCYON_DECOMPILER.getDecompiler().decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(path, contents, false);
BytecodeViewer.viewer.updateBusyStatus(false);
} catch (Exception e) {
@ -320,7 +320,7 @@ public class ResourceDecompiling
} catch (InterruptedException ignored) {
}
}
String contents = Decompiler.CFR.getDecompiler().decompileClassNode(cn, cw.toByteArray());
String contents = Decompiler.CFR_DECOMPILER.getDecompiler().decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(path, contents, false);
BytecodeViewer.viewer.updateBusyStatus(false);
} catch (Exception e) {
@ -347,7 +347,7 @@ public class ResourceDecompiling
} catch (InterruptedException ignored) {
}
}
String contents = Decompiler.FERNFLOWER.getDecompiler().decompileClassNode(cn,
String contents = Decompiler.FERNFLOWER_DECOMPILER.getDecompiler().decompileClassNode(cn,
cw.toByteArray());
DiskWriter.replaceFile(path, contents, false);
BytecodeViewer.viewer.updateBusyStatus(false);
@ -375,7 +375,7 @@ public class ResourceDecompiling
}
}
String contents = Decompiler.KRAKATAU.getDecompiler().decompileClassNode(cn,
String contents = Decompiler.KRAKATAU_DECOMPILER.getDecompiler().decompileClassNode(cn,
cw.toByteArray());
DiskWriter.replaceFile(path, contents, false);
BytecodeViewer.viewer.updateBusyStatus(false);