|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.claritysys.jvm.classfile.Attribute
public class Attribute
An attribute list within a class, field, method, or code attribute.
Note that, in this implementation, each attribute in the classfile does not necessarily get read into an Attribute object: only the unrecognized ones do, so that a read classfile can be written again without loss of information. Recognized attributes are mapped to fields.
| Constructor Summary | |
|---|---|
Attribute(int nameIndex,
int length,
byte[] info)
Create a new attribute. |
|
| Method Summary | |
|---|---|
byte[] |
getInfo()
|
int |
getLength()
|
int |
getNameIndex()
|
Attribute |
getNext()
|
static int |
getTotalSize(Attribute attributes)
Compute the total size of the attributes, including the 6 bytes of tag/length for each, plus the sum of the lengths. |
static Attribute |
readTable(java.io.DataInputStream dataIn,
ConstantPool cpool,
AttributeHandler handler)
Read attribute table from stream, returning a (possibly null) linked list of Attribute objects. |
void |
setInfo(byte[] info)
|
void |
setLength(int length)
|
void |
setNameIndex(int nameIndex)
|
void |
setNext(Attribute next)
|
static void |
writeAttribute(java.io.DataOutput dout,
ConstantPool cp,
java.lang.String name,
int length)
Write an attribute, given its name, length, etc. |
static void |
writeAttribute(java.io.DataOutput dataOut,
ConstantPool cp,
java.lang.String name,
int length,
int data)
Write an attribute, given its name, length, etc. |
static void |
writeTable(java.io.DataOutput dataOut,
Attribute head)
Write the attribute table to the stream, or nothing if the attribute is null. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Attribute(int nameIndex,
int length,
byte[] info)
nameIndex - CpUtf8 index referencing name of attribute, such as
"SourceFile" or "Code", etc.length - length in bytes of the info[].info - optional array of data relating to attribute.| Method Detail |
|---|
public Attribute getNext()
public void setNext(Attribute next)
public int getNameIndex()
public void setNameIndex(int nameIndex)
public int getLength()
public void setLength(int length)
public byte[] getInfo()
public void setInfo(byte[] info)
public static Attribute readTable(java.io.DataInputStream dataIn,
ConstantPool cpool,
AttributeHandler handler)
throws java.io.IOException,
ClassFileFormatException
The caller can pass an AttributeHandler, which will be
called to process each attribute as it is read from the stream.
Unhandled attributes will be created as Attribute objects.
dataIn - the input stream.cpool - the Constant pool to use to resolve attribute names.handler - An optional handler to delegate attribute processing
to.
java.io.IOException - If an I/O error occurs with the stream.
ClassFileFormatException - If malformed class data is
encountered.
public static void writeTable(java.io.DataOutput dataOut,
Attribute head)
throws java.io.IOException
java.io.IOException
public static void writeAttribute(java.io.DataOutput dataOut,
ConstantPool cp,
java.lang.String name,
int length,
int data)
throws java.io.IOException
java.io.IOException
public static void writeAttribute(java.io.DataOutput dout,
ConstantPool cp,
java.lang.String name,
int length)
throws java.io.IOException
java.io.IOExceptionpublic static int getTotalSize(Attribute attributes)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||