Improved Javap

This commit is contained in:
Konloch 2021-07-12 05:18:22 -07:00
parent f966f7b29f
commit 600b88e05e
3 changed files with 12 additions and 5 deletions

View file

@ -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()});

View file

@ -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));

View file

@ -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()