|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjef.dna.attributes.impl.GenericAttribute
jef.dna.attributes.impl.Code
public class Code
The Code class represents a Code Attribute as defined by the JVM Class file
Specification.
| Field Summary | |
|---|---|
protected static Logger |
logger
|
static int |
MAX_CODE_LENGTH_VALUE
|
| Fields inherited from class jef.dna.attributes.impl.GenericAttribute |
|---|
attribFactory, attributeNameIndex, dna, instrFactory, length |
| Constructor Summary | |
|---|---|
Code()
Constructor. |
|
| Method Summary | |
|---|---|
java.lang.Object |
clone()
The clone() method will return a new instance whose reference to the
containing Dna instance is set to null. |
void |
fromStream(java.io.DataInputStream dis,
Dna dna,
int nameIndex,
int length)
This method fills in the current Code instance reading all the required values
from the specified input stream. |
java.util.List<Instruction> |
generateObjectiveCode(int[] bytecode)
This method generates an object oriented representation of the bytecode contained within this method. |
int |
getAttributeCount()
Gets the number of attributes of the current Code attribute. |
java.util.List<Attribute> |
getAttributes()
Gets the set of attributes associated with the current Code attribute. |
int |
getBytesCount()
This method must return the overall number of bytes required by the component implementing this interface. |
int[] |
getCode()
This method gets this Code Attribute's bytecode, as an int array. |
int |
getCodeLength()
Gets the numeber of bytes making up this method's actual code. |
java.util.List<ExceptionTableEntry> |
getExceptionTable()
Gets the exception table. |
int |
getExceptionTableLength()
Gets the number of entries in stored within the Exceptio Table |
int |
getMaxLocals()
Gets the number of local variables allocated upon method invocation. |
int |
getMaxStack()
Gets the maximum depth of this method's operand stack during execution. |
java.util.List<Instruction> |
getObjectiveCode()
This method returns the object oriented representation of this method's code. |
protected void |
innerValidations(ConstantPoolTable cpt)
This method guarantees the validation process' workflow is executed correctly. |
void |
setCode(int[] code)
This method sets this Code Attribute's bytecode, as an int array. |
void |
setDna(Dna dna)
Set the Dna instance which will contain the current Attribute |
void |
setExceptionTable(java.util.List<ExceptionTableEntry> table)
Sets the exception table. |
void |
setMaxLocals(int maxLocals)
Sets the number of local variables allocated upon method invocation. |
void |
setMaxStack(int maxStack)
Sets the maximum depth of this method's operand stack during execution. |
void |
toStream(java.io.DataOutputStream dos)
This method flushes to the given ouput stream all the information related to this object. |
void |
updateRefs(int offset)
This method updates all the references that the current attribute holds to the constant pool table. |
void |
validateRefIntoCode(int ref)
This method verifies that the given reference is a valid reference to one of the bytecode instructions contained within this Code attribute. |
| Methods inherited from class jef.dna.attributes.impl.GenericAttribute |
|---|
getDna, getLength, getNameIndex, setNameIndex, validate, validateNameIndex |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface jef.dna.attributes.Attribute |
|---|
getDna, getLength, getNameIndex, setNameIndex, validate |
| Field Detail |
|---|
protected static Logger logger
public static final int MAX_CODE_LENGTH_VALUE
| Constructor Detail |
|---|
public Code()
fromStream method. Neverthless you can manipulate all this class'
attributes via the appropriate getters and setters.
| Method Detail |
|---|
public void setMaxStack(int maxStack)
setMaxStack in interface CodeAttributemaxStack - Stack maximum depthpublic int getMaxStack()
getMaxStack in interface CodeAttributepublic void setMaxLocals(int maxLocals)
setMaxLocals in interface CodeAttributemaxLocals - Number of allocated local variablespublic int getMaxLocals()
getMaxLocals in interface CodeAttributepublic int getCodeLength()
getCodeLength in interface CodeAttributepublic int getExceptionTableLength()
Exceptio Table
getExceptionTableLength in interface CodeAttributepublic void setExceptionTable(java.util.List<ExceptionTableEntry> table)
List containing
ExceptionTableEntry instances.
table - The Lsit of public java.util.List<ExceptionTableEntry> getExceptionTable()
List instance, containing
ExceptionTableEntry instances.
getExceptionTable in interface CodeAttributeList of public int getAttributeCount()
Code attribute.
getAttributeCount in interface CodeAttributepublic java.util.List<Attribute> getAttributes()
Code attribute. This
set is represented by a List holding instances of subclasses of the
GenericAttribute base class.
getAttributes in interface CodeAttributepublic java.util.List<Instruction> getObjectiveCode()
getObjectiveCode in interface CodeAttributegenerateObjectiveCode method.public void setCode(int[] code)
int array.
setCode in interface CodeAttributecode - The code as int arraypublic int[] getCode()
int array.
getCode in interface CodeAttributeint arraypublic java.util.List<Instruction> generateObjectiveCode(int[] bytecode)
generateObjectiveCode in interface CodeAttributebytecode - The method's bytecode
public void toStream(java.io.DataOutputStream dos)
throws DnaSerializationException
toStream in interface Attributedos - The ouput stream to write to
DnaSerializationException
public void fromStream(java.io.DataInputStream dis,
Dna dna,
int nameIndex,
int length)
throws DnaDeserializationException,
MissingDnaContainerException
Code instance reading all the required values
from the specified input stream.
fromStream in interface Attributedis - The input streamdna - A reference to the current Dna instanceattributeNameIndex - Index of the current attribute's name into the constant pool tablelength - The length of the attribute but the initial six bytes
DnaDeserializationException
MissingDnaContainerExceptionpublic void updateRefs(int offset)
updateRefs in interface AttributeupdateRefs in class GenericAttributeoffset - The offset to apply
public void validateRefIntoCode(int ref)
throws UnknownOpCodeException,
MissingDnaContainerException,
java.lang.IndexOutOfBoundsException
Code attribute.
validateRefIntoCode in interface CodeAttributeref - The reference to be verified
UnknownOpCodeException - One of the instructions of the current attribute is not recognized
MissingDnaContainerException - There is no reference to the Dna instance this attribute belongs
to
java.lang.IndexOutOfBoundsException - Error during processing
protected void innerValidations(ConstantPoolTable cpt)
throws AttributeValidationException,
AttributeOutOfRangeException,
MissingDnaContainerException,
MissingCPTableException
innerValidations in class GenericAttributecpt - The constant pool table
MissingCPTableException
MissingDnaContainerException
AttributeValidationException
AttributeOutOfRangeException
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone() method will return a new instance whose reference to the
containing Dna instance is set to null. It is up to you
appropriately setting it to the correct value.
clone in interface Attributeclone in class GenericAttributejava.lang.CloneNotSupportedExceptionpublic void setDna(Dna dna)
GenericAttributeDna instance which will contain the current Attribute
setDna in interface AttributesetDna in class GenericAttributedna - The "container" Dnapublic int getBytesCount()
BytesCountable
getBytesCount in interface BytesCountable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||