Merge pull request #404 from GraxCode/bytecode

Bug fixes and UI fixes and other small stuff.
This commit is contained in:
Konloch 2022-03-23 12:09:18 -07:00 committed by GitHub
commit 2848d1d4cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 45 additions and 45 deletions

View file

@ -130,10 +130,10 @@ public class InstructionPrinter implements Opcodes {
List<TryCatchBlockNode> tcbs = mNode.tryCatchBlocks; List<TryCatchBlockNode> tcbs = mNode.tryCatchBlocks;
String starting = tcbs.stream().filter(tcb -> tcb.start == label).map(tcb -> "start TCB" + tcbs.indexOf(tcb)).collect(Collectors.joining(", ")); String starting = tcbs.stream().filter(tcb -> tcb.start == label).map(tcb -> "start TCB" + tcbs.indexOf(tcb)).collect(Collectors.joining(", "));
String ending = tcbs.stream().filter(tcb -> tcb.end == label).map(tcb -> "end TCB" + tcbs.indexOf(tcb)).collect(Collectors.joining(", ")); String ending = tcbs.stream().filter(tcb -> tcb.end == label).map(tcb -> "end TCB" + tcbs.indexOf(tcb)).collect(Collectors.joining(", "));
String handlers = tcbs.stream().filter(tcb -> tcb.handler == label).map(tcb -> "handler TCB" + tcbs.indexOf(tcb)).collect(Collectors.joining(", ")); String handlers = tcbs.stream().filter(tcb -> tcb.handler == label).map(tcb -> "handle TCB" + tcbs.indexOf(tcb)).collect(Collectors.joining(", "));
if (!ending.isEmpty()) info.add("// " + ending); if (!ending.isEmpty()) info.add("// " + ending);
if (!starting.isEmpty()) info.add("// " + starting); if (!starting.isEmpty()) info.add("// " + starting);
if (!handlers.isEmpty()) info.add("// " + starting); if (!handlers.isEmpty()) info.add("// " + handlers);
} }
line = printLabelNode((LabelNode) ain); line = printLabelNode((LabelNode) ain);
@ -344,7 +344,7 @@ public class InstructionPrinter implements Opcodes {
return "unknown"; return "unknown";
} }
} }
if (obj instanceof String) return "reference [" + obj + "]"; if (obj instanceof String) return obj.toString();
return "unknown [" + obj.toString() + "]"; return "unknown [" + obj.toString() + "]";
} }

View file

@ -144,9 +144,11 @@ public class MethodNodeDecompiler {
addAttrList(m.visibleTypeAnnotations, "visTypeAnno", sb, addAttrList(m.visibleTypeAnnotations, "visTypeAnno", sb,
insnPrinter); insnPrinter);
for (TryCatchBlockNode o : m.tryCatchBlocks) { List<TryCatchBlockNode> tryCatchBlocks = m.tryCatchBlocks;
for (int i = 0; i < tryCatchBlocks.size(); i++) {
TryCatchBlockNode o = tryCatchBlocks.get(i);
sb.append(" "); sb.append(" ");
sb.append("TryCatch: L"); sb.append("TCB").append(i).append(": L");
sb.append(insnPrinter.resolveLabel(o.start)); sb.append(insnPrinter.resolveLabel(o.start));
sb.append(" to L"); sb.append(" to L");
sb.append(insnPrinter.resolveLabel(o.end)); sb.append(insnPrinter.resolveLabel(o.end));

View file

@ -117,7 +117,7 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File
JPanel buttonPanel = new JPanel(new BorderLayout()); JPanel buttonPanel = new JPanel(new BorderLayout());
quickSearchPanel.setLayout(new BorderLayout()); quickSearchPanel.setLayout(new BorderLayout());
quickSearchPanel.add(quickSearch, BorderLayout.NORTH); quickSearchPanel.add(quickSearch, BorderLayout.CENTER);
JPanel btns = new JPanel(new FlowLayout()); JPanel btns = new JPanel(new FlowLayout());
btns.add(exact); btns.add(exact);
@ -126,7 +126,7 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File
buttonPanel.add(open, BorderLayout.EAST); buttonPanel.add(open, BorderLayout.EAST);
buttonPanel.add(close, BorderLayout.WEST); buttonPanel.add(close, BorderLayout.WEST);
exactPanel.add(buttonPanel, BorderLayout.EAST); quickSearchPanel.add(buttonPanel, BorderLayout.EAST);
quickSearchPanel.add(exactPanel, BorderLayout.SOUTH); quickSearchPanel.add(exactPanel, BorderLayout.SOUTH);
getContentPane().add(quickSearchPanel, BorderLayout.SOUTH); getContentPane().add(quickSearchPanel, BorderLayout.SOUTH);

View file

@ -5,6 +5,7 @@ import javax.swing.tree.TreePath;
import java.awt.*; import java.awt.*;
import java.awt.event.KeyAdapter; import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.util.Arrays;
import java.util.Enumeration; import java.util.Enumeration;
/*************************************************************************** /***************************************************************************
@ -42,17 +43,15 @@ public class SearchKeyAdapter extends KeyAdapter {
if (ke.getKeyCode() != KeyEvent.VK_ENTER) if (ke.getKeyCode() != KeyEvent.VK_ENTER)
return; return;
final String qt = resourceListPane.quickSearch.getText(); String qt = resourceListPane.quickSearch.getText();
if (qt.trim().isEmpty()) //NOPE if (qt.trim().isEmpty()) //NOPE
return; return;
String[] path; String[] path;
if (qt.contains(".")) {
path = qt.split("\\."); path = qt.split("[\\./]+"); // split at dot or slash
} else { qt = qt.replace('/', '.');
path = new String[]{qt};
}
ResourceTreeNode curNode = resourceListPane.treeRoot; ResourceTreeNode curNode = resourceListPane.treeRoot;
boolean caseSensitive = resourceListPane.caseSensitive.isSelected(); boolean caseSensitive = resourceListPane.caseSensitive.isSelected();
@ -67,7 +66,7 @@ public class SearchKeyAdapter extends KeyAdapter {
for (int c = 0; c < curNode.getChildCount(); c++) { for (int c = 0; c < curNode.getChildCount(); c++) {
final ResourceTreeNode child = (ResourceTreeNode) curNode.getChildAt(c); final ResourceTreeNode child = (ResourceTreeNode) curNode.getChildAt(c);
Object userObject = child.getUserObject(); Object userObject = child.getUserObject();
if (caseSensitive ? userObject.equals(pathName) : userObject.toString().equalsIgnoreCase(pathName)) { if (caseSensitive ? userObject.toString().equals(pathName) : userObject.toString().equalsIgnoreCase(pathName)) {
curNode = child; curNode = child;
if (isLast) { if (isLast) {
final TreePath pathn = new TreePath(curNode.getPath()); final TreePath pathn = new TreePath(curNode.getPath());
@ -81,7 +80,6 @@ public class SearchKeyAdapter extends KeyAdapter {
continue pathLoop; continue pathLoop;
} }
} }
System.out.println("Could not find " + pathName); System.out.println("Could not find " + pathName);
break; break;
} }

View file

@ -6,14 +6,7 @@ import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.Objects; import java.util.Objects;
import javax.swing.DefaultComboBoxModel; import javax.swing.*;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
@ -95,12 +88,12 @@ public class SearchBoxPane extends TranslatedVisibleComponent
typeModel.addElement(st); typeModel.addElement(st);
typeBox = new JComboBox<>(typeModel); typeBox = new JComboBox<>(typeModel);
final JPanel searchOptPanel = new JPanel(); final JPanel searchOptPanel = new JPanel(new BorderLayout());
searchOptPanel.setBorder(BorderFactory.createEmptyBorder(4,4,4,4));
final ItemListener il = arg0 -> { final ItemListener il = arg0 -> {
searchOptPanel.removeAll(); searchOptPanel.removeAll();
searchType = (SearchType) typeBox.getSelectedItem(); searchType = (SearchType) typeBox.getSelectedItem();
searchOptPanel.add(Objects.requireNonNull(searchType).panel.getPanel()); searchOptPanel.add(Objects.requireNonNull(searchType).panel.getPanel(), BorderLayout.CENTER);
searchOptPanel.revalidate(); searchOptPanel.revalidate();
searchOptPanel.repaint(); searchOptPanel.repaint();

View file

@ -1,6 +1,6 @@
package the.bytecode.club.bytecodeviewer.searching.impl; package the.bytecode.club.bytecodeviewer.searching.impl;
import java.awt.GridLayout; import java.awt.*;
import java.util.Iterator; import java.util.Iterator;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JTextField; import javax.swing.JTextField;
@ -60,9 +60,9 @@ public class LDCSearch implements SearchPanel
{ {
if (myPanel == null) if (myPanel == null)
{ {
myPanel = new JPanel(new GridLayout(1, 2)); myPanel = new JPanel(new BorderLayout(16, 16));
myPanel.add(new TranslatedJLabel("Search String: ", TranslatedComponents.SEARCH_STRING)); myPanel.add(new TranslatedJLabel("Search String: ", TranslatedComponents.SEARCH_STRING), BorderLayout.WEST);
myPanel.add(searchText); myPanel.add(searchText, BorderLayout.CENTER);
} }
return myPanel; return myPanel;

View file

@ -51,9 +51,9 @@ public class MemberWithAnnotationSearch implements SearchPanel {
@Override @Override
public JPanel getPanel() { public JPanel getPanel() {
if (myPanel == null) { if (myPanel == null) {
myPanel = new JPanel(new GridLayout(1, 2)); myPanel = new JPanel(new BorderLayout(16, 16));
myPanel.add(new TranslatedJLabel("Annotation name: ", TranslatedComponents.ANNOTATION_NAME)); myPanel.add(new TranslatedJLabel("Annotation name: ", TranslatedComponents.ANNOTATION_NAME), BorderLayout.WEST);
myPanel.add(annotation); myPanel.add(annotation, BorderLayout.CENTER);
} }
return myPanel; return myPanel;

View file

@ -1,7 +1,8 @@
package the.bytecode.club.bytecodeviewer.searching.impl; package the.bytecode.club.bytecodeviewer.searching.impl;
import eu.bibl.banalysis.asm.desc.OpcodeInfo; import eu.bibl.banalysis.asm.desc.OpcodeInfo;
import java.awt.GridLayout;
import java.awt.*;
import java.util.Iterator; import java.util.Iterator;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JTextField; import javax.swing.JTextField;
@ -65,13 +66,19 @@ public class MethodCallSearch implements SearchPanel
{ {
if (myPanel == null) if (myPanel == null)
{ {
myPanel = new JPanel(new GridLayout(3, 2)); myPanel = new JPanel(new BorderLayout(16, 16));
myPanel.add(new TranslatedJLabel("Owner: ", TranslatedComponents.OWNER));
myPanel.add(mOwner); JPanel left = new JPanel(new GridLayout(3,1));
myPanel.add(new TranslatedJLabel("Name: ", TranslatedComponents.NAME)); JPanel right = new JPanel(new GridLayout(3,1));
myPanel.add(mName);
myPanel.add(new TranslatedJLabel("Desc: ", TranslatedComponents.DESC)); left.add(new TranslatedJLabel("Owner: ", TranslatedComponents.OWNER));
myPanel.add(mDesc); right.add(mOwner);
left.add(new TranslatedJLabel("Name: ", TranslatedComponents.NAME));
right.add(mName);
left.add(new TranslatedJLabel("Desc: ", TranslatedComponents.DESC));
right.add(mDesc);
myPanel.add(left, BorderLayout.WEST);
myPanel.add(right, BorderLayout.CENTER);
} }
return myPanel; return myPanel;

View file

@ -1,6 +1,6 @@
package the.bytecode.club.bytecodeviewer.searching.impl; package the.bytecode.club.bytecodeviewer.searching.impl;
import java.awt.GridLayout; import java.awt.*;
import java.util.Iterator; import java.util.Iterator;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -61,9 +61,9 @@ public class RegexSearch implements SearchPanel
{ {
if (myPanel == null) if (myPanel == null)
{ {
myPanel = new JPanel(new GridLayout(1, 2)); myPanel = new JPanel(new BorderLayout(16, 16));
myPanel.add(new TranslatedJLabel("Search Regex: ", TranslatedComponents.SEARCH_REGEX)); myPanel.add(new TranslatedJLabel("Search Regex: ", TranslatedComponents.SEARCH_REGEX), BorderLayout.WEST);
myPanel.add(searchText); myPanel.add(searchText, BorderLayout.CENTER);
} }
return myPanel; return myPanel;