jreversepro.reflect
Class JClassInfo

java.lang.Object
  extended by jreversepro.reflect.JClassInfo
All Implemented Interfaces:
KeyWords

public class JClassInfo
extends java.lang.Object
implements KeyWords

JClassInfo is the abstract representation of the Class File. The names of the methods are self explanatory.

Author:
Karthik Kumar

Field Summary
static int ACC_INTERFACE
          ACC_INTERFACE bit required to be set if it is an interface and not a class.
static int ACC_SUPER
          ACC_SUPER bit required to be set on all modern classes.
 
Fields inherited from interface jreversepro.common.KeyWords
ANY, BOOLEAN, BREAK, BYTE, CASE, CHAR, CLASS, CLASS_STRING, CLINIT, CLOSE_BRACKET, COND_AND, COND_NOT, COND_OR, CONTINUE, DEFAULT, DEFAULT_PACKAGE, DOUBLE, EQUALTO, FALSE, FLOAT, FOREIGN_CLASS, FOREIGN_OBJ, GOTO, INIT, INSTANCEOF, INT, INTERFACE, JVM_BOOLEAN, JVM_CHAR, JVM_VOID, LANG_OBJECT, LENGTH, LONG, NEW, NULL, OPEN_BRACKET, OPR_EQ, OPR_GE, OPR_GT, OPR_LE, OPR_LT, OPR_NE, OPR_NOT, REFERENCE, RET_ADDR, RETURN, SHORT, SPACE, STATIC, SUPER, SWITCH, THIS, THISCLASS, THROW, TRUE, VOID
 
Constructor Summary
JClassInfo()
          Empty constructor
 
Method Summary
 void addField(JField rhsField)
          Adds a new field present in the class.
 void addInterface(java.lang.String interfaceName)
          Adds a new interface that is implemented by this class.
 void addMethod(JMethod rhsMethod)
          Adds a new method present in the class.
 java.lang.String getAccessString()
          Returns the access string of this class.
 JConstantPool getConstantPool()
          Returns the constantpool reference
 java.util.List<JField> getFields()
          Returns the fields present in the class.
 java.util.List<java.lang.String> getInterfaces()
          Returns the List of interfaces of the current class.
 int getMajor()
          Returns the major number of the JVM.
 java.util.List<JMethod> getMethods()
          Returns the methods of this class.
 int getMinor()
          Returns the minor number of the JVM.
 java.lang.String getPathName()
          Returns the path name of this class.
 java.lang.String getSourceFile()
          Returns the source file of the current class.
 java.lang.String getStringifiedClass(boolean getBytecode)
          Returns the stringified disassembled/decompiled class.
 java.lang.String getStringifiedClass(boolean getBytecode, boolean includeMetadata)
          Returns the stringified disassembled/decompiled class, optionally with metadata.
 java.lang.String getStringifiedMethods(boolean getBytecode, boolean includeMetadata)
          Returns the stringified disassembled/decompiled method.
 java.lang.String getSuperClass()
          Returns the class name of this class' super class.
 java.lang.String getThisClass()
          Returns the class name of this class.
 java.lang.String getThisClass(boolean fullyQualified)
           
 boolean isClass()
          Returns if this is a class or an interface
 void processMethods(boolean getBytecode)
          Process the methods.
 void reverseEngineer(boolean getBytecode)
          Reverse Engineer the Class file.
 void setAccess(int rhsAccess)
          Sets the access flag of the class.
 void setConstantPool(JConstantPool cpInfo)
          Sets the ConstantPool information of this class.
 void setMajorMinor(short rhsMajor, short rhsMinor)
          Sets the major and minor number of the JVM for which this class file is compiled for.
 void setPackageName(java.lang.String packageName)
          Sets the package to which this class belongs to.
 void setPathName(java.lang.String classPath)
          Sets the pathname of this class.
 void setSourceFile(java.lang.String rhsSrcFile)
          Sets the name of the source file to which this was contained in.
 void setSuperClass(java.lang.String rhsName)
          Sets the name of the current class' superclass.
 void setThisClass(java.lang.String rhsName)
          Sets the name of the current class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACC_SUPER

public static final int ACC_SUPER
ACC_SUPER bit required to be set on all modern classes.

See Also:
Constant Field Values

ACC_INTERFACE

public static final int ACC_INTERFACE
ACC_INTERFACE bit required to be set if it is an interface and not a class.

See Also:
Constant Field Values
Constructor Detail

JClassInfo

public JClassInfo()
Empty constructor

Method Detail

addInterface

public void addInterface(java.lang.String interfaceName)
Adds a new interface that is implemented by this class.

Parameters:
interfaceName - Name of the interface.

addField

public void addField(JField rhsField)
Adds a new field present in the class.

Parameters:
rhsField - contains the field-related information.

addMethod

public void addMethod(JMethod rhsMethod)
Adds a new method present in the class.

Parameters:
rhsMethod - contains the method-related information.

setPathName

public void setPathName(java.lang.String classPath)
Sets the pathname of this class.

Parameters:
classPath - Path to this class.

setConstantPool

public void setConstantPool(JConstantPool cpInfo)
Sets the ConstantPool information of this class.

Parameters:
cpInfo - contains the constant pool information of this class.

getConstantPool

public JConstantPool getConstantPool()
Returns the constantpool reference

Returns:
Returns the ConstantPool reference.

setMajorMinor

public void setMajorMinor(short rhsMajor,
                          short rhsMinor)
Sets the major and minor number of the JVM for which this class file is compiled for.

Parameters:
rhsMajor - Major number
rhsMinor - Minor number

setAccess

public void setAccess(int rhsAccess)
Sets the access flag of the class.

Parameters:
rhsAccess - Access flag of the class.

setThisClass

public void setThisClass(java.lang.String rhsName)
Sets the name of the current class.

Parameters:
rhsName - Name of this class.

setSuperClass

public void setSuperClass(java.lang.String rhsName)
Sets the name of the current class' superclass.

Parameters:
rhsName - Name of this class; superclass.

setPackageName

public void setPackageName(java.lang.String packageName)
Sets the package to which this class belongs to.

Parameters:
packageName - name of the package to be set.

setSourceFile

public void setSourceFile(java.lang.String rhsSrcFile)
Sets the name of the source file to which this was contained in.

Parameters:
rhsSrcFile - Name of the source file.

getPathName

public java.lang.String getPathName()
Returns the path name of this class.

Returns:
Absolute path of this class.

getMajor

public int getMajor()
Returns the major number of the JVM.

Returns:
JVM

getMinor

public int getMinor()
Returns the minor number of the JVM.

Returns:
JVM minor version

getThisClass

public java.lang.String getThisClass(boolean fullyQualified)
Parameters:
fullyQualified - Parameter to indicate if to return the fully qualified name. Yes - Fully qualified name along with the package name. No - Just the class name only.
Returns:
Returns Thisclass name only.

getThisClass

public java.lang.String getThisClass()
Returns the class name of this class.

Returns:
name of the current class.

getSuperClass

public java.lang.String getSuperClass()
Returns the class name of this class' super class.

Returns:
name of the current class' super-class.

getSourceFile

public java.lang.String getSourceFile()
Returns the source file of the current class.

Returns:
source file of the current class.

getInterfaces

public java.util.List<java.lang.String> getInterfaces()
Returns the List of interfaces of the current class.

Returns:
interfaces of the current class.

getFields

public java.util.List<JField> getFields()
Returns the fields present in the class.

Returns:
Returns a List of JField

getMethods

public java.util.List<JMethod> getMethods()
Returns the methods of this class.

Returns:
Returns a list of JMethods

getAccessString

public java.lang.String getAccessString()
Returns the access string of this class.

Returns:
Returns the access string of this class.

isClass

public boolean isClass()
Returns if this is a class or an interface

Returns:
Returns true if this is a class, false, if this is an interface.

processMethods

public void processMethods(boolean getBytecode)
Process the methods.

Parameters:
getBytecode - TRUE - disassemble. FALSE - disassemble.

getStringifiedClass

public java.lang.String getStringifiedClass(boolean getBytecode)
Returns the stringified disassembled/decompiled class.

Parameters:
getBytecode - If TRUE, returns the disassembled code IF the class has already been disassembled. If FALSE, returns the decompiled code IF the class has been decompiled. Otherwise, returns null;
Returns:
Stringified class

getStringifiedClass

public java.lang.String getStringifiedClass(boolean getBytecode,
                                            boolean includeMetadata)
Returns the stringified disassembled/decompiled class, optionally with metadata.

Parameters:
getBytecode - If TRUE, returns the disassembled code IF the class has already been disassembled. If FALSE, returns the decompiled code IF the class has been decompiled. Otherwise, returns null;
includeMetadata - - TRUE if method stack & exception data should be output.
Returns:
Stringified class

getStringifiedMethods

public java.lang.String getStringifiedMethods(boolean getBytecode,
                                              boolean includeMetadata)
Returns the stringified disassembled/decompiled method.

Parameters:
getBytecode - If TRUE, returns the disassembled code IF the method has already been disassembled. If FALSE, returns the decompiled code IF the method has been decompiled. Otherwise, returns null;
includeMetadata - - TRUE if method stack & exception data should be output
Returns:
Stringified methods in this class

reverseEngineer

public void reverseEngineer(boolean getBytecode)
                     throws ClassParserException,
                            RevEngineException
Reverse Engineer the Class file.

Parameters:
getBytecode - True disassembler, false - decompile.
Throws:
ClassParserException - Thrown if class file not in proper format.
RevEngineException - Thrown if error occured in reverse engineering file.


Submit Feedback to akkumar@users.sourceforge.net