From 600b88e05e9649133132f9c193807e4dc874c0a9 Mon Sep 17 00:00:00 2001 From: Konloch Date: Mon, 12 Jul 2021 05:18:22 -0700 Subject: [PATCH] Improved Javap --- .../decompilers/impl/JavapDisassembler.java | 5 +++-- .../gui/components/JFrameConsolePrintStream.java | 9 +++++++-- .../gui/components/JTextAreaOutputStream.java | 3 ++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/JavapDisassembler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/JavapDisassembler.java index 6df21bc6..7039cf8c 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/JavapDisassembler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/JavapDisassembler.java @@ -8,6 +8,7 @@ import org.objectweb.asm.util.TraceClassVisitor; import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.Constants; import the.bytecode.club.bytecodeviewer.decompilers.InternalDecompiler; +import the.bytecode.club.bytecodeviewer.gui.components.JFrameConsolePrintStream; import the.bytecode.club.bytecodeviewer.gui.components.SystemConsole; import the.bytecode.club.bytecodeviewer.resources.ExternalResources; import the.bytecode.club.bytecodeviewer.util.MiscUtils; @@ -64,7 +65,7 @@ public class JavapDisassembler extends InternalDecompiler DiskWriter.replaceFileBytes(tempClass.getAbsolutePath(), b, false); - SystemConsole sysOut = null; + JFrameConsolePrintStream sysOut = null; try { URLClassLoader child = new URLClassLoader( @@ -77,7 +78,7 @@ public class JavapDisassembler extends InternalDecompiler Object cl = javap.newInstance(); //pipe sys out - sysOut = new SystemConsole(""); + sysOut = new JFrameConsolePrintStream("", false); //invoke Javap main.invoke(cl, (Object) new String[]{"-c", "-l", "-constants", tempClass.getAbsolutePath()}); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/JFrameConsolePrintStream.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/JFrameConsolePrintStream.java index 99c67189..a7e02d2c 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/JFrameConsolePrintStream.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/JFrameConsolePrintStream.java @@ -40,11 +40,16 @@ public class JFrameConsolePrintStream extends JFrameConsole private long lastUpdate = 0; public JFrameConsolePrintStream(String title) + { + this(title, true); + } + + public JFrameConsolePrintStream(String title, boolean preserveOriginalOutput) { super(title); - textAreaOutputStreamOut = new JTextAreaOutputStream(getTextArea(), System.out); - textAreaOutputStreamErr = new JTextAreaOutputStream(getTextArea(), System.err); + textAreaOutputStreamOut = new JTextAreaOutputStream(getTextArea(), preserveOriginalOutput ? System.out : null); + textAreaOutputStreamErr = new JTextAreaOutputStream(getTextArea(), preserveOriginalOutput ? System.err : null); System.setOut(new PrintStream(textAreaOutputStreamOut)); System.setErr(new PrintStream(textAreaOutputStreamErr)); 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 4897b261..e65ab77f 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 @@ -53,7 +53,8 @@ public class JTextAreaOutputStream extends OutputStream public void write(int b) { sb.append((char) b); - og.write(b); + if(og != null) + og.write(b); } public StringBuilder getBuffer()