Skip to content

Commit c8af835

Browse files
committed
Add warning for Javap disassembler and Java 16+
1 parent 756b3b3 commit c8af835

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/JavapDisassembler.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import the.bytecode.club.bytecodeviewer.decompilers.InternalDecompiler;
1313
import the.bytecode.club.bytecodeviewer.gui.components.JFrameConsolePrintStream;
1414
import the.bytecode.club.bytecodeviewer.resources.ExternalResources;
15+
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
1516
import the.bytecode.club.bytecodeviewer.util.MiscUtils;
1617

1718
import static the.bytecode.club.bytecodeviewer.Constants.fs;
@@ -75,7 +76,6 @@ private synchronized String synchronizedDecompilation(ClassNode cn, byte[] b)
7576
//setup reflection
7677
Class<?> javap = child.loadClass("com.sun.tools.javap.Main");
7778
Method main = javap.getMethod("main", String[].class);
78-
Object cl = javap.newInstance();
7979

8080
//pipe sys out
8181
sysOutBuffer = new JFrameConsolePrintStream("", false);
@@ -84,13 +84,17 @@ private synchronized String synchronizedDecompilation(ClassNode cn, byte[] b)
8484
BytecodeViewer.sm.silenceExec(true);
8585

8686
//invoke Javap
87-
main.invoke(cl, (Object) new String[]{
87+
main.invoke(null, (Object) new String[]{
8888
"-p", //Shows all classes and members
8989
"-c", //Prints out disassembled code
9090
//"-l", //Prints out line and local variable tables
9191
"-constants", //Shows static final constants
9292
tempClass.getAbsolutePath()});
9393
}
94+
catch (IllegalAccessException e)
95+
{
96+
return TranslatedStrings.ILLEGAL_ACCESS_ERROR.toString();
97+
}
9498
catch (Exception e)
9599
{
96100
e.printStackTrace();

0 commit comments

Comments
 (0)