From 35613f01dac790c12d3cb94e2ae11a7e23f1b17e Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Thu, 16 Sep 2021 13:55:56 +0200 Subject: [PATCH] Remove deprecations for JDK 17 --- pom.xml | 1 + .../club/bytecodeviewer/GlobalHotKeys.java | 14 +++++++------- .../gui/components/ExtendedJOptionPane.java | 2 +- .../gui/components/SearchableJTextArea.java | 2 +- .../gui/components/SearchableRSyntaxTextArea.java | 4 ++-- .../gui/resourceviewer/TabbedPane.java | 2 +- .../plugin/preinstalled/EZInjection.java | 2 +- .../CompiledJavaPluginLaunchStrategy.java | 4 ++-- .../strategies/JavaPluginLaunchStrategy.java | 4 ++-- .../translation/TranslatedStrings.java | 1 + src/main/resources/translations/english.json | 1 + src/main/resources/translations/german.json | 3 ++- 12 files changed, 22 insertions(+), 18 deletions(-) diff --git a/pom.xml b/pom.xml index fa1ffab3..20a0d51d 100644 --- a/pom.xml +++ b/pom.xml @@ -365,6 +365,7 @@ ${java.version} ${java.version} + true diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/GlobalHotKeys.java b/src/main/java/the/bytecode/club/bytecodeviewer/GlobalHotKeys.java index 3bd050b2..d76d8852 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/GlobalHotKeys.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/GlobalHotKeys.java @@ -44,7 +44,7 @@ public class GlobalHotKeys //CTRL + O //open resource - if ((e.getKeyCode() == KeyEvent.VK_O) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) + if ((e.getKeyCode() == KeyEvent.VK_O) && ((e.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0)) { Configuration.lastHotKeyExecuted = System.currentTimeMillis(); @@ -62,7 +62,7 @@ public class GlobalHotKeys //CTRL + N //new workspace - else if ((e.getKeyCode() == KeyEvent.VK_N) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) + else if ((e.getKeyCode() == KeyEvent.VK_N) && ((e.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0)) { Configuration.lastHotKeyExecuted = System.currentTimeMillis(); BytecodeViewer.resetWorkspace(true); @@ -70,7 +70,7 @@ public class GlobalHotKeys //CTRL + T //compile - else if ((e.getKeyCode() == KeyEvent.VK_T) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) + else if ((e.getKeyCode() == KeyEvent.VK_T) && ((e.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0)) { Configuration.lastHotKeyExecuted = System.currentTimeMillis(); Thread t = new Thread(() -> BytecodeViewer.compile(true, false), "Compile"); @@ -79,7 +79,7 @@ public class GlobalHotKeys //CTRL + R //Run remote code - else if ((e.getKeyCode() == KeyEvent.VK_R) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) + else if ((e.getKeyCode() == KeyEvent.VK_R) && ((e.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0)) { Configuration.lastHotKeyExecuted = System.currentTimeMillis(); @@ -91,7 +91,7 @@ public class GlobalHotKeys //CTRL + S //Export resources - else if ((e.getKeyCode() == KeyEvent.VK_S) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) + else if ((e.getKeyCode() == KeyEvent.VK_S) && ((e.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0)) { Configuration.lastHotKeyExecuted = System.currentTimeMillis(); @@ -137,7 +137,7 @@ public class GlobalHotKeys //CTRL + W //close active resource (currently opened tab) - else if ((e.getKeyCode() == KeyEvent.VK_W) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) + else if ((e.getKeyCode() == KeyEvent.VK_W) && ((e.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0)) { Configuration.lastHotKeyExecuted = System.currentTimeMillis(); @@ -147,7 +147,7 @@ public class GlobalHotKeys //CTRL + L //open last opened resource - else if ((e.getKeyCode() == KeyEvent.VK_L) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) + else if ((e.getKeyCode() == KeyEvent.VK_L) && ((e.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0)) { Configuration.lastHotKeyExecuted = System.currentTimeMillis(); 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 3b9b0dd5..c845b287 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 @@ -215,7 +215,7 @@ public class ExtendedJOptionPane else dialog.setLocationRelativeTo(BytecodeViewer.viewer); - dialog.show(); + dialog.setVisible(true); dialog.dispose(); return dialog; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/SearchableJTextArea.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/SearchableJTextArea.java index 586ab755..e26d042b 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/SearchableJTextArea.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/SearchableJTextArea.java @@ -82,7 +82,7 @@ public class SearchableJTextArea extends JTextArea addKeyListener(new PressKeyListener(keyEvent -> { - if ((keyEvent.getKeyCode() == KeyEvent.VK_F) && ((keyEvent.getModifiers() & KeyEvent.CTRL_MASK) != 0)) + if ((keyEvent.getKeyCode() == KeyEvent.VK_F) && ((keyEvent.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0)) searchInput.requestFocus(); GlobalHotKeys.keyPressed(keyEvent); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/SearchableRSyntaxTextArea.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/SearchableRSyntaxTextArea.java index c9c1aedc..ae88d89b 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/SearchableRSyntaxTextArea.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/SearchableRSyntaxTextArea.java @@ -108,10 +108,10 @@ public class SearchableRSyntaxTextArea extends RSyntaxTextArea addKeyListener(new PressKeyListener(keyEvent -> { - if ((keyEvent.getKeyCode() == KeyEvent.VK_F) && ((keyEvent.getModifiers() & KeyEvent.CTRL_MASK) != 0)) + if ((keyEvent.getKeyCode() == KeyEvent.VK_F) && ((keyEvent.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0)) searchInput.requestFocus(); - if (onCtrlS != null && (keyEvent.getKeyCode() == KeyEvent.VK_S) && ((keyEvent.getModifiers() & KeyEvent.CTRL_MASK) != 0)) + if (onCtrlS != null && (keyEvent.getKeyCode() == KeyEvent.VK_S) && ((keyEvent.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0)) { onCtrlS.run(); return; 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 d205aa7f..52171c52 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 @@ -101,7 +101,7 @@ public class TabbedPane extends JPanel exitButton.setComponentPopupMenu(rightClickMenu); exitButton.addMouseListener(new MouseClickedListener(e -> { - if (e.getModifiers() != InputEvent.ALT_MASK || System.currentTimeMillis() - lastMouseClick < 100) + if (e.getModifiersEx() != InputEvent.ALT_DOWN_MASK || System.currentTimeMillis() - lastMouseClick < 100) return; lastMouseClick = System.currentTimeMillis(); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/EZInjection.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/EZInjection.java index 9b8bce85..e7699572 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/EZInjection.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/EZInjection.java @@ -299,7 +299,7 @@ public class EZInjection extends Plugin if(kit != null) kit.setVisible(true); - m2.invoke(classNode.getClass().newInstance(), (Object[]) new String[1]); + m2.invoke(classNode.getClass().getDeclaredConstructor().newInstance(), (Object[]) new String[1]); print("Finished running " + invokeMethodInformation); } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/strategies/CompiledJavaPluginLaunchStrategy.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/strategies/CompiledJavaPluginLaunchStrategy.java index 7290ec92..110f76b5 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/strategies/CompiledJavaPluginLaunchStrategy.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/strategies/CompiledJavaPluginLaunchStrategy.java @@ -61,7 +61,7 @@ public class CompiledJavaPluginLaunchStrategy implements PluginLaunchStrategy { } LoadingClassLoader cl = new LoadingClassLoader(pdata, set); - Plugin p = cl.pluginKlass.newInstance(); + Plugin p = cl.pluginKlass.getDeclaredConstructor().newInstance(); LoadedPluginData npdata = new LoadedPluginData(pdata, cl, p); loaded.add(npdata); @@ -197,4 +197,4 @@ public class CompiledJavaPluginLaunchStrategy implements PluginLaunchStrategy { return pluginKlass; } } -} \ No newline at end of file +} diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/strategies/JavaPluginLaunchStrategy.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/strategies/JavaPluginLaunchStrategy.java index 17bf4009..a3db6b8a 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/strategies/JavaPluginLaunchStrategy.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/strategies/JavaPluginLaunchStrategy.java @@ -51,6 +51,6 @@ public class JavaPluginLaunchStrategy implements PluginLaunchStrategy ); //create a new instance of the class - return (Plugin) clazz.newInstance(); + return (Plugin) clazz.getDeclaredConstructor().newInstance(); } -} \ No newline at end of file +} diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/translation/TranslatedStrings.java b/src/main/java/the/bytecode/club/bytecodeviewer/translation/TranslatedStrings.java index 52a4ad1e..f056dea0 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/translation/TranslatedStrings.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/translation/TranslatedStrings.java @@ -84,6 +84,7 @@ public enum TranslatedStrings PLEASE_SEND_THIS_ERROR_LOG_TO, PLEASE_SEND_RESOURCES, ONE_PLUGIN_AT_A_TIME, + ILLEGAL_ACCESS_ERROR, YES, diff --git a/src/main/resources/translations/english.json b/src/main/resources/translations/english.json index cf7aa961..64c5f1b3 100644 --- a/src/main/resources/translations/english.json +++ b/src/main/resources/translations/english.json @@ -263,6 +263,7 @@ "PLEASE_SEND_THIS_ERROR_LOG_TO": "Please send this error log to", "PLEASE_SEND_RESOURCES": "If you hold appropriate legal rights to the relevant class/jar/apk file please include that as well.", "ONE_PLUGIN_AT_A_TIME": "There is currently another plugin running right now, please wait for that to finish executing.", + "ILLEGAL_ACCESS_ERROR": "Please use Java 15 or older to do this.", "FILES": "Files", diff --git a/src/main/resources/translations/german.json b/src/main/resources/translations/german.json index 9f40eb6b..9df1caeb 100644 --- a/src/main/resources/translations/german.json +++ b/src/main/resources/translations/german.json @@ -255,5 +255,6 @@ "CLOSE_TAB": "Tab schließen", "PLEASE_SEND_THIS_ERROR_LOG_TO": "Bitte senden Sie dieses Fehlerprotokoll an", "PLEASE_SEND_RESOURCES": "Wenn Sie entsprechende gesetzliche Rechte an der jeweiligen Klasse besitzen", - "MIN_SDK_VERSION": "Minimale SDK-Version" + "MIN_SDK_VERSION": "Minimale SDK-Version", + "ILLEGAL_ACCESS_ERROR": "Bitte benutzen Sie Java 15 oder älter, um dies zu tun." }