From 4e5c3358983a13ecdfde08304e9839de5b91fba3 Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Sun, 19 Dec 2021 22:05:31 +0100 Subject: [PATCH 01/11] Update dependencies --- pom.xml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 03821d33..8098fb31 100644 --- a/pom.xml +++ b/pom.xml @@ -30,13 +30,13 @@ 1.9 2.7.3 0.3.4 - 5.2.0.Final - v36 - 981e35a + 5.2.1.Final + v37 + 94d9422 2.8.9 31.0.1-jre 4.2 - 1.3.0 + 1.3.1 3.1.6 1.6.6bcv 3.4.1.3 @@ -48,7 +48,7 @@ 2.1.1 1.7.32 2.5.2 - 1.29 + 1.30 1.0.3 0.2.2 1.1.4c @@ -288,22 +288,22 @@ ${xpp3.version} - com.github.skylot.jadx + io.github.skylot jadx-core ${jadx.version} - com.github.skylot.jadx + io.github.skylot jadx-java-convert ${jadx.version} - com.github.skylot.jadx + io.github.skylot jadx-dex-input ${jadx.version} - com.github.skylot.jadx + io.github.skylot jadx-smali-input ${jadx.version} From 9824071323e3efbd6900426776c71ae4b4b109cc Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Sun, 19 Dec 2021 22:10:40 +0100 Subject: [PATCH 02/11] Update Workflow to Java 17 release --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 561f55fe..415e2ae4 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - java: [ '8', '11', '17-ea' ] # LTS versions + java: [ '8', '11', '17' ] # LTS versions steps: - uses: actions/checkout@v2 From 69c480f9cc54310fa184eea4e454ef13da412381 Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Sun, 19 Dec 2021 22:10:52 +0100 Subject: [PATCH 03/11] Exclude duplicated dependencies --- pom.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pom.xml b/pom.xml index 8098fb31..fb47940f 100644 --- a/pom.xml +++ b/pom.xml @@ -296,6 +296,16 @@ io.github.skylot jadx-java-convert ${jadx.version} + + + com.android.tools + r8 + + + com.jakewharton.android.repackaged + dalvik-dx + + io.github.skylot From dac8dcc6c7cef6bcdab14e13547c9eb59e1fd071 Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Sun, 19 Dec 2021 22:20:09 +0100 Subject: [PATCH 04/11] Update dependencies again --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fb47940f..88f1a0ca 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ 2.7.3 0.3.4 5.2.1.Final - v37 + v39 94d9422 2.8.9 31.0.1-jre From 86fb69f69486e1ff0ef58b802630de8e356f56f9 Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Mon, 20 Dec 2021 00:24:17 +0100 Subject: [PATCH 05/11] Optimize various stuff --- install/launch4j_config.xml | 24 ++-- plugins/Skeleton.gy | 20 +-- plugins/example/ExampleStringDecrypter.gy | 42 ++++--- .../bytecode/club/bytecodeviewer/api/BCV.java | 2 +- .../club/bytecodeviewer/bootloader/Boot.java | 8 +- .../bootloader/classtree/ClassHelper.java | 7 +- .../external/EmptyExternalResource.java | 5 +- .../bytecode/ClassNodeDecompiler.java | 2 - .../decompilers/impl/CFRDecompiler.java | 1 - .../decompilers/impl/KrakatauDecompiler.java | 2 +- .../decompilers/jdgui/PlainTextPrinter.java | 3 +- .../gui/components/ExtendedJOptionPane.java | 8 +- .../gui/components/JTextAreaOutputStream.java | 3 +- .../gui/contextmenu/ContextMenu.java | 6 +- .../contextmenu/resourcelist/Collapse.java | 18 ++- .../gui/contextmenu/resourcelist/Delete.java | 18 ++- .../gui/contextmenu/resourcelist/Expand.java | 18 ++- .../gui/contextmenu/resourcelist/New.java | 12 +- .../gui/contextmenu/resourcelist/Open.java | 18 ++- .../gui/contextmenu/searchbox/Open.java | 18 ++- .../hexviewer/BaseSwitchableSpinnerPanel.java | 29 +---- .../gui/hexviewer/BinaryStatusPanel.java | 80 +++--------- .../gui/hexviewer/GoToBinaryPanel.java | 47 ++----- .../gui/hexviewer/HexViewer.java | 53 +++----- .../gui/hexviewer/OkCancelPanel.java | 13 +- .../gui/hexviewer/ValuesPanel.java | 117 +++++------------- .../gui/resourcelist/ResourceListPane.java | 4 +- .../gui/resourcesearch/PerformSearch.java | 4 +- .../gui/resourcesearch/SearchBoxPane.java | 15 ++- .../gui/resourceviewer/BytecodeViewPanel.java | 4 +- .../DecompilerSelectionPane.java | 4 +- .../gui/resourceviewer/TabbedPane.java | 4 +- .../gui/resourceviewer/Workspace.java | 4 +- .../viewer/ComponentViewer.java | 2 +- .../viewer/synchronizedscroll/MethodData.java | 21 ++-- .../gui/util/BytecodeViewPanelUpdater.java | 2 +- .../mapping/RemappingSignatureAdapter.java | 2 +- .../bytecodeviewer/plugin/PluginManager.java | 6 +- .../bytecodeviewer/plugin/PluginWriter.java | 2 +- .../preinstalled/AllatoriStringDecrypter.java | 4 +- .../resources/ExternalResources.java | 16 +-- .../resources/exporting/impl/APKExport.java | 4 +- .../resources/exporting/impl/DexExport.java | 2 +- .../exporting/impl/RunnableJarExporter.java | 2 +- .../resources/importing/ImportResource.java | 1 - .../bytecodeviewer/translation/Language.java | 2 +- .../club/bytecodeviewer/util/Enjarify.java | 2 +- .../club/bytecodeviewer/util/MiscUtils.java | 4 +- .../club/bytecodeviewer/util/SeqAndCount.java | 10 +- .../html/intro.english.draft.html | 2 +- .../translations/html/intro.english.html | 2 +- .../translations/html/intro.german.html | 2 +- .../translations/html/intro.mandarin.html | 6 +- 53 files changed, 253 insertions(+), 454 deletions(-) diff --git a/install/launch4j_config.xml b/install/launch4j_config.xml index 5bfb07cd..a4af5920 100644 --- a/install/launch4j_config.xml +++ b/install/launch4j_config.xml @@ -14,35 +14,35 @@ w32api/libshell32.a H:\Repo\BCV\bytecode-viewer\BytecodeViewer 2.9.8.jar H:\Repo\BCV\bytecode-viewer\BytecodeViewer.exe - - + + . normal - http://java.com/download - + https://java.com/de/download/ + false false - + H:\Repo\BCV\bytecode-viewer\BCV Icon.ico - + false false 1.7.0_00 - + preferJre 64/32 0.2.9.7 - http://the.bytecode.club + https://the.bytecode.club/ Bytecode Viewer - http://bytecodeviewer.com + https://bytecodeviewer.com/ 0.2.9.6 - http://the.bytecode.club + https://the.bytecode.club/ Bytecode Viewer - + BCV Bytecode_Viewer.exe - \ No newline at end of file + diff --git a/plugins/Skeleton.gy b/plugins/Skeleton.gy index c9d45583..7c540020 100644 --- a/plugins/Skeleton.gy +++ b/plugins/Skeleton.gy @@ -1,14 +1,14 @@ -import the.bytecode.club.bytecodeviewer.api.*; -import java.util.ArrayList; -import org.objectweb.asm.tree.ClassNode; -import the.bytecode.club.bytecodeviewer.decompilers.*; +import org.objectweb.asm.tree.ClassNode +import the.bytecode.club.bytecodeviewer.api.Plugin +import the.bytecode.club.bytecodeviewer.api.PluginConsole -public class Skeleton extends Plugin { +class Skeleton extends Plugin { @Override - public void execute(ArrayList classNodesList) { - PluginConsole gui = new PluginConsole("Skeleton"); - gui.setVisible(true); - gui.appendText("executed skeleton"); + void execute(List classNodesList) { + PluginConsole gui = new PluginConsole("Skeleton") + gui.setVisible(true) + gui.appendText("executed skeleton") } -} \ No newline at end of file + +} diff --git a/plugins/example/ExampleStringDecrypter.gy b/plugins/example/ExampleStringDecrypter.gy index 917ceacb..086cbc83 100644 --- a/plugins/example/ExampleStringDecrypter.gy +++ b/plugins/example/ExampleStringDecrypter.gy @@ -1,52 +1,54 @@ -import the.bytecode.club.bytecodeviewer.api.* -import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialog; - -import java.util.ArrayList; -import java.lang.reflect.Field; -import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.FieldNode +import the.bytecode.club.bytecodeviewer.api.BCV +import the.bytecode.club.bytecodeviewer.api.Plugin +import the.bytecode.club.bytecodeviewer.api.PluginConsole +import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialog -import static the.bytecode.club.bytecodeviewer.Constants.nl; +import java.lang.reflect.Field + +import static the.bytecode.club.bytecodeviewer.Constants.nl /** * This is an example of a string decrypter plugin */ -public class ExampleStringDecrypter extends Plugin { +class ExampleStringDecrypter extends Plugin { @Override - public void execute(ArrayList classNodesList) { - PluginConsole gui = new PluginConsole("Example String Decrypter"); + void execute(List classNodesList) { + PluginConsole gui = new PluginConsole("Example String Decrypter") MultipleChoiceDialog dialog = new MultipleChoiceDialog("Bytecode Viewer - WARNING", "WARNING: This will load the classes into the JVM and execute the initialize function" + nl + "for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE.", - new String[]{"Continue", "Cancel"}); + new String[]{"Continue", "Cancel"}) if(dialog.promptChoice() == 0) { for(ClassNode cn : classNodesList) { - BCV.getClassNodeLoader().addClass(cn); + BCV.getClassNodeLoader().addClass(cn) for(Object o : cn.fields.toArray()) { - FieldNode f = (FieldNode) o; - if(f.name.equals("z")) {// && f.desc.equals("([Ljava/lang/String;)V")) { + FieldNode f = (FieldNode) o + if(f.name == "z") {// && f.desc.equals("([Ljava/lang/String;)V")) { try { for(Field f2 : BCV.getClassNodeLoader().nodeToClass(cn).getFields()) { - String s = f2.get(null); - if(s != null && !s.empty()) - gui.appendText(cn+":"+s); + String s = f2.get(null) + if(s != null && !s.empty) + gui.appendText(cn + ":" + s) } - } catch(Exception | StackOverflowError e) {} + } catch(Exception | StackOverflowError ignored) {} } } } - gui.setVisible(true); + gui.setVisible(true) } } -} \ No newline at end of file + +} diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/api/BCV.java b/src/main/java/the/bytecode/club/bytecodeviewer/api/BCV.java index 91fd1aee..db008f66 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/api/BCV.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/api/BCV.java @@ -247,7 +247,7 @@ public class BCV { try { Thread.sleep(100); - } catch (InterruptedException e) { } + } catch (InterruptedException ignored) { } } frame.setVisible(false); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/bootloader/Boot.java b/src/main/java/the/bytecode/club/bytecodeviewer/bootloader/Boot.java index 951dfe2d..d12676e5 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/bootloader/Boot.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/bootloader/Boot.java @@ -296,7 +296,7 @@ public class Boot { public static void dropKrakatau() { File temp = new File(getBCVDirectory() + fs + "krakatau_" + krakatauVersion + ".zip"); File krakatauDirectory = new File(krakatauWorkingDirectory); - Constants.krakatauWorkingDirectory = krakatauWorkingDirectory + fs + "Krakatau-master"; + krakatauWorkingDirectory += fs + "Krakatau-master"; if (!krakatauDirectory.exists() || temp.exists()) { if (temp.exists()) temp.delete(); @@ -308,7 +308,7 @@ public class Boot { temp.delete(); try (InputStream is = BytecodeViewer.class.getClassLoader().getResourceAsStream("Krakatau-" - + Constants.krakatauVersion + ".zip"); + + krakatauVersion + ".zip"); FileOutputStream baos = new FileOutputStream(temp)) { int r; byte[] buffer = new byte[8192]; @@ -329,7 +329,7 @@ public class Boot { public static void dropEnjarify() { File temp = new File(getBCVDirectory() + fs + "enjarify" + Constants.enjarifyVersion + ".zip"); File enjarifyDirectory = new File(Constants.enjarifyWorkingDirectory); - Constants.enjarifyWorkingDirectory = Constants.enjarifyWorkingDirectory + fs + "enjarify-master"; + Constants.enjarifyWorkingDirectory += fs + "enjarify-master"; if (!enjarifyDirectory.exists() || temp.exists()) { if (temp.exists()) temp.delete(); @@ -359,7 +359,7 @@ public class Boot { } } - public static void downloadZipsOnly() throws Exception { + public static void downloadZipsOnly() { for (String s : urlList) { String fileName = s.substring("https://github.com/Konloch/bytecode-viewer/blob/master/libs/".length() ); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/bootloader/classtree/ClassHelper.java b/src/main/java/the/bytecode/club/bytecodeviewer/bootloader/classtree/ClassHelper.java index fae10bcb..cabc70d0 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/bootloader/classtree/ClassHelper.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/bootloader/classtree/ClassHelper.java @@ -3,7 +3,6 @@ package the.bytecode.club.bytecodeviewer.bootloader.classtree; import java.util.Collection; import java.util.HashMap; import java.util.Map; -import java.util.Map.Entry; import org.objectweb.asm.tree.ClassNode; /*************************************************************************** @@ -45,8 +44,6 @@ public class ClassHelper { } public static void copy(Map src, Map dst) { - for (Entry e : src.entrySet()) { - dst.put(e.getKey(), e.getValue()); - } + dst.putAll(src); } -} \ No newline at end of file +} diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/bootloader/resource/external/EmptyExternalResource.java b/src/main/java/the/bytecode/club/bytecodeviewer/bootloader/resource/external/EmptyExternalResource.java index 4d1c4744..c86836f7 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/bootloader/resource/external/EmptyExternalResource.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/bootloader/resource/external/EmptyExternalResource.java @@ -1,6 +1,5 @@ package the.bytecode.club.bytecodeviewer.bootloader.resource.external; -import java.io.IOException; import java.net.URL; /*************************************************************************** @@ -38,7 +37,7 @@ public class EmptyExternalResource extends ExternalResource { * @see the.bytecode.club.bootloader.resource.ExternalResource#load() */ @Override - public T load() throws IOException { + public T load() { throw new UnsupportedOperationException(); } -} \ No newline at end of file +} diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/bytecode/ClassNodeDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/bytecode/ClassNodeDecompiler.java index 5fa1744a..1959a1cb 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/bytecode/ClassNodeDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/bytecode/ClassNodeDecompiler.java @@ -162,8 +162,6 @@ public class ClassNodeDecompiler if (!tokens.contains("interface") && !tokens.contains("enum") && !tokens.contains("annotation")) tokens.add("class"); - if (tokens.size() == 0) - return "[Error parsing]"; // hackery delimeters StringBuilder sb = new StringBuilder(tokens.get(0)); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/CFRDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/CFRDecompiler.java index 9c3baa37..f447a554 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/CFRDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/CFRDecompiler.java @@ -316,7 +316,6 @@ public class CFRDecompiler extends InternalDecompiler fuck.delete(); } - @SuppressWarnings("resource") public void zip(File directory, File zipFile) throws IOException { java.net.URI base = directory.toURI(); Deque queue = new LinkedList<>(); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDecompiler.java index d4b369f6..b828b016 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDecompiler.java @@ -226,7 +226,7 @@ public class KrakatauDecompiler extends InternalDecompiler } int exitValue = process.waitFor(); - log.append(nl).append(nl).append(TranslatedStrings.EXIT_VALUE_IS + " ").append(exitValue); + log.append(nl).append(nl).append(TranslatedStrings.EXIT_VALUE_IS).append(" ").append(exitValue); s = log.toString(); //if the motherfucker failed this'll fail, aka wont set. diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/jdgui/PlainTextPrinter.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/jdgui/PlainTextPrinter.java index dc00fb85..73596eab 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/jdgui/PlainTextPrinter.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/jdgui/PlainTextPrinter.java @@ -1,7 +1,6 @@ package the.bytecode.club.bytecodeviewer.decompilers.jdgui; import java.io.Closeable; -import java.io.IOException; import java.io.PrintStream; import org.jd.core.v1.api.printer.Printer; @@ -230,7 +229,7 @@ public class PlainTextPrinter implements Printer, Closeable { } @Override - public void close() throws IOException { + public void close() { if (this.printStream != null) this.printStream.close(); } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/ExtendedJOptionPane.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/ExtendedJOptionPane.java index c845b287..9174656f 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/ExtendedJOptionPane.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/ExtendedJOptionPane.java @@ -119,9 +119,7 @@ public class ExtendedJOptionPane int style = styleFromMessageType(messageType); JDialog dialog = createNewJDialog(parentComponent, pane, title, style, (d)-> - { - pane.selectInitialValue(); - }); + pane.selectInitialValue()); pane.selectInitialValue(); @@ -163,9 +161,7 @@ public class ExtendedJOptionPane int style = styleFromMessageType(messageType); JDialog dialog = createNewJDialog(parentComponent, pane, title, style, (d)-> - { - pane.selectInitialValue(); - }); + pane.selectInitialValue()); pane.selectInitialValue(); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/JTextAreaOutputStream.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/JTextAreaOutputStream.java index 465dac8d..a169c3d9 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/JTextAreaOutputStream.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/JTextAreaOutputStream.java @@ -1,7 +1,6 @@ package the.bytecode.club.bytecodeviewer.gui.components; import java.io.Closeable; -import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import javax.swing.JTextArea; @@ -65,7 +64,7 @@ public class JTextAreaOutputStream extends OutputStream implements Closeable } @Override - public void close() throws IOException { + public void close() { if (og != null) og.close(); } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/ContextMenu.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/ContextMenu.java index 2db9e8e6..cb30f47b 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/ContextMenu.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/ContextMenu.java @@ -39,7 +39,7 @@ import the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult; */ public class ContextMenu { - private static ContextMenu SINGLETON = new ContextMenu(); + private static final ContextMenu SINGLETON = new ContextMenu(); private final List contextMenuItems = new ArrayList<>(); static @@ -85,11 +85,11 @@ public class ContextMenu switch(item.getMenuType()) { case CONTAINER: - if(!isContainerSelected || searchBoxPane) + if(!isContainerSelected) continue; break; case RESOURCE: - if(!isResourceSelected || isContainerSelected || searchBoxPane) + if(!isResourceSelected || isContainerSelected) continue; break; case DIRECTORY: diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/resourcelist/Collapse.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/resourcelist/Collapse.java index c550a889..9c300174 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/resourcelist/Collapse.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/resourcelist/Collapse.java @@ -34,15 +34,13 @@ public class Collapse extends ContextMenuItem public Collapse() { super(ContextMenuType.DIRECTORY, ((tree, selPath, result, menu) -> - { - menu.add(new AbstractAction(TranslatedStrings.COLLAPSE.toString()) - { - @Override - public void actionPerformed(ActionEvent e) - { - BytecodeViewer.viewer.resourcePane.expandAll(tree, selPath, false); - } - }); - })); + menu.add(new AbstractAction(TranslatedStrings.COLLAPSE.toString()) + { + @Override + public void actionPerformed(ActionEvent e) + { + BytecodeViewer.viewer.resourcePane.expandAll(tree, selPath, false); + } + }))); } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/resourcelist/Delete.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/resourcelist/Delete.java index 62bc35ac..c79e0ed7 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/resourcelist/Delete.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/resourcelist/Delete.java @@ -34,15 +34,13 @@ public class Delete extends ContextMenuItem public Delete() { super(ContextMenuType.CONTAINER, ((tree, selPath, result, menu) -> - { - menu.add(new AbstractAction(TranslatedStrings.DELETE.toString()) - { - @Override - public void actionPerformed(ActionEvent e) - { - BytecodeViewer.viewer.resourcePane.removeNode(tree, selPath); - } - }); - })); + menu.add(new AbstractAction(TranslatedStrings.DELETE.toString()) + { + @Override + public void actionPerformed(ActionEvent e) + { + BytecodeViewer.viewer.resourcePane.removeNode(tree, selPath); + } + }))); } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/resourcelist/Expand.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/resourcelist/Expand.java index 7a8c288f..4663dbd2 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/resourcelist/Expand.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/resourcelist/Expand.java @@ -34,15 +34,13 @@ public class Expand extends ContextMenuItem public Expand() { super(ContextMenuType.DIRECTORY, ((tree, selPath, result, menu) -> - { - menu.add(new AbstractAction(TranslatedStrings.EXPAND.toString()) - { - @Override - public void actionPerformed(ActionEvent e) - { - BytecodeViewer.viewer.resourcePane.expandAll(tree, selPath, true); - } - }); - })); + menu.add(new AbstractAction(TranslatedStrings.EXPAND.toString()) + { + @Override + public void actionPerformed(ActionEvent e) + { + BytecodeViewer.viewer.resourcePane.expandAll(tree, selPath, true); + } + }))); } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/resourcelist/New.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/resourcelist/New.java index 18cda870..66896200 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/resourcelist/New.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/resourcelist/New.java @@ -77,8 +77,7 @@ public class New extends ContextMenuItem return; byte[] contents = new byte[0]; - String resourcePath = newPath; - + switch(fileType) { case CLASS: @@ -89,7 +88,7 @@ public class New extends ContextMenuItem //TODO santize newPath and remove extension if added cn.name = newPath; - String oldResourcePath = resourcePath.replace(".", "/"); + String oldResourcePath = newPath.replace(".", "/"); String newResourcePath = oldResourcePath + ".class"; contents = ASMUtil.nodeToBytes(cn); @@ -100,7 +99,7 @@ public class New extends ContextMenuItem break; case FILE: - BytecodeViewer.resourceContainers.get(containerName).resourceFiles.put(resourcePath, contents); + BytecodeViewer.resourceContainers.get(containerName).resourceFiles.put(newPath, contents); searchAndInsert(firstPath + separator +newPath, BytecodeViewer.resourceContainers.get(containerName).treeNode, separator); break; } @@ -115,7 +114,7 @@ public class New extends ContextMenuItem { StringBuilder tempSpot = new StringBuilder(); - for(int counter = startsAt, maxCounter = max;counter < maxCounter; counter++) + for(int counter = startsAt; counter < max; counter++) { if(counter > startsAt) tempSpot.append(separator); @@ -129,7 +128,7 @@ public class New extends ContextMenuItem { StringBuilder tempSpot = new StringBuilder(); - for(int counter = startsAt, maxCounter = max;counter < maxCounter; counter++) + for(int counter = startsAt; counter < max; counter++) { if(counter > startsAt) tempSpot.append(separator); @@ -140,6 +139,7 @@ public class New extends ContextMenuItem } //TODO this needs to be rewritten to support creating parent nodes that don't exist + @SuppressWarnings("unchecked") public static boolean searchAndInsert(String path, DefaultMutableTreeNode treeNode, String separator) { Enumeration children = treeNode.children(); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/resourcelist/Open.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/resourcelist/Open.java index e28843ac..a4e0c877 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/resourcelist/Open.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/resourcelist/Open.java @@ -34,15 +34,13 @@ public class Open extends ContextMenuItem public Open() { super(ContextMenuType.RESOURCE, ((tree, selPath, result, menu) -> - { - menu.add(new AbstractAction(TranslatedStrings.OPEN_UNSTYLED.toString()) - { - @Override - public void actionPerformed(ActionEvent e) - { - BytecodeViewer.viewer.resourcePane.openPath(selPath); - } - }); - })); + menu.add(new AbstractAction(TranslatedStrings.OPEN_UNSTYLED.toString()) + { + @Override + public void actionPerformed(ActionEvent e) + { + BytecodeViewer.viewer.resourcePane.openPath(selPath); + } + }))); } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/searchbox/Open.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/searchbox/Open.java index 140ef34a..4337c93c 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/searchbox/Open.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/contextmenu/searchbox/Open.java @@ -34,15 +34,13 @@ public class Open extends ContextMenuItem public Open() { super(ContextMenuType.SEARCH_BOX_RESULT, ((tree, selPath, result, menu) -> - { - menu.add(new AbstractAction(TranslatedStrings.OPEN_UNSTYLED.toString()) - { - @Override - public void actionPerformed(ActionEvent e) - { - BytecodeViewer.viewer.workPane.addClassResource(result.container, result.resourceWorkingName); - } - }); - })); + menu.add(new AbstractAction(TranslatedStrings.OPEN_UNSTYLED.toString()) + { + @Override + public void actionPerformed(ActionEvent e) + { + BytecodeViewer.viewer.workPane.addClassResource(result.container, result.resourceWorkingName); + } + }))); } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/BaseSwitchableSpinnerPanel.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/BaseSwitchableSpinnerPanel.java index f37eea4a..a242f558 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/BaseSwitchableSpinnerPanel.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/BaseSwitchableSpinnerPanel.java @@ -66,7 +66,6 @@ public class BaseSwitchableSpinnerPanel extends javax.swing.JPanel { * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ - @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { @@ -79,29 +78,17 @@ public class BaseSwitchableSpinnerPanel extends javax.swing.JPanel { octalMenuItem.setText("OCT"); octalMenuItem.setToolTipText("Octal"); - octalMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - octalMenuItemActionPerformed(evt); - } - }); + octalMenuItem.addActionListener(this::octalMenuItemActionPerformed); baseSwitchPopupMenu.add(octalMenuItem); decimalMenuItem.setText("DEC"); decimalMenuItem.setToolTipText("Decimal"); - decimalMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - decimalMenuItemActionPerformed(evt); - } - }); + decimalMenuItem.addActionListener(this::decimalMenuItemActionPerformed); baseSwitchPopupMenu.add(decimalMenuItem); hexadecimalMenuItem.setText("HEX"); hexadecimalMenuItem.setToolTipText("Hexadecimal"); - hexadecimalMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - hexadecimalMenuItemActionPerformed(evt); - } - }); + hexadecimalMenuItem.addActionListener(this::hexadecimalMenuItemActionPerformed); baseSwitchPopupMenu.add(hexadecimalMenuItem); setPreferredSize(new java.awt.Dimension(400, 300)); @@ -109,11 +96,7 @@ public class BaseSwitchableSpinnerPanel extends javax.swing.JPanel { baseSwitchButton.setText("DEC"); baseSwitchButton.setToolTipText("Decimal"); baseSwitchButton.setComponentPopupMenu(baseSwitchPopupMenu); - baseSwitchButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - baseSwitchButtonActionPerformed(evt); - } - }); + baseSwitchButton.addActionListener(this::baseSwitchButtonActionPerformed); spinner.setModel(new javax.swing.SpinnerNumberModel(0L, null, null, 1L)); @@ -302,9 +285,7 @@ public class BaseSwitchableSpinnerPanel extends javax.swing.JPanel { } JSpinner sourceSpinner = (JSpinner) (e.getSource()); - SwingUtilities.invokeLater(() -> { - textField.setText(getPositionAsString((Long) sourceSpinner.getValue())); - }); + SwingUtilities.invokeLater(() -> textField.setText(getPositionAsString((Long) sourceSpinner.getValue()))); } @Override diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/BinaryStatusPanel.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/BinaryStatusPanel.java index bd8b7c6e..71bd12dd 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/BinaryStatusPanel.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/BinaryStatusPanel.java @@ -35,11 +35,11 @@ public class BinaryStatusPanel extends javax.swing.JPanel implements BinaryStatu public static final String DECIMAL_CODE_TYPE_LABEL = "DEC"; public static final String HEXADECIMAL_CODE_TYPE_LABEL = "HEX"; - private StatusCursorPositionFormat cursorPositionFormat = new StatusCursorPositionFormat(); - private StatusDocumentSizeFormat documentSizeFormat = new StatusDocumentSizeFormat(); - private int octalSpaceGroupSize = DEFAULT_OCTAL_SPACE_GROUP_SIZE; - private int decimalSpaceGroupSize = DEFAULT_DECIMAL_SPACE_GROUP_SIZE; - private int hexadecimalSpaceGroupSize = DEFAULT_HEXADECIMAL_SPACE_GROUP_SIZE; + private final StatusCursorPositionFormat cursorPositionFormat = new StatusCursorPositionFormat(); + private final StatusDocumentSizeFormat documentSizeFormat = new StatusDocumentSizeFormat(); + private final int octalSpaceGroupSize = DEFAULT_OCTAL_SPACE_GROUP_SIZE; + private final int decimalSpaceGroupSize = DEFAULT_DECIMAL_SPACE_GROUP_SIZE; + private final int hexadecimalSpaceGroupSize = DEFAULT_HEXADECIMAL_SPACE_GROUP_SIZE; private EditOperation editOperation; private CodeAreaCaretPosition caretPosition; @@ -164,32 +164,20 @@ public class BinaryStatusPanel extends javax.swing.JPanel implements BinaryStatu cursorPositionModeButtonGroup.add(octalCursorPositionModeRadioButtonMenuItem); octalCursorPositionModeRadioButtonMenuItem.setText("Show as octal"); octalCursorPositionModeRadioButtonMenuItem.setName("octalCursorPositionModeRadioButtonMenuItem"); - octalCursorPositionModeRadioButtonMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - octalCursorPositionModeRadioButtonMenuItemActionPerformed(evt); - } - }); + octalCursorPositionModeRadioButtonMenuItem.addActionListener(this::octalCursorPositionModeRadioButtonMenuItemActionPerformed); cursorPositionCodeTypeMenu.add(octalCursorPositionModeRadioButtonMenuItem); cursorPositionModeButtonGroup.add(decimalCursorPositionModeRadioButtonMenuItem); decimalCursorPositionModeRadioButtonMenuItem.setSelected(true); decimalCursorPositionModeRadioButtonMenuItem.setText("Show as decimal"); decimalCursorPositionModeRadioButtonMenuItem.setName("decimalCursorPositionModeRadioButtonMenuItem"); - decimalCursorPositionModeRadioButtonMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - decimalCursorPositionModeRadioButtonMenuItemActionPerformed(evt); - } - }); + decimalCursorPositionModeRadioButtonMenuItem.addActionListener(this::decimalCursorPositionModeRadioButtonMenuItemActionPerformed); cursorPositionCodeTypeMenu.add(decimalCursorPositionModeRadioButtonMenuItem); cursorPositionModeButtonGroup.add(hexadecimalCursorPositionModeRadioButtonMenuItem); hexadecimalCursorPositionModeRadioButtonMenuItem.setText("Show as hexadecimal"); hexadecimalCursorPositionModeRadioButtonMenuItem.setName("hexadecimalCursorPositionModeRadioButtonMenuItem"); - hexadecimalCursorPositionModeRadioButtonMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - hexadecimalCursorPositionModeRadioButtonMenuItemActionPerformed(evt); - } - }); + hexadecimalCursorPositionModeRadioButtonMenuItem.addActionListener(this::hexadecimalCursorPositionModeRadioButtonMenuItemActionPerformed); cursorPositionCodeTypeMenu.add(hexadecimalCursorPositionModeRadioButtonMenuItem); positionPopupMenu.add(cursorPositionCodeTypeMenu); @@ -197,11 +185,7 @@ public class BinaryStatusPanel extends javax.swing.JPanel implements BinaryStatu cursorPositionShowOffsetCheckBoxMenuItem.setSelected(true); cursorPositionShowOffsetCheckBoxMenuItem.setText("Show offset"); cursorPositionShowOffsetCheckBoxMenuItem.setName("cursorPositionShowOffsetCheckBoxMenuItem"); - cursorPositionShowOffsetCheckBoxMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - cursorPositionShowOffsetCheckBoxMenuItemActionPerformed(evt); - } - }); + cursorPositionShowOffsetCheckBoxMenuItem.addActionListener(this::cursorPositionShowOffsetCheckBoxMenuItemActionPerformed); positionPopupMenu.add(cursorPositionShowOffsetCheckBoxMenuItem); jSeparator2.setName("jSeparator2"); @@ -209,21 +193,13 @@ public class BinaryStatusPanel extends javax.swing.JPanel implements BinaryStatu positionCopyMenuItem.setText("Copy"); positionCopyMenuItem.setName("positionCopyMenuItem"); - positionCopyMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - positionCopyMenuItemActionPerformed(evt); - } - }); + positionCopyMenuItem.addActionListener(this::positionCopyMenuItemActionPerformed); positionPopupMenu.add(positionCopyMenuItem); positionGoToMenuItem.setText("Go To..."); positionGoToMenuItem.setEnabled(false); positionGoToMenuItem.setName("positionGoToMenuItem"); - positionGoToMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - positionGoToMenuItemActionPerformed(evt); - } - }); + positionGoToMenuItem.addActionListener(this::positionGoToMenuItemActionPerformed); positionPopupMenu.add(positionGoToMenuItem); documentSizePopupMenu.setName("documentSizePopupMenu"); @@ -234,31 +210,19 @@ public class BinaryStatusPanel extends javax.swing.JPanel implements BinaryStatu documentSizeModeButtonGroup.add(octalDocumentSizeModeRadioButtonMenuItem); octalDocumentSizeModeRadioButtonMenuItem.setText("Show as octal"); octalDocumentSizeModeRadioButtonMenuItem.setName("octalDocumentSizeModeRadioButtonMenuItem"); - octalDocumentSizeModeRadioButtonMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - octalDocumentSizeModeRadioButtonMenuItemActionPerformed(evt); - } - }); + octalDocumentSizeModeRadioButtonMenuItem.addActionListener(this::octalDocumentSizeModeRadioButtonMenuItemActionPerformed); documentSizeCodeTypeMenu.add(octalDocumentSizeModeRadioButtonMenuItem); documentSizeModeButtonGroup.add(decimalDocumentSizeModeRadioButtonMenuItem); decimalDocumentSizeModeRadioButtonMenuItem.setText("Show as decimal"); decimalDocumentSizeModeRadioButtonMenuItem.setName("decimalDocumentSizeModeRadioButtonMenuItem"); - decimalDocumentSizeModeRadioButtonMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - decimalDocumentSizeModeRadioButtonMenuItemActionPerformed(evt); - } - }); + decimalDocumentSizeModeRadioButtonMenuItem.addActionListener(this::decimalDocumentSizeModeRadioButtonMenuItemActionPerformed); documentSizeCodeTypeMenu.add(decimalDocumentSizeModeRadioButtonMenuItem); documentSizeModeButtonGroup.add(hexadecimalDocumentSizeModeRadioButtonMenuItem); hexadecimalDocumentSizeModeRadioButtonMenuItem.setText("Show as hexadecimal"); hexadecimalDocumentSizeModeRadioButtonMenuItem.setName("hexadecimalDocumentSizeModeRadioButtonMenuItem"); - hexadecimalDocumentSizeModeRadioButtonMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - hexadecimalDocumentSizeModeRadioButtonMenuItemActionPerformed(evt); - } - }); + hexadecimalDocumentSizeModeRadioButtonMenuItem.addActionListener(this::hexadecimalDocumentSizeModeRadioButtonMenuItemActionPerformed); documentSizeCodeTypeMenu.add(hexadecimalDocumentSizeModeRadioButtonMenuItem); documentSizePopupMenu.add(documentSizeCodeTypeMenu); @@ -266,11 +230,7 @@ public class BinaryStatusPanel extends javax.swing.JPanel implements BinaryStatu documentSizeShowRelativeCheckBoxMenuItem.setSelected(true); documentSizeShowRelativeCheckBoxMenuItem.setText("Show relative size"); documentSizeShowRelativeCheckBoxMenuItem.setName("documentSizeShowRelativeCheckBoxMenuItem"); - documentSizeShowRelativeCheckBoxMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - documentSizeShowRelativeCheckBoxMenuItemActionPerformed(evt); - } - }); + documentSizeShowRelativeCheckBoxMenuItem.addActionListener(this::documentSizeShowRelativeCheckBoxMenuItemActionPerformed); documentSizePopupMenu.add(documentSizeShowRelativeCheckBoxMenuItem); jSeparator1.setName("jSeparator1"); @@ -278,11 +238,7 @@ public class BinaryStatusPanel extends javax.swing.JPanel implements BinaryStatu documentSizeCopyMenuItem.setText("Copy"); documentSizeCopyMenuItem.setName("documentSizeCopyMenuItem"); - documentSizeCopyMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - documentSizeCopyMenuItemActionPerformed(evt); - } - }); + documentSizeCopyMenuItem.addActionListener(this::documentSizeCopyMenuItemActionPerformed); documentSizePopupMenu.add(documentSizeCopyMenuItem); setName("Form"); @@ -627,7 +583,7 @@ public class BinaryStatusPanel extends javax.swing.JPanel implements BinaryStatu return "0"; } - int spaceGroupSize = 0; + int spaceGroupSize; switch (codeType) { case OCTAL: { spaceGroupSize = octalSpaceGroupSize; @@ -660,7 +616,7 @@ public class BinaryStatusPanel extends javax.swing.JPanel implements BinaryStatu } int digit = (int) (remainder % base); - remainder = remainder / base; + remainder /= base; builder.insert(0, CodeAreaUtils.UPPER_HEX_CODES[digit]); } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/GoToBinaryPanel.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/GoToBinaryPanel.java index 1565135b..db43ca86 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/GoToBinaryPanel.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/GoToBinaryPanel.java @@ -1,7 +1,5 @@ package the.bytecode.club.bytecodeviewer.gui.hexviewer; -import java.util.ResourceBundle; -import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import org.exbin.bined.CodeAreaUtils; @@ -18,10 +16,8 @@ public class GoToBinaryPanel extends javax.swing.JPanel { public GoToBinaryPanel() { initComponents(); - baseSwitchableSpinnerPanel.setMinimum(0l); - baseSwitchableSpinnerPanel.addChangeListener((javax.swing.event.ChangeEvent evt) -> { - updateTargetPosition(); - }); + baseSwitchableSpinnerPanel.setMinimum(0L); + baseSwitchableSpinnerPanel.addChangeListener((javax.swing.event.ChangeEvent evt) -> updateTargetPosition()); } /** @@ -29,7 +25,6 @@ public class GoToBinaryPanel extends javax.swing.JPanel { * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ - @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { @@ -55,27 +50,15 @@ public class GoToBinaryPanel extends javax.swing.JPanel { positionTypeButtonGroup.add(fromStartRadioButton); fromStartRadioButton.setSelected(true); fromStartRadioButton.setText("Position from start"); - fromStartRadioButton.addItemListener(new java.awt.event.ItemListener() { - public void itemStateChanged(java.awt.event.ItemEvent evt) { - fromStartRadioButtonItemStateChanged(evt); - } - }); + fromStartRadioButton.addItemListener(this::fromStartRadioButtonItemStateChanged); positionTypeButtonGroup.add(fromEndRadioButton); fromEndRadioButton.setText("Position from end"); - fromEndRadioButton.addItemListener(new java.awt.event.ItemListener() { - public void itemStateChanged(java.awt.event.ItemEvent evt) { - fromEndRadioButtonItemStateChanged(evt); - } - }); + fromEndRadioButton.addItemListener(this::fromEndRadioButtonItemStateChanged); positionTypeButtonGroup.add(fromCursorRadioButton); fromCursorRadioButton.setText("Position relative to cursor"); - fromCursorRadioButton.addItemListener(new java.awt.event.ItemListener() { - public void itemStateChanged(java.awt.event.ItemEvent evt) { - fromCursorRadioButtonItemStateChanged(evt); - } - }); + fromCursorRadioButton.addItemListener(this::fromCursorRadioButtonItemStateChanged); positionLabel.setText("Position"); @@ -250,22 +233,16 @@ public class GoToBinaryPanel extends javax.swing.JPanel { long absolutePosition = getTargetPosition(); this.goToMode = goToMode; switch (goToMode) { - case FROM_START: { - setPositionValue(0l); - baseSwitchableSpinnerPanel.setMinimum(0l); + case FROM_START: + case FROM_END: { + setPositionValue(0L); + baseSwitchableSpinnerPanel.setMinimum(0L); baseSwitchableSpinnerPanel.setMaximum(maxPosition); baseSwitchableSpinnerPanel.revalidateSpinner(); break; } - case FROM_END: { - setPositionValue(0l); - baseSwitchableSpinnerPanel.setMinimum(0l); - baseSwitchableSpinnerPanel.setMaximum(maxPosition); - baseSwitchableSpinnerPanel.revalidateSpinner(); - break; - } - case FROM_CURSOR: { - setPositionValue(0l); + case FROM_CURSOR: { + setPositionValue(0L); baseSwitchableSpinnerPanel.setMinimum(-cursorPosition); baseSwitchableSpinnerPanel.setMaximum(maxPosition - cursorPosition); baseSwitchableSpinnerPanel.revalidateSpinner(); @@ -278,7 +255,7 @@ public class GoToBinaryPanel extends javax.swing.JPanel { } private long getPositionValue() { - return (Long) baseSwitchableSpinnerPanel.getValue(); + return baseSwitchableSpinnerPanel.getValue(); } private void setPositionValue(long value) { diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/HexViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/HexViewer.java index e0cdb6f8..c7c8ab26 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/HexViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/HexViewer.java @@ -30,7 +30,6 @@ public class HexViewer extends JPanel { private boolean valuesPanelVisible = false; private final AbstractAction cycleCodeTypesAction; - private javax.swing.JToggleButton lineWrappingToggleButton; private JButton cycleCodeTypeButton; private BinaryStatusApi binaryStatus; private final AbstractAction goToAction; @@ -114,18 +113,16 @@ public class HexViewer extends JPanel { cycleCodeTypeButton.setAction(cycleCodeTypesAction); updateCycleButtonState(); toolBar.add(cycleCodeTypeButton); - lineWrappingToggleButton = new javax.swing.JToggleButton(); + JToggleButton lineWrappingToggleButton = new JToggleButton(); lineWrappingToggleButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/the/bytecode/club/bytecodeviewer/gui/hexviewer/resources/bined-linewrap.png"))); lineWrappingToggleButton.setToolTipText("Toggle line wrapping"); - lineWrappingToggleButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - if (codeArea.getRowWrapping() == RowWrappingMode.WRAPPING) { - codeArea.setMaxBytesPerRow(16); - codeArea.setRowWrapping(RowWrappingMode.NO_WRAPPING); - } else { - codeArea.setMaxBytesPerRow(0); - codeArea.setRowWrapping(RowWrappingMode.WRAPPING); - } + lineWrappingToggleButton.addActionListener(evt -> { + if (codeArea.getRowWrapping() == RowWrappingMode.WRAPPING) { + codeArea.setMaxBytesPerRow(16); + codeArea.setRowWrapping(RowWrappingMode.NO_WRAPPING); + } else { + codeArea.setMaxBytesPerRow(0); + codeArea.setRowWrapping(RowWrappingMode.WRAPPING); } }); toolBar.add(lineWrappingToggleButton); @@ -137,15 +134,8 @@ public class HexViewer extends JPanel { codeArea.setComponentPopupMenu(new JPopupMenu() { @Override public void show(Component invoker, int x, int y) { - int clickedX = x; - int clickedY = y; - if (invoker instanceof JViewport) { - clickedX += ((JViewport) invoker).getParent().getX(); - clickedY += ((JViewport) invoker).getParent().getY(); - } - removeAll(); - final JPopupMenu menu = createPopupMenu(clickedX, clickedY); + final JPopupMenu menu = createPopupMenu(); menu.show(invoker, x, y); } }); @@ -187,15 +177,9 @@ public class HexViewer extends JPanel { public void registerBinaryStatus(BinaryStatusApi binaryStatusApi) { this.binaryStatus = binaryStatusApi; - codeArea.addCaretMovedListener((CodeAreaCaretPosition caretPosition) -> { - binaryStatus.setCursorPosition(caretPosition); - }); - codeArea.addSelectionChangedListener(() -> { - binaryStatus.setSelectionRange(codeArea.getSelection()); - }); - codeArea.addDataChangedListener(() -> { - binaryStatus.setCurrentDocumentSize(codeArea.getDataSize(), codeArea.getDataSize()); - }); + codeArea.addCaretMovedListener((CodeAreaCaretPosition caretPosition) -> binaryStatus.setCursorPosition(caretPosition)); + codeArea.addSelectionChangedListener(() -> binaryStatus.setSelectionRange(codeArea.getSelection())); + codeArea.addDataChangedListener(() -> binaryStatus.setCurrentDocumentSize(codeArea.getDataSize(), codeArea.getDataSize())); binaryStatus.setCurrentDocumentSize(codeArea.getDataSize(), codeArea.getDataSize()); codeArea.addEditModeChangedListener(binaryStatus::setEditMode); @@ -207,7 +191,6 @@ public class HexViewer extends JPanel { * * @return down mask for meta keys */ - @SuppressWarnings("deprecation") public static int getMetaMask() { try { switch (java.awt.Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) { @@ -226,7 +209,7 @@ public class HexViewer extends JPanel { } @Nonnull - private JPopupMenu createPopupMenu(int x, int y) { + private JPopupMenu createPopupMenu() { JPopupMenu menu = new JPopupMenu(); JMenu viewMenu = new JMenu("View"); @@ -311,22 +294,18 @@ public class HexViewer extends JPanel { final JMenuItem copyMenuItem = new JMenuItem("Copy"); copyMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, HexViewer.getMetaMask())); copyMenuItem.setEnabled(codeArea.hasSelection()); - copyMenuItem.addActionListener((ActionEvent e) -> { - codeArea.copy(); - }); + copyMenuItem.addActionListener((ActionEvent e) -> codeArea.copy()); menu.add(copyMenuItem); final JMenuItem selectAllMenuItem = new JMenuItem("Select All"); selectAllMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, HexViewer.getMetaMask())); - selectAllMenuItem.addActionListener((ActionEvent e) -> { - codeArea.selectAll(); - }); + selectAllMenuItem.addActionListener((ActionEvent e) -> codeArea.selectAll()); menu.add(selectAllMenuItem); menu.addSeparator(); final JMenuItem goToMenuItem = new JMenuItem("Go To..."); goToMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, HexViewer.getMetaMask())); - goToMenuItem.addActionListener(goToAction::actionPerformed); + goToMenuItem.addActionListener(goToAction); menu.add(goToMenuItem); return menu; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/OkCancelPanel.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/OkCancelPanel.java index f2037113..9eac2ae3 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/OkCancelPanel.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/OkCancelPanel.java @@ -14,7 +14,6 @@ public class OkCancelPanel extends javax.swing.JPanel { * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ - @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { @@ -22,18 +21,10 @@ public class OkCancelPanel extends javax.swing.JPanel { okButton = new javax.swing.JButton(); cancelButton.setText("Cancel"); - cancelButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - cancelButtonActionPerformed(evt); - } - }); + cancelButton.addActionListener(this::cancelButtonActionPerformed); okButton.setText("Ok"); - okButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - okButtonActionPerformed(evt); - } - }); + okButton.addActionListener(this::okButtonActionPerformed); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/ValuesPanel.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/ValuesPanel.java index 5e9af864..0532d39e 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/ValuesPanel.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/ValuesPanel.java @@ -29,7 +29,7 @@ public class ValuesPanel extends javax.swing.JPanel { public static final int SWORD_MIN_VALUE = -32768; public static final int SWORD_MAX_VALUE = 32767; public static final int UWORD_MAX_VALUE = 65535; - public static final long UINT_MAX_VALUE = 4294967295l; + public static final long UINT_MAX_VALUE = 4294967295L; public static final BigInteger ULONG_MAX_VALUE = new BigInteger("4294967295"); public static final BigInteger BIG_INTEGER_BYTE_MASK = BigInteger.valueOf(255); public static final String VALUE_OUT_OF_RANGE = "Value is out of range"; @@ -86,7 +86,6 @@ public class ValuesPanel extends javax.swing.JPanel { * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ - @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { @@ -128,53 +127,21 @@ public class ValuesPanel extends javax.swing.JPanel { binaryLabel.setText("Binary"); - binaryCheckBox0.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - binaryCheckBox0ActionPerformed(evt); - } - }); + binaryCheckBox0.addActionListener(this::binaryCheckBox0ActionPerformed); - binaryCheckBox1.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - binaryCheckBox1ActionPerformed(evt); - } - }); + binaryCheckBox1.addActionListener(this::binaryCheckBox1ActionPerformed); - binaryCheckBox2.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - binaryCheckBox2ActionPerformed(evt); - } - }); + binaryCheckBox2.addActionListener(this::binaryCheckBox2ActionPerformed); - binaryCheckBox3.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - binaryCheckBox3ActionPerformed(evt); - } - }); + binaryCheckBox3.addActionListener(this::binaryCheckBox3ActionPerformed); - binaryCheckBox4.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - binaryCheckBox4ActionPerformed(evt); - } - }); + binaryCheckBox4.addActionListener(this::binaryCheckBox4ActionPerformed); - binaryCheckBox5.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - binaryCheckBox5ActionPerformed(evt); - } - }); + binaryCheckBox5.addActionListener(this::binaryCheckBox5ActionPerformed); - binaryCheckBox6.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - binaryCheckBox6ActionPerformed(evt); - } - }); + binaryCheckBox6.addActionListener(this::binaryCheckBox6ActionPerformed); - binaryCheckBox7.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - binaryCheckBox7ActionPerformed(evt); - } - }); + binaryCheckBox7.addActionListener(this::binaryCheckBox7ActionPerformed); byteLabel.setText("Byte"); @@ -254,39 +221,23 @@ public class ValuesPanel extends javax.swing.JPanel { bigEndianRadioButton.setSelected(true); bigEndianRadioButton.setText("BE"); bigEndianRadioButton.setToolTipText("Big Endian"); - bigEndianRadioButton.addChangeListener(new javax.swing.event.ChangeListener() { - public void stateChanged(javax.swing.event.ChangeEvent evt) { - bigEndianRadioButtonStateChanged(evt); - } - }); + bigEndianRadioButton.addChangeListener(this::bigEndianRadioButtonStateChanged); endianButtonGroup.add(littleEndianRadioButton); littleEndianRadioButton.setText("LE"); littleEndianRadioButton.setToolTipText("Little Endian"); - littleEndianRadioButton.addChangeListener(new javax.swing.event.ChangeListener() { - public void stateChanged(javax.swing.event.ChangeEvent evt) { - littleEndianRadioButtonStateChanged(evt); - } - }); + littleEndianRadioButton.addChangeListener(this::littleEndianRadioButtonStateChanged); integerSignButtonGroup.add(signedRadioButton); signedRadioButton.setSelected(true); signedRadioButton.setText("Sig"); signedRadioButton.setToolTipText("Signed Integers"); - signedRadioButton.addChangeListener(new javax.swing.event.ChangeListener() { - public void stateChanged(javax.swing.event.ChangeEvent evt) { - signedRadioButtonStateChanged(evt); - } - }); + signedRadioButton.addChangeListener(this::signedRadioButtonStateChanged); integerSignButtonGroup.add(unsignedRadioButton); unsignedRadioButton.setText("Uns"); unsignedRadioButton.setToolTipText("Unsigned Integers"); - unsignedRadioButton.addChangeListener(new javax.swing.event.ChangeListener() { - public void stateChanged(javax.swing.event.ChangeEvent evt) { - unsignedRadioButtonStateChanged(evt); - } - }); + unsignedRadioButton.addChangeListener(this::unsignedRadioButtonStateChanged); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); @@ -482,7 +433,7 @@ public class ValuesPanel extends javax.swing.JPanel { private void byteTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_byteTextFieldKeyReleased if (evt.getKeyCode() == KeyEvent.VK_ENTER && isEditable()) { try { - Integer intValue = Integer.valueOf(byteTextField.getText()); + int intValue = Integer.parseInt(byteTextField.getText()); if (isSigned()) { if (intValue < Byte.MIN_VALUE || intValue > Byte.MAX_VALUE) { throw new NumberFormatException(VALUE_OUT_OF_RANGE); @@ -493,7 +444,7 @@ public class ValuesPanel extends javax.swing.JPanel { } } - valuesCache[0] = intValue.byteValue(); + valuesCache[0] = (byte) intValue; modifyValues(1); updateValues(); } catch (NumberFormatException ex) { @@ -505,7 +456,7 @@ public class ValuesPanel extends javax.swing.JPanel { private void wordTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_wordTextFieldKeyReleased if (evt.getKeyCode() == KeyEvent.VK_ENTER && isEditable()) { try { - Integer intValue = Integer.valueOf(wordTextField.getText()); + int intValue = Integer.parseInt(wordTextField.getText()); if (isSigned()) { if (intValue < SWORD_MIN_VALUE || intValue > SWORD_MAX_VALUE) { throw new NumberFormatException(VALUE_OUT_OF_RANGE); @@ -534,7 +485,7 @@ public class ValuesPanel extends javax.swing.JPanel { private void intTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_intTextFieldKeyReleased if (evt.getKeyCode() == KeyEvent.VK_ENTER && isEditable()) { try { - Long longValue = Long.valueOf(intTextField.getText()); + long longValue = Long.parseLong(intTextField.getText()); if (isSigned()) { if (longValue < Integer.MIN_VALUE || longValue > Integer.MAX_VALUE) { throw new NumberFormatException(VALUE_OUT_OF_RANGE); @@ -569,7 +520,7 @@ public class ValuesPanel extends javax.swing.JPanel { try { ByteOrder byteOrder = getByteOrder(); if (isSigned()) { - Long longValue = Long.valueOf(longTextField.getText()); + long longValue = Long.parseLong(longTextField.getText()); byteBuffer.rewind(); if (byteBuffer.order() != byteOrder) { @@ -579,7 +530,7 @@ public class ValuesPanel extends javax.swing.JPanel { byteBuffer.putLong(longValue); } else { BigInteger bigInteger = new BigInteger(longTextField.getText()); - if (bigInteger.compareTo(BigInteger.ZERO) == -1 || bigInteger.compareTo(ULONG_MAX_VALUE) == 1) { + if (bigInteger.signum() == -1 || bigInteger.compareTo(ULONG_MAX_VALUE) > 0) { throw new NumberFormatException(VALUE_OUT_OF_RANGE); } @@ -610,7 +561,7 @@ public class ValuesPanel extends javax.swing.JPanel { if (evt.getKeyCode() == KeyEvent.VK_ENTER && isEditable()) { try { ByteOrder byteOrder = getByteOrder(); - Float floatValue = Float.valueOf(floatTextField.getText()); + float floatValue = Float.parseFloat(floatTextField.getText()); byteBuffer.rewind(); if (byteBuffer.order() != byteOrder) { @@ -631,7 +582,7 @@ public class ValuesPanel extends javax.swing.JPanel { if (evt.getKeyCode() == KeyEvent.VK_ENTER && isEditable()) { try { ByteOrder byteOrder = getByteOrder(); - Double doubleValue = Double.valueOf(doubleTextField.getText()); + double doubleValue = Double.parseDouble(doubleTextField.getText()); byteBuffer.rewind(); if (byteBuffer.order() != byteOrder) { @@ -703,9 +654,7 @@ public class ValuesPanel extends javax.swing.JPanel { updateValues(); }; codeArea.addDataChangedListener(dataChangedListener); - caretMovedListener = (CodeAreaCaretPosition caretPosition) -> { - updateValues(); - }; + caretMovedListener = (CodeAreaCaretPosition caretPosition) -> updateValues(); codeArea.addCaretMovedListener(caretMovedListener); updateEditMode(); updateValues(); @@ -815,9 +764,7 @@ public class ValuesPanel extends javax.swing.JPanel { } private void scheduleNextStep(final ValuesPanelField valuesPanelField) { - SwingUtilities.invokeLater(() -> { - updateValue(valuesPanelField); - }); + SwingUtilities.invokeLater(() -> updateValue(valuesPanelField)); } public boolean isUpdateInProgress() { @@ -913,11 +860,11 @@ public class ValuesPanel extends javax.swing.JPanel { case INTEGER: { long intValue = signed ? (byteOrder == ByteOrder.LITTLE_ENDIAN - ? (values[0] & 0xffl) | ((values[1] & 0xffl) << 8) | ((values[2] & 0xffl) << 16) | (values[3] << 24) - : (values[3] & 0xffl) | ((values[2] & 0xffl) << 8) | ((values[1] & 0xffl) << 16) | (values[0] << 24)) + ? (values[0] & 0xffL) | ((values[1] & 0xffL) << 8) | ((values[2] & 0xffL) << 16) | (values[3] << 24) + : (values[3] & 0xffL) | ((values[2] & 0xffL) << 8) | ((values[1] & 0xffL) << 16) | (values[0] << 24)) : (byteOrder == ByteOrder.LITTLE_ENDIAN - ? (values[0] & 0xffl) | ((values[1] & 0xffl) << 8) | ((values[2] & 0xffl) << 16) | ((values[3] & 0xffl) << 24) - : (values[3] & 0xffl) | ((values[2] & 0xffl) << 8) | ((values[1] & 0xffl) << 16) | ((values[0] & 0xffl) << 24)); + ? (values[0] & 0xffL) | ((values[1] & 0xffL) << 8) | ((values[2] & 0xffL) << 16) | ((values[3] & 0xffL) << 24) + : (values[3] & 0xffL) | ((values[2] & 0xffL) << 8) | ((values[1] & 0xffL) << 16) | ((values[0] & 0xffL) << 24)); intTextField.setText(String.valueOf(intValue)); break; } @@ -931,11 +878,11 @@ public class ValuesPanel extends javax.swing.JPanel { longTextField.setText(String.valueOf(byteBuffer.getLong())); } else { long longValue = byteOrder == ByteOrder.LITTLE_ENDIAN - ? (values[0] & 0xffl) | ((values[1] & 0xffl) << 8) | ((values[2] & 0xffl) << 16) | ((values[3] & 0xffl) << 24) - | ((values[4] & 0xffl) << 32) | ((values[5] & 0xffl) << 40) | ((values[6] & 0xffl) << 48) - : (values[7] & 0xffl) | ((values[6] & 0xffl) << 8) | ((values[5] & 0xffl) << 16) | ((values[4] & 0xffl) << 24) - | ((values[3] & 0xffl) << 32) | ((values[2] & 0xffl) << 40) | ((values[1] & 0xffl) << 48); - BigInteger bigInt1 = BigInteger.valueOf(values[byteOrder == ByteOrder.LITTLE_ENDIAN ? 7 : 0] & 0xffl); + ? (values[0] & 0xffL) | ((values[1] & 0xffL) << 8) | ((values[2] & 0xffL) << 16) | ((values[3] & 0xffL) << 24) + | ((values[4] & 0xffL) << 32) | ((values[5] & 0xffL) << 40) | ((values[6] & 0xffL) << 48) + : (values[7] & 0xffL) | ((values[6] & 0xffL) << 8) | ((values[5] & 0xffL) << 16) | ((values[4] & 0xffL) << 24) + | ((values[3] & 0xffL) << 32) | ((values[2] & 0xffL) << 40) | ((values[1] & 0xffL) << 48); + BigInteger bigInt1 = BigInteger.valueOf(values[byteOrder == ByteOrder.LITTLE_ENDIAN ? 7 : 0] & 0xffL); BigInteger bigInt2 = bigInt1.shiftLeft(56); BigInteger bigInt3 = bigInt2.add(BigInteger.valueOf(longValue)); longTextField.setText(bigInt3.toString()); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListPane.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListPane.java index d092e8d9..9e5c02a6 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListPane.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListPane.java @@ -94,7 +94,7 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File //used to remove resources from the resource list public void removeFile(ResourceContainer resourceContainer) { - BytecodeViewer.resourceContainers.remove(resourceContainer); + while (BytecodeViewer.resourceContainers.values().remove(resourceContainer)); LazyNameUtil.removeName(resourceContainer.name); } @@ -263,7 +263,6 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File } } - @SuppressWarnings("rawtypes") public void removeNode(final JTree tree, final TreePath nodePath) { MutableTreeNode node = findNodeByPath(nodePath); if (node == null) @@ -274,7 +273,6 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File tree.updateUI(); } - @SuppressWarnings("rawtypes") private MutableTreeNode findNodeByPath(TreePath path) { MutableTreeNode node = treeRoot; for (int pathStep = 1; pathStep < path.getPathCount(); pathStep++) { diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/PerformSearch.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/PerformSearch.java index 9790ff3c..f1a1e4f1 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/PerformSearch.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/PerformSearch.java @@ -55,9 +55,7 @@ class PerformSearch extends BackgroundSearchThread } for (ResourceContainer container : BytecodeViewer.resourceContainers.values()) - container.resourceClasses.forEach((key,cn)->{ - searchBoxPane.searchType.panel.search(container, key, cn, searchBoxPane.exact.isSelected()); - }); + container.resourceClasses.forEach((key,cn)-> searchBoxPane.searchType.panel.search(container, key, cn, searchBoxPane.exact.isSelected())); BytecodeViewer.viewer.searchBoxPane.search.setEnabled(true); BytecodeViewer.viewer.searchBoxPane.search.setText(TranslatedStrings.SEARCH.toString()); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/SearchBoxPane.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/SearchBoxPane.java index b816e0af..54964a6c 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/SearchBoxPane.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/SearchBoxPane.java @@ -65,13 +65,12 @@ public class SearchBoxPane extends TranslatedVisibleComponent public final JComboBox typeBox; public SearchType searchType = null; - public final JComboBox searchRadiusBox; + public final JComboBox searchRadiusBox; public final JPopupMenu rightClickMenu = new JPopupMenu(); public JButton search = new TranslatedJButton("Search", TranslatedComponents.SEARCH); public BackgroundSearchThread performSearchThread; - @SuppressWarnings("unchecked") public SearchBoxPane() { super("Search", TranslatedComponents.SEARCH); @@ -82,20 +81,20 @@ public class SearchBoxPane extends TranslatedVisibleComponent searchRadiusOpt.add(new TranslatedJLabel("Search from ", TranslatedComponents.SEARCH_FROM), BorderLayout.WEST); - DefaultComboBoxModel model = new DefaultComboBoxModel(); + DefaultComboBoxModel radiusModel = new DefaultComboBoxModel<>(); for (final SearchRadius st : SEARCH_RADII) - model.addElement(st); + radiusModel.addElement(st); - searchRadiusBox = new JComboBox(model); + searchRadiusBox = new JComboBox<>(radiusModel); searchRadiusOpt.add(searchRadiusBox, BorderLayout.CENTER); searchOpts.add(searchRadiusOpt); - model = new DefaultComboBoxModel(); + DefaultComboBoxModel typeModel = new DefaultComboBoxModel<>(); for (final SearchType st : SEARCH_TYPES) - model.addElement(st); + typeModel.addElement(st); - typeBox = new JComboBox(model); + typeBox = new JComboBox<>(typeModel); final JPanel searchOptPanel = new JPanel(); final ItemListener il = arg0 -> { diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/BytecodeViewPanel.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/BytecodeViewPanel.java index 9315fe9b..53e39e18 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/BytecodeViewPanel.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/BytecodeViewPanel.java @@ -80,8 +80,8 @@ public class BytecodeViewPanel extends JPanel return true; SystemConsole errConsole = new SystemConsole(TranslatedStrings.JAVA_COMPILE_FAILED.toString()); - errConsole.setText(TranslatedStrings.ERROR_COMPILING_CLASS.toString() + " " + viewer.resource.getResourceClassNode().name + - nl + TranslatedStrings.COMPILER_TIP.toString() + + errConsole.setText(TranslatedStrings.ERROR_COMPILING_CLASS + " " + viewer.resource.getResourceClassNode().name + + nl + TranslatedStrings.COMPILER_TIP + nl + nl + TranslatedStrings.SUGGESTED_FIX_COMPILER_ERROR + nl + nl); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/DecompilerSelectionPane.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/DecompilerSelectionPane.java index 2f62b63b..30c2dc7c 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/DecompilerSelectionPane.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/DecompilerSelectionPane.java @@ -72,9 +72,9 @@ public class DecompilerSelectionPane { this.paneID = paneID; if(paneID == 1) - this.menu = new TranslatedJMenu("Pane " + paneID, TranslatedComponents.PANE_1); + this.menu = new TranslatedJMenu("Pane " + 1, TranslatedComponents.PANE_1); else if(paneID == 2) - this.menu = new TranslatedJMenu("Pane " + paneID, TranslatedComponents.PANE_2); + this.menu = new TranslatedJMenu("Pane " + 2, TranslatedComponents.PANE_2); else this.menu = new TranslatedJMenu("Pane " + paneID, TranslatedComponents.PANE_3); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabbedPane.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabbedPane.java index 52171c52..582353a3 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabbedPane.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabbedPane.java @@ -91,8 +91,8 @@ public class TabbedPane extends JPanel //define the right click pop-up menu JPopupMenu rightClickMenu = new JPopupMenu(); - JMenuItem closeAllTabs = new JMenuItem(TranslatedStrings.CLOSE_ALL_BUT_THIS.toString() + ": " + name); - JMenuItem closeTab = new JMenuItem(TranslatedStrings.CLOSE_TAB.toString() + ": " + name); + JMenuItem closeAllTabs = new JMenuItem(TranslatedStrings.CLOSE_ALL_BUT_THIS + ": " + name); + JMenuItem closeTab = new JMenuItem(TranslatedStrings.CLOSE_TAB + ": " + name); rightClickMenu.add(closeAllTabs); rightClickMenu.add(closeTab); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/Workspace.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/Workspace.java index 21e9f23e..cf42fe6a 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/Workspace.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/Workspace.java @@ -119,8 +119,8 @@ public class Workspace extends TranslatedVisibleComponent if (c != null && bounds.intersects(c.getBounds())) { popUp.setVisible(true); - closeAllTabs.setText(TranslatedStrings.CLOSE_TAB.toString() + ": " + ((TabbedPane) c).tabName); - closeTab.setText(TranslatedStrings.CLOSE_TAB.toString() + ": " + ((TabbedPane) c).tabName); + closeAllTabs.setText(TranslatedStrings.CLOSE_TAB + ": " + ((TabbedPane) c).tabName); + closeTab.setText(TranslatedStrings.CLOSE_TAB + ": " + ((TabbedPane) c).tabName); } else { diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ComponentViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ComponentViewer.java index 767774a0..eb365c64 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ComponentViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ComponentViewer.java @@ -33,7 +33,7 @@ import the.bytecode.club.bytecodeviewer.resources.Resource; public class ComponentViewer extends ResourceViewer { - private Component component; + private final Component component; private static final String containerName = "internalComponent."; public ComponentViewer(String title, Component component) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/synchronizedscroll/MethodData.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/synchronizedscroll/MethodData.java index 50e49751..fa4e2912 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/synchronizedscroll/MethodData.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/synchronizedscroll/MethodData.java @@ -1,6 +1,7 @@ package the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.synchronizedscroll; import java.util.Arrays; +import java.util.Objects; import org.objectweb.asm.Type; /*************************************************************************** @@ -28,18 +29,20 @@ import org.objectweb.asm.Type; public class MethodData { public String name, desc; - + @Override - public boolean equals(final Object o) - { - return equals((MethodData) o); + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof MethodData)) return false; + MethodData that = (MethodData) o; + return Objects.equals(name, that.name) && Objects.equals(desc, that.desc); } - - public boolean equals(final MethodData md) - { - return this.name.equals(md.name) && this.desc.equals(md.desc); + + @Override + public int hashCode() { + return Objects.hash(name, desc); } - + public String constructPattern() { final StringBuilder pattern = new StringBuilder(); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/util/BytecodeViewPanelUpdater.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/util/BytecodeViewPanelUpdater.java index 59be7b9f..3d012e73 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/util/BytecodeViewPanelUpdater.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/util/BytecodeViewPanelUpdater.java @@ -119,7 +119,7 @@ public class BytecodeViewPanelUpdater implements Runnable { try { Thread.sleep(1); - } catch (Exception e) {} + } catch (Exception ignored) {} } } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/obfuscators/mapping/RemappingSignatureAdapter.java b/src/main/java/the/bytecode/club/bytecodeviewer/obfuscators/mapping/RemappingSignatureAdapter.java index 27316830..1191714c 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/obfuscators/mapping/RemappingSignatureAdapter.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/obfuscators/mapping/RemappingSignatureAdapter.java @@ -68,7 +68,7 @@ public class RemappingSignatureAdapter extends SignatureVisitor { @Override public void visitInnerClassType(String name) { String remappedOuter = remapper.mapType(className) + '$'; - className = className + '$' + name; + className += '$' + name; String remappedName = remapper.mapType(className); int index = remappedName.startsWith(remappedOuter) ? remappedOuter .length() : remappedName.lastIndexOf('$') + 1; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginManager.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginManager.java index 5c450e04..e0868dee 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginManager.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginManager.java @@ -55,7 +55,7 @@ public final class PluginManager { private static final Map launchStrategies = new HashMap<>(); private static final PluginFileFilter filter = new PluginFileFilter(); - private static List pluginInstances = new ArrayList<>(); + private static final List pluginInstances = new ArrayList<>(); //TODO this system needs to be redone, currently it will conflict if more than one plugin is ran at the same time // the solution is to tie the plugin object into the plugin console, @@ -155,8 +155,8 @@ public final class PluginManager return; } - final String name = (activePlugin == null || activePlugin.activeContainer == null) - ? ("#" + (activeTabbedException.getTabbedPane().getTabCount() + 1)) : activePlugin.activeContainer.name; + final String name = activePlugin.activeContainer == null + ? "#" + (activeTabbedException.getTabbedPane().getTabCount() + 1) : activePlugin.activeContainer.name; ExceptionUI existingUI = exceptionTabs.get(name); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginWriter.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginWriter.java index daa82df2..e4e33472 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginWriter.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginWriter.java @@ -231,7 +231,7 @@ public class PluginWriter extends JFrame //auto append extension if (!path.endsWith("." + ext)) - path = path + "." + ext; + path += "." + ext; if (!DialogUtils.canOverwriteFile(path)) return; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/AllatoriStringDecrypter.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/AllatoriStringDecrypter.java index 1dcd5b2d..27a9209f 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/AllatoriStringDecrypter.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/AllatoriStringDecrypter.java @@ -226,7 +226,7 @@ public class AllatoriStringDecrypter extends Plugin { InsnList iList = decryptermethodnode.instructions; - AbstractInsnNode insn = null, removeInsn = null; + AbstractInsnNode insn = null, removeInsn; for (AbstractInsnNode i : iList.toArray()) { if (i instanceof MethodInsnNode) @@ -292,7 +292,7 @@ public class AllatoriStringDecrypter extends Plugin public static class AllatoriStringDecrypterOptionsFrame extends JFrame { - private JTextField textField; + private final JTextField textField; public AllatoriStringDecrypterOptionsFrame() { diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ExternalResources.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ExternalResources.java index 21f9a2e0..be14d1bc 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ExternalResources.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ExternalResources.java @@ -62,9 +62,7 @@ public class ExternalResources return Configuration.java; //check CLI for java - testCommand(new String[]{"java", "-version"}, "java version", ()->{ - Configuration.java = "java"; - }); + testCommand(new String[]{"java", "-version"}, "java version", ()-> Configuration.java = "java"); if(!Configuration.java.isEmpty()) return Configuration.java; @@ -137,9 +135,7 @@ public class ExternalResources return Configuration.python2; //check if 'python' command is bound as python 2.X - testCommand(new String[]{"python", "--version"}, "python 2", ()->{ - Configuration.python2 = "python"; - }); + testCommand(new String[]{"python", "--version"}, "python 2", ()-> Configuration.python2 = "python"); if(!Configuration.python2.isEmpty()) return Configuration.python2; @@ -178,17 +174,13 @@ public class ExternalResources //check if 'python3' command is bound as python 3.X - testCommand(new String[]{"python3", "--version"}, "python 3", ()->{ - Configuration.python3 = "python3"; - }); + testCommand(new String[]{"python3", "--version"}, "python 3", ()-> Configuration.python3 = "python3"); if(!Configuration.python3.isEmpty()) return Configuration.python3; //check if 'python' command is bound as python 3.X - testCommand(new String[]{"python", "--version"}, "python 3", ()->{ - Configuration.python3 = "python"; - }); + testCommand(new String[]{"python", "--version"}, "python 3", ()-> Configuration.python3 = "python"); if(!Configuration.python3.isEmpty()) return Configuration.python3; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/APKExport.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/APKExport.java index edb9ccca..85160ce4 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/APKExport.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/APKExport.java @@ -104,9 +104,9 @@ public class APKExport implements Exporter final File file = fc.getSelectedFile(); String output = file.getAbsolutePath(); - //auto appened .apk + //auto append .apk if (!output.endsWith(".apk")) - output = output + ".apk"; + output += ".apk"; final File file2 = new File(output); if (!DialogUtils.canOverwriteFile(file2)) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/DexExport.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/DexExport.java index c4e55dcd..8850cbca 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/DexExport.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/DexExport.java @@ -65,7 +65,7 @@ public class DexExport implements Exporter //auto append .dex if (!output.endsWith(".dex")) - output = output + ".dex"; + output += ".dex"; File outputPath = new File(output); if (!DialogUtils.canOverwriteFile(outputPath)) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/RunnableJarExporter.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/RunnableJarExporter.java index 501f49ac..64ecf79d 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/RunnableJarExporter.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/RunnableJarExporter.java @@ -59,7 +59,7 @@ public class RunnableJarExporter implements Exporter //auto append .jar if (!path.endsWith(".jar")) - path = path + ".jar"; + path += ".jar"; if (!DialogUtils.canOverwriteFile(path)) return; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/importing/ImportResource.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/importing/ImportResource.java index ca2f3d78..0774d12c 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/importing/ImportResource.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/importing/ImportResource.java @@ -54,7 +54,6 @@ public class ImportResource implements Runnable if (file.isDirectory()) { Import.DIRECTORY.getImporter().open(file); - continue; } //everything else import as a resource else if(!importKnownFile(file)) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/translation/Language.java b/src/main/java/the/bytecode/club/bytecodeviewer/translation/Language.java index 62d96a73..2bb2fcf3 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/translation/Language.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/translation/Language.java @@ -132,7 +132,7 @@ public enum Language try { TranslatedStrings str = TranslatedStrings.valueOf(text.key); str.setText(text.value); - } catch (IllegalArgumentException e) { } + } catch (IllegalArgumentException ignored) { } //check if translation key has been assigned to a component, //on fail print an error alerting the devs diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/Enjarify.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/Enjarify.java index fef2b65a..318f96f0 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/Enjarify.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/Enjarify.java @@ -82,7 +82,7 @@ public class Enjarify { try { Thread.sleep(500); - } catch (InterruptedException e) { } + } catch (InterruptedException ignored) { } } }, "Enjarify Fail Safe Thread").start(); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/MiscUtils.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/MiscUtils.java index 3f688ea9..f586702c 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/MiscUtils.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/MiscUtils.java @@ -54,7 +54,7 @@ import static the.bytecode.club.bytecodeviewer.BytecodeViewer.gson; public class MiscUtils { - private static CharsetEncoder asciiEncoder = StandardCharsets.US_ASCII.newEncoder(); // or "ISO-8859-1" for ISO Latin 1 + private static final CharsetEncoder asciiEncoder = StandardCharsets.US_ASCII.newEncoder(); // or "ISO-8859-1" for ISO Latin 1 private static final String AB = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; private static final String AN = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; private static final Random rnd = new Random(); @@ -186,7 +186,7 @@ public class MiscUtils public static String append(File file, String extension) { String path = file.getAbsolutePath(); if (!path.endsWith(extension)) - path = path + extension; + path += extension; return path; } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/SeqAndCount.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/SeqAndCount.java index d9380430..4dc64c73 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/SeqAndCount.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/SeqAndCount.java @@ -37,26 +37,26 @@ class SeqAndCount public SeqAndCount incrSeq() { - seq = seq + 1; + seq++; return this; } public SeqAndCount incrCount() { - count = count + 1; + count++; return this; } public SeqAndCount decrCount() { - count = count - 1; + count--; return this; } public SeqAndCount incrSeqAndCount() { - seq = seq + 1; - count = count + 1; + seq++; + count++; return this; } diff --git a/src/main/resources/translations/html/intro.english.draft.html b/src/main/resources/translations/html/intro.english.draft.html index 418b8338..fe670f6b 100644 --- a/src/main/resources/translations/html/intro.english.draft.html +++ b/src/main/resources/translations/html/intro.english.draft.html @@ -1,4 +1,4 @@ - +

About

Bytecode Viewer (BCV) is an easy to use Java & Android Reverse Engineering Suite!
diff --git a/src/main/resources/translations/html/intro.english.html b/src/main/resources/translations/html/intro.english.html index 54630c73..0f7c30be 100644 --- a/src/main/resources/translations/html/intro.english.html +++ b/src/main/resources/translations/html/intro.english.html @@ -1,4 +1,4 @@ - +

About

Bytecode Viewer (BCV) was designed to be extremely user and beginner friendly, because of this almost everything diff --git a/src/main/resources/translations/html/intro.german.html b/src/main/resources/translations/html/intro.german.html index f07fdfa1..37989636 100644 --- a/src/main/resources/translations/html/intro.german.html +++ b/src/main/resources/translations/html/intro.german.html @@ -1,4 +1,4 @@ - +

Über uns

Der Bytecode Viewer (BCV) wurde extrem benutzer- und einsteigerfreundlich gestaltet, deshalb ist fast alles diff --git a/src/main/resources/translations/html/intro.mandarin.html b/src/main/resources/translations/html/intro.mandarin.html index 27b462eb..e56bbf8b 100644 --- a/src/main/resources/translations/html/intro.mandarin.html +++ b/src/main/resources/translations/html/intro.mandarin.html @@ -1,9 +1,9 @@ - +

关于

Bytecode Viewer (BCV)被设计成对用户和初学者非常友好,因此,几乎所有的东西都可以通过界面、设置、工具等方式进行访问。 -
将Jar/APK/Class文件拖到资源列表中。
+

将Jar/APK/Class文件拖到资源列表中。

设置

    @@ -118,4 +118,4 @@ Bytecode Viewer (BCV)被设计成对用户和初学者非常友好,因此,
  • Bytecode Viewer的主页是 https://bytecodeviewer.com
- \ No newline at end of file + From 55918948110fff26df5625720f3aa6da4136c938 Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Mon, 20 Dec 2021 00:31:22 +0100 Subject: [PATCH 06/11] Update dependencies one last time --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 88f1a0ca..0dd5eb6c 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ 2.7.3 0.3.4 5.2.1.Final - v39 + v40 94d9422 2.8.9 31.0.1-jre From dda0604696750ce87bbbaaf4f6a4d1076e37e0c2 Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Mon, 3 Jan 2022 17:23:16 +0100 Subject: [PATCH 07/11] Update dependencies --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 0dd5eb6c..757aabca 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ 2.7.3 0.3.4 5.2.1.Final - v40 + v41 94d9422 2.8.9 31.0.1-jre @@ -44,7 +44,7 @@ 3.2 0.2.0 0.5.36 - 3.1.4 + 3.1.5 2.1.1 1.7.32 2.5.2 From 54fc4e5e485ecccd0f42ee73ef5c4607d83d94d8 Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Mon, 3 Jan 2022 20:05:56 +0100 Subject: [PATCH 08/11] Use RSTA's file type detector --- .../gui/resourceviewer/viewer/FileViewer.java | 5 +++-- .../bytecode/club/bytecodeviewer/plugin/PluginWriter.java | 4 ++-- .../club/bytecodeviewer/resources/ResourceType.java | 7 ++++--- .../bytecode/club/bytecodeviewer/util/SyntaxLanguage.java | 4 +++- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/FileViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/FileViewer.java index f4fb5afc..2a3cac77 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/FileViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/FileViewer.java @@ -3,11 +3,13 @@ package the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer; import java.awt.BorderLayout; import java.awt.Font; import java.awt.image.BufferedImage; +import java.io.File; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import org.apache.commons.io.FilenameUtils; +import org.fife.ui.rsyntaxtextarea.FileTypeUtil; import org.imgscalr.Scalr; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Configuration; @@ -19,7 +21,6 @@ import the.bytecode.club.bytecodeviewer.resources.Resource; import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; import the.bytecode.club.bytecodeviewer.resources.ResourceType; import the.bytecode.club.bytecodeviewer.util.MiscUtils; -import the.bytecode.club.bytecodeviewer.util.SyntaxLanguage; /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * @@ -143,7 +144,7 @@ public class FileViewer extends ResourceViewer } textArea.setCodeFoldingEnabled(true); - textArea.setSyntaxEditingStyle(SyntaxLanguage.detectLanguage(nameLowerCase, contentsAsString).getSyntaxConstant()); + textArea.setSyntaxEditingStyle(FileTypeUtil.get().guessContentType(new File(nameLowerCase))); textArea.setText(contentsAsString); textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int) BytecodeViewer.viewer.fontSpinner.getValue())); textArea.setCaretPosition(0); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginWriter.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginWriter.java index e4e33472..4bdfe063 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginWriter.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginWriter.java @@ -15,6 +15,7 @@ import javax.swing.JPanel; import me.konloch.kontainer.io.DiskReader; import me.konloch.kontainer.io.DiskWriter; import org.apache.commons.compress.utils.FileNameUtils; +import org.fife.ui.rsyntaxtextarea.FileTypeUtil; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.gui.components.FileChooser; @@ -26,7 +27,6 @@ import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJMenu; import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJMenuItem; import the.bytecode.club.bytecodeviewer.util.DialogUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils; -import the.bytecode.club.bytecodeviewer.util.SyntaxLanguage; import static the.bytecode.club.bytecodeviewer.Constants.fs; import static the.bytecode.club.bytecodeviewer.Constants.tempDirectory; @@ -88,7 +88,7 @@ public class PluginWriter extends JFrame area.setOnCtrlS(this::save); area.setText(content); area.setCaretPosition(0); - area.setSyntaxEditingStyle(SyntaxLanguage.detectLanguage(pluginName, content).getSyntaxConstant()); + area.setSyntaxEditingStyle(FileTypeUtil.get().guessContentType(new File(pluginName))); content = null; JButton run = new JButton("Run"); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceType.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceType.java index bb66f36c..6613bc2d 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceType.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceType.java @@ -29,9 +29,10 @@ import javax.swing.ImageIcon; public enum ResourceType { - //TODO tar/gzip? - //TODO add the files icons for the missing files from the.bytecode.club.bytecodeviewer.util.SyntaxLanguage - + // TODO tar/gzip? + // TODO add the files icons for the missing files from the.bytecode.club.bytecodeviewer.util.SyntaxLanguage + // or from org.fife.ui.rsyntaxtextarea.FileTypeUtil or from org.fife.ui.rsyntaxtextarea.SyntaxConstants + CLASS_FILE(IconResources.classIcon, "class"), JAVA_ARCHIVE(IconResources.jarIcon, "jar", "war", "ear"), ZIP_ARCHIVE(IconResources.zipIcon, "zip"), diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/SyntaxLanguage.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/SyntaxLanguage.java index cab24097..60aab8dc 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/SyntaxLanguage.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/SyntaxLanguage.java @@ -23,7 +23,9 @@ import org.fife.ui.rsyntaxtextarea.SyntaxConstants; /** * @author ThexXTURBOXx + * @deprecated See {@link org.fife.ui.rsyntaxtextarea.FileTypeUtil#guessContentType(java.io.File)} */ +@Deprecated public enum SyntaxLanguage { XML(SyntaxConstants.SYNTAX_STYLE_XML, @@ -92,4 +94,4 @@ public enum SyntaxLanguage } return NONE; } -} \ No newline at end of file +} From 347b6acf0f1faeca1d21a474a4baed4c88f283b3 Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Mon, 3 Jan 2022 22:51:00 +0100 Subject: [PATCH 09/11] Better language detection --- .../gui/resourceviewer/viewer/FileViewer.java | 5 ++--- .../bytecodeviewer/plugin/PluginWriter.java | 4 ++-- .../bytecodeviewer/util/SyntaxLanguage.java | 22 +++++++++++++++---- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/FileViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/FileViewer.java index 2a3cac77..1571232d 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/FileViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/FileViewer.java @@ -3,13 +3,11 @@ package the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer; import java.awt.BorderLayout; import java.awt.Font; import java.awt.image.BufferedImage; -import java.io.File; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import org.apache.commons.io.FilenameUtils; -import org.fife.ui.rsyntaxtextarea.FileTypeUtil; import org.imgscalr.Scalr; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Configuration; @@ -21,6 +19,7 @@ import the.bytecode.club.bytecodeviewer.resources.Resource; import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; import the.bytecode.club.bytecodeviewer.resources.ResourceType; import the.bytecode.club.bytecodeviewer.util.MiscUtils; +import the.bytecode.club.bytecodeviewer.util.SyntaxLanguage; /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * @@ -144,7 +143,7 @@ public class FileViewer extends ResourceViewer } textArea.setCodeFoldingEnabled(true); - textArea.setSyntaxEditingStyle(FileTypeUtil.get().guessContentType(new File(nameLowerCase))); + SyntaxLanguage.setLanguage(textArea, nameLowerCase); textArea.setText(contentsAsString); textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int) BytecodeViewer.viewer.fontSpinner.getValue())); textArea.setCaretPosition(0); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginWriter.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginWriter.java index 4bdfe063..2ecfa99e 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginWriter.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginWriter.java @@ -15,7 +15,6 @@ import javax.swing.JPanel; import me.konloch.kontainer.io.DiskReader; import me.konloch.kontainer.io.DiskWriter; import org.apache.commons.compress.utils.FileNameUtils; -import org.fife.ui.rsyntaxtextarea.FileTypeUtil; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.gui.components.FileChooser; @@ -27,6 +26,7 @@ import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJMenu; import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJMenuItem; import the.bytecode.club.bytecodeviewer.util.DialogUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils; +import the.bytecode.club.bytecodeviewer.util.SyntaxLanguage; import static the.bytecode.club.bytecodeviewer.Constants.fs; import static the.bytecode.club.bytecodeviewer.Constants.tempDirectory; @@ -88,7 +88,7 @@ public class PluginWriter extends JFrame area.setOnCtrlS(this::save); area.setText(content); area.setCaretPosition(0); - area.setSyntaxEditingStyle(FileTypeUtil.get().guessContentType(new File(pluginName))); + SyntaxLanguage.setLanguage(area, pluginName); content = null; JButton run = new JButton("Run"); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/SyntaxLanguage.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/SyntaxLanguage.java index 60aab8dc..1206e9af 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/SyntaxLanguage.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/SyntaxLanguage.java @@ -1,6 +1,9 @@ package the.bytecode.club.bytecodeviewer.util; +import java.io.File; import java.util.function.BiFunction; +import org.fife.ui.rsyntaxtextarea.FileTypeUtil; +import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; import org.fife.ui.rsyntaxtextarea.SyntaxConstants; /*************************************************************************** @@ -23,11 +26,8 @@ import org.fife.ui.rsyntaxtextarea.SyntaxConstants; /** * @author ThexXTURBOXx - * @deprecated See {@link org.fife.ui.rsyntaxtextarea.FileTypeUtil#guessContentType(java.io.File)} */ -@Deprecated -public enum SyntaxLanguage -{ +public enum SyntaxLanguage { XML(SyntaxConstants.SYNTAX_STYLE_XML, (n, c) -> n.endsWith(".xml") || c.startsWith(" n.endsWith(".py") || n.endsWith(".python")), @@ -69,6 +69,8 @@ public enum SyntaxLanguage public static final SyntaxLanguage[] VALUES = values(); + private static final FileTypeUtil FILE_TYPE_UTIL = FileTypeUtil.get(); + private final BiFunction criteria; private final String syntaxConstant; @@ -86,6 +88,10 @@ public enum SyntaxLanguage return syntaxConstant; } + /** + * @deprecated See {@link #setLanguage(String, RSyntaxTextArea)}. + */ + @Deprecated public static SyntaxLanguage detectLanguage(String fileName, String content) { for (SyntaxLanguage lang : VALUES) { if (lang.isLanguage(fileName, content)) { @@ -94,4 +100,12 @@ public enum SyntaxLanguage } return NONE; } + + public static void setLanguage(RSyntaxTextArea area, String fileName) { + String type = FILE_TYPE_UTIL.guessContentType(new File(fileName)); + if (type == null || type.equals(SyntaxConstants.SYNTAX_STYLE_NONE)) { + type = FILE_TYPE_UTIL.guessContentType(area); + } + area.setSyntaxEditingStyle(type); + } } From c8c67b71b6fcbb9505a51120931d3413410a43b7 Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Tue, 4 Jan 2022 00:21:32 +0100 Subject: [PATCH 10/11] Fix JavaDoc --- .../the/bytecode/club/bytecodeviewer/util/SyntaxLanguage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/SyntaxLanguage.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/SyntaxLanguage.java index 1206e9af..5072d982 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/SyntaxLanguage.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/SyntaxLanguage.java @@ -89,7 +89,7 @@ public enum SyntaxLanguage { } /** - * @deprecated See {@link #setLanguage(String, RSyntaxTextArea)}. + * @deprecated See {@link #setLanguage(RSyntaxTextArea, String)}. */ @Deprecated public static SyntaxLanguage detectLanguage(String fileName, String content) { From 4f66739bec50179924e551a4287f71ecece7ff7b Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Wed, 5 Jan 2022 11:09:54 +0100 Subject: [PATCH 11/11] Update FernFlower --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 757aabca..2792599f 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ 0.3.4 5.2.1.Final v41 - 94d9422 + eda981d 2.8.9 31.0.1-jre 4.2