com.claritysys.jvm.disassembler
Class Disassembler

java.lang.Object
  extended by com.claritysys.jvm.disassembler.Disassembler
All Implemented Interfaces:
Signature.TypeFormatter

public class Disassembler
extends java.lang.Object
implements Signature.TypeFormatter

JASM Java Bytecode Disassembler Stuff To Do - Proper conversion of WIDE args - Exceptions need better labels/block marking. - Inner classes? - Branch target smart labels -- what condition made it jump to the branch target. Locals analysis, especially for automatic locals: e.g., a local used in a ret is storing the caller's PC. PERFORMANCE IMPROVEMENTS For typical runs verify the HashMap sizes (aliasToFull/fullToAlias) to ensure good hashing. ENHANCEMENTS One of my original desires was to provide a disassembly listing, including the hex dump of the bytecode on each line, interspersed with the original Java source code, or at least the comments from the original source code. The code segments have line number information which can tie back to the original source file, but I am as much interested in the original JavaDoc comments (more so). I have considered several formats, such as showing the original source code to the right (truncated) in single line comments, with comments appearing inline. Or printing the original code with no extra indent, then the bytecode it generated, then the source, etc. When interspersing the original source we should turn off local variable declaration since they will be shown in the source.


Constructor Summary
Disassembler(ClassFile cf, java.lang.String toFileName)
          Create a new Disassembler for given class.
Disassembler(ClassFile cf, java.io.Writer writer)
           
 
Method Summary
 void disassemble()
          Do the disassembly.
 java.lang.String getFormattedType(java.lang.String type)
          TypeFormatter.getFormattedType
 boolean isThisClass(java.lang.String alias)
           
static void main(java.lang.String[] args)
          Disassemble from command line filename to out.jasm.
 void setClassFile(ClassFile cf)
          Set the class.
 void setOutput(java.io.Writer writer)
          Set the writer to write to.
 void setOutputFile(java.lang.String path)
          Set the file to write to.
 void visitField(CfField obj)
          FIELD modifiers type name (= static value)?
 void visitJavaClass(ClassFile obj)
          CLASS package? import* [modifiers] (class | interface) (extends)? (implements)?
 void visitMethod(CfMethod obj)
          METHOD modifiers type name (params) throws? { code }
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Disassembler

public Disassembler(ClassFile cf,
                    java.lang.String toFileName)
Create a new Disassembler for given class.


Disassembler

public Disassembler(ClassFile cf,
                    java.io.Writer writer)
Method Detail

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException,
                        ClassFileFormatException
Disassemble from command line filename to out.jasm.

Throws:
java.io.IOException
ClassFileFormatException

isThisClass

public boolean isThisClass(java.lang.String alias)

disassemble

public void disassemble()
Do the disassembly.


setClassFile

public void setClassFile(ClassFile cf)
Set the class.


setOutputFile

public void setOutputFile(java.lang.String path)
Set the file to write to.

This opens the file in overwrite mode and creates the PrintWriter.


setOutput

public void setOutput(java.io.Writer writer)
Set the writer to write to.

Parameters:
writer -

getFormattedType

public java.lang.String getFormattedType(java.lang.String type)
TypeFormatter.getFormattedType

Called by the sig parser to let us format Object types.

Specified by:
getFormattedType in interface Signature.TypeFormatter

visitJavaClass

public void visitJavaClass(ClassFile obj)
CLASS package? import* [modifiers] (class | interface) (extends)? (implements)?


visitField

public void visitField(CfField obj)
FIELD modifiers type name (= static value)?


visitMethod

public void visitMethod(CfMethod obj)
METHOD modifiers type name (params) throws? { code }



Copyright ? 2000-2003 Clarity Systems Group, LLC. All Rights Reserved.