|
Jode 1.90-CVS Build Aug 6, 2004 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.jode.bytecode.BinaryInfo
Represents a container for user specified attributes.
Java bytecode is extensible: Classes, Methods and Fields may have any number of attributes. Every attribute has a name and some unformatted data.
There are some predefined attributes, even the Code of a Method is an attribute. These predefined attributes are all handled by this package as appropriate. These methods are only useful for non standard attributes.
You can provide new attributes by overriding the protected methods of this class. This makes it possible to use constant pool entries in the attributes.
Another possibility is to add the attributes with the public method. This way you don't need to extend the classes, but you can't use a constant pool for the contents of the attributes. One possible application of this are installation classes. These classes have a special attribute containing a zip archive of the files that should be installed. There are other possible uses, e.g. putting native machine code for some architectures into the class.
Field Summary | |
static int |
ACC_ABSTRACT
The bit mask representing abstract modifier. |
static int |
ACC_ANNOTATION
The bit mask representing annotation classes. |
static int |
ACC_BRIDGE
The bit mask representing synthetic bridge method. |
static int |
ACC_ENUM
The bit mask representing enum fields. |
static int |
ACC_FINAL
The bit mask representing final modifier. |
static int |
ACC_INTERFACE
The bit mask representing interfaces. |
static int |
ACC_NATIVE
The bit mask representing native methods. |
static int |
ACC_PRIVATE
The bit mask representing private modifier. |
static int |
ACC_PROTECTED
The bit mask representing protected modifier. |
static int |
ACC_PUBLIC
The bit mask representing public modifier. |
static int |
ACC_STATIC
The bit mask representing static modifier. |
static int |
ACC_STRICT
The bit mask representing strictfp modifier. |
static int |
ACC_SUPER
The bit mask representing the ACC_SUPER modifier for classes. |
static int |
ACC_SYNTHETIC
The bit mask representing synthetic fields/methods and classes. |
static int |
ACC_TRANSIENT
The bit mask representing transient fields. |
static int |
ACC_VARARGS
The bit mask representing varargs methods. |
static int |
ACC_VOLATILE
The bit mask representing volatile modifier for fields. |
Constructor Summary | |
BinaryInfo()
|
Method Summary | |
void |
addAttribute(java.lang.String name,
byte[] contents)
Adds a new non standard attribute or replaces an old one with the same name. |
protected void |
drop(int keep)
Drops information from this info. |
byte[] |
findAttribute(java.lang.String name)
Finds a non standard attribute with the given name. |
protected int |
getAttributeCount()
Returns the number of attributes of this class. |
java.util.Iterator |
getAttributes()
Gets all non standard attributes. |
protected int |
getAttributeSize()
Gets the total length of all attributes in this binary info. |
protected void |
prepareAttributes(GrowableConstantPool gcp)
Prepare writing your attributes. |
protected void |
readAttribute(java.lang.String name,
int length,
ConstantPool constantPool,
java.io.DataInputStream input,
int howMuch)
Reads in an attributes of this class. |
void |
removeAllAttributes()
Removes all non standard attributes. |
byte[] |
removeAttribute(java.lang.String name)
Removes a non standard attributes. |
protected void |
writeAttributes(GrowableConstantPool constantPool,
java.io.DataOutputStream output)
Writes the attributes to the output stream. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static int ACC_PUBLIC
public static int ACC_PRIVATE
public static int ACC_PROTECTED
public static int ACC_STATIC
public static int ACC_FINAL
public static int ACC_SUPER
public static int ACC_VOLATILE
public static int ACC_BRIDGE
public static int ACC_TRANSIENT
public static int ACC_VARARGS
public static int ACC_ENUM
public static int ACC_NATIVE
public static int ACC_INTERFACE
public static int ACC_ABSTRACT
public static int ACC_ANNOTATION
public static int ACC_STRICT
public static int ACC_SYNTHETIC
Constructor Detail |
public BinaryInfo()
Method Detail |
protected void readAttribute(java.lang.String name, int length, ConstantPool constantPool, java.io.DataInputStream input, int howMuch) throws java.io.IOException
name
- the attribute name.length
- the length of the attribute.constantPool
- the constant pool of the class.input
- a data input stream where you can read the attribute
from. It will protect you to read more over the attribute boundary.howMuch
- the constant that was given to the ClassInfo.load(int)
function when loading this class.
java.io.IOException
protected void drop(int keep)
keep
- the constant representing how much information we
should keep (see ClassInfo.load(int)
).protected int getAttributeCount()
protected void prepareAttributes(GrowableConstantPool gcp)
gcp
- The growable constant pool.protected void writeAttributes(GrowableConstantPool constantPool, java.io.DataOutputStream output) throws java.io.IOException
Writes the attributes to the output stream.
Overwrite this method if you want to add your own attributes.
All constants you need from the growable constant pool must
have been previously registered by the prepareAttributes(net.sf.jode.bytecode.GrowableConstantPool)
method. This method must not add new constants to the pool
constantPool
- The growable constant pool, which is not
growable anymore (see above).output
- the data output stream. You must write exactly
as many bytes to it as you have told with the getAttributeSize()
method.
java.io.IOException
protected int getAttributeSize()
public byte[] findAttribute(java.lang.String name)
name
- the name of the attribute.
readAttribute(java.lang.String, int, net.sf.jode.bytecode.ConstantPool, java.io.DataInputStream, int)
public java.util.Iterator getAttributes()
findAttribute(java.lang.String)
public void addAttribute(java.lang.String name, byte[] contents)
getAttributeCount()
, prepareAttributes(net.sf.jode.bytecode.GrowableConstantPool)
, writeAttributes(net.sf.jode.bytecode.GrowableConstantPool, java.io.DataOutputStream)
, and getAttributeSize()
.
name
- the name of the attribute.contents
- the new contens.public byte[] removeAttribute(java.lang.String name)
name
- the name of the attribute.
public void removeAllAttributes()
|
Jode 1.90-CVS Build Aug 6, 2004 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |