|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectclassUtils.javassist.bytecode.JAClassFile
public final class JAClassFile
ClassFile
represents a Java .class
file,
which consists of a constant pool, methods, fields, and attributes.
CompileTimeClass.getClassFile()
Constructor Summary | |
---|---|
JAClassFile(boolean isInterface,
java.lang.String classname,
java.lang.String superclass)
Constructs a class file including no members. |
|
JAClassFile(java.io.DataInputStream in)
Constructs a class file from a byte stream. |
Method Summary | |
---|---|
void |
addAttribute(AttributeInfo info)
Appends an attribute. |
void |
addField(FieldInfo finfo)
Appends a field to the class. |
void |
addInterface(java.lang.String name)
Appends an interface to the interfaces implemented by the class. |
void |
addMethod(MethodInfo minfo)
Appends a method to the class. |
int |
getAccessFlags()
Returns access flags. |
AttributeInfo |
getAttribute(java.lang.String name)
Returns the attribute with the specified name. |
java.util.List |
getAttributes()
Returns all the attributes. |
ConstPool |
getConstPool()
Returns a constant pool table. |
java.util.List |
getFields()
Returns all the fields declared in the class. |
java.lang.String[] |
getInterfaces()
Returns the names of the interfaces implemented by the class. |
MethodInfo |
getMethod(java.lang.String name)
Returns the method with the specified name. |
java.util.List |
getMethods()
Returns all the methods declared in the class. |
java.lang.String |
getName()
Returns the class name. |
java.lang.String |
getSourceFile()
Returns the source file containing this class. |
MethodInfo |
getStaticInitializer()
Returns a static initializer (class initializer), or null if it does not exist. |
java.lang.String |
getSuperclass()
Returns the super class name. |
int |
getSuperclassId()
Returns the index of the constant pool entry representing the super class. |
boolean |
isAbstract()
Returns true if this is an abstract class or an interface. |
boolean |
isFinal()
Returns true if this is a final class or interface. |
boolean |
isInterface()
Returns true if this is an interface. |
void |
renameClass(java.util.Map classnames)
Replaces all occurrences of several class names in the class file. |
void |
renameClass(java.lang.String oldname,
java.lang.String newname)
Replaces all occurrences of a class name in the class file. |
void |
setAccessFlags(int acc)
Changes access flags. |
void |
setInterfaces(java.lang.String[] nameList)
Sets the interfaces. |
void |
setName(java.lang.String name)
Sets the class name. |
void |
setSuperclass(java.lang.String superclass)
Sets the super class. |
void |
write(java.io.DataOutputStream out)
Writes a class file represened by this object into an output stream. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JAClassFile(java.io.DataInputStream in) throws java.io.IOException
java.io.IOException
public JAClassFile(boolean isInterface, java.lang.String classname, java.lang.String superclass)
isInterface
- true if this is an interface.
false if this is a class.classname
- a fully-qualified class namesuperclass
- a fully-qualified super class nameMethod Detail |
---|
public ConstPool getConstPool()
public boolean isInterface()
public boolean isFinal()
public boolean isAbstract()
public int getAccessFlags()
AccessFlag
public void setAccessFlags(int acc)
AccessFlag
public java.lang.String getName()
public void setName(java.lang.String name)
public java.lang.String getSuperclass()
public int getSuperclassId()
public void setSuperclass(java.lang.String superclass) throws CannotCompileException
This method modifies constructors so that they call constructors declared in the new super class.
CannotCompileException
public final void renameClass(java.lang.String oldname, java.lang.String newname)
If class X is substituted for class Y in the class file, X and Y must have the same signature. If Y provides a method m(), X must provide it even if X inherits m() from the super class. If this fact is not guaranteed, the bytecode verifier may cause an error.
oldname
- the replaced class namenewname
- the substituted class namepublic final void renameClass(java.util.Map classnames)
classnames
- specifies which class name is replaced
with which new name. Class names must
be described with the JVM-internal
representation like
java/lang/Object
.renameClass(String,String)
public java.lang.String[] getInterfaces()
public void setInterfaces(java.lang.String[] nameList)
nameList
- the names of the interfaces.public void addInterface(java.lang.String name)
public java.util.List getFields()
FieldInfo
.FieldInfo
public void addField(FieldInfo finfo)
public java.util.List getMethods()
MethodInfo
.MethodInfo
public MethodInfo getMethod(java.lang.String name)
public MethodInfo getStaticInitializer()
public void addMethod(MethodInfo minfo)
public java.util.List getAttributes()
AttributeInfo
objects.AttributeInfo
public AttributeInfo getAttribute(java.lang.String name)
name
- attribute namepublic void addAttribute(AttributeInfo info)
public java.lang.String getSourceFile()
public void write(java.io.DataOutputStream out) throws java.io.IOException
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |