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.Configuration;
import the.bytecode.club.bytecodeviewer.Constants; import the.bytecode.club.bytecodeviewer.Constants;
import the.bytecode.club.bytecodeviewer.decompilers.InternalDecompiler; 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.gui.components.SystemConsole;
import the.bytecode.club.bytecodeviewer.resources.ExternalResources; import the.bytecode.club.bytecodeviewer.resources.ExternalResources;
import the.bytecode.club.bytecodeviewer.util.MiscUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils;
@ -64,7 +65,7 @@ public class JavapDisassembler extends InternalDecompiler
DiskWriter.replaceFileBytes(tempClass.getAbsolutePath(), b, false); DiskWriter.replaceFileBytes(tempClass.getAbsolutePath(), b, false);
SystemConsole sysOut = null; JFrameConsolePrintStream sysOut = null;
try try
{ {
URLClassLoader child = new URLClassLoader( URLClassLoader child = new URLClassLoader(
@ -77,7 +78,7 @@ public class JavapDisassembler extends InternalDecompiler
Object cl = javap.newInstance(); Object cl = javap.newInstance();
//pipe sys out //pipe sys out
sysOut = new SystemConsole(""); sysOut = new JFrameConsolePrintStream("", false);
//invoke Javap //invoke Javap
main.invoke(cl, (Object) new String[]{"-c", "-l", "-constants", tempClass.getAbsolutePath()}); 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; private long lastUpdate = 0;
public JFrameConsolePrintStream(String title) public JFrameConsolePrintStream(String title)
{
this(title, true);
}
public JFrameConsolePrintStream(String title, boolean preserveOriginalOutput)
{ {
super(title); super(title);
textAreaOutputStreamOut = new JTextAreaOutputStream(getTextArea(), System.out); textAreaOutputStreamOut = new JTextAreaOutputStream(getTextArea(), preserveOriginalOutput ? System.out : null);
textAreaOutputStreamErr = new JTextAreaOutputStream(getTextArea(), System.err); textAreaOutputStreamErr = new JTextAreaOutputStream(getTextArea(), preserveOriginalOutput ? System.err : null);
System.setOut(new PrintStream(textAreaOutputStreamOut)); System.setOut(new PrintStream(textAreaOutputStreamOut));
System.setErr(new PrintStream(textAreaOutputStreamErr)); System.setErr(new PrintStream(textAreaOutputStreamErr));

View file

@ -53,6 +53,7 @@ public class JTextAreaOutputStream extends OutputStream
public void write(int b) public void write(int b)
{ {
sb.append((char) b); sb.append((char) b);
if(og != null)
og.write(b); og.write(b);
} }