|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.bcel.classfile.AccessFlags
org.apache.bcel.classfile.JavaClass
public class JavaClass
Represents a Java class, i.e., the data structures, constant pool, fields, methods and commands contained in a Java .class file. See JVM specification for details. The intent of this class is to represent a parsed or otherwise existing class file. Those interested in programatically generating classes should see the ClassGen class.
ClassGen
,
Serialized FormField Summary | |
---|---|
private static BCELComparator |
_cmp
|
private Attribute[] |
attributes
|
private java.lang.String |
class_name
|
private int |
class_name_index
|
private ConstantPool |
constant_pool
|
(package private) static boolean |
debug
|
private Field[] |
fields
|
static byte |
FILE
|
private java.lang.String |
file_name
|
static byte |
HEAP
|
private java.lang.String[] |
interface_names
|
private int[] |
interfaces
|
private int |
major
|
private Method[] |
methods
|
private int |
minor
|
private java.lang.String |
package_name
|
private Repository |
repository
In cases where we go ahead and create something, use the default SyntheticRepository, because we don't know any better. |
(package private) static char |
sep
|
private byte |
source
|
private java.lang.String |
source_file_name
|
private java.lang.String |
superclass_name
|
private int |
superclass_name_index
|
static byte |
ZIP
|
Fields inherited from class org.apache.bcel.classfile.AccessFlags |
---|
access_flags |
Constructor Summary | |
---|---|
JavaClass(int class_name_index,
int superclass_name_index,
java.lang.String file_name,
int major,
int minor,
int access_flags,
ConstantPool constant_pool,
int[] interfaces,
Field[] fields,
Method[] methods,
Attribute[] attributes)
Constructor gets all contents as arguments. |
|
JavaClass(int class_name_index,
int superclass_name_index,
java.lang.String file_name,
int major,
int minor,
int access_flags,
ConstantPool constant_pool,
int[] interfaces,
Field[] fields,
Method[] methods,
Attribute[] attributes,
byte source)
Constructor gets all contents as arguments. |
Method Summary | |
---|---|
void |
accept(Visitor v)
Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class. |
int |
compareTo(java.lang.Object obj)
Return the natural ordering of two JavaClasses. |
JavaClass |
copy()
|
(package private) static void |
Debug(java.lang.String str)
|
void |
dump(java.io.DataOutputStream file)
Dump Java class to output stream in binary format. |
void |
dump(java.io.File file)
Dump class to a file. |
void |
dump(java.io.OutputStream file)
Dump Java class to output stream in binary format. |
void |
dump(java.lang.String _file_name)
Dump class to a file named file_name. |
boolean |
equals(java.lang.Object obj)
Return value as defined by given BCELComparator strategy. |
JavaClass[] |
getAllInterfaces()
Get all interfaces implemented by this JavaClass (transitively). |
Attribute[] |
getAttributes()
|
byte[] |
getBytes()
|
java.lang.String |
getClassName()
|
int |
getClassNameIndex()
|
static BCELComparator |
getComparator()
|
ConstantPool |
getConstantPool()
|
Field[] |
getFields()
|
java.lang.String |
getFileName()
|
int[] |
getInterfaceIndices()
|
java.lang.String[] |
getInterfaceNames()
|
JavaClass[] |
getInterfaces()
Get interfaces directly implemented by this JavaClass. |
int |
getMajor()
|
Method |
getMethod(java.lang.reflect.Method m)
|
Method[] |
getMethods()
|
int |
getMinor()
|
java.lang.String |
getPackageName()
|
Repository |
getRepository()
Gets the ClassRepository which holds its definition. |
byte |
getSource()
|
java.lang.String |
getSourceFileName()
|
JavaClass |
getSuperClass()
|
JavaClass[] |
getSuperClasses()
|
java.lang.String |
getSuperclassName()
|
int |
getSuperclassNameIndex()
|
int |
hashCode()
Return value as defined by given BCELComparator strategy. |
boolean |
implementationOf(JavaClass inter)
|
private static java.lang.String |
indent(java.lang.Object obj)
|
boolean |
instanceOf(JavaClass super_class)
Equivalent to runtime "instanceof" operator. |
boolean |
isClass()
|
boolean |
isSuper()
|
void |
setAttributes(Attribute[] attributes)
|
void |
setClassName(java.lang.String class_name)
|
void |
setClassNameIndex(int class_name_index)
|
static void |
setComparator(BCELComparator comparator)
|
void |
setConstantPool(ConstantPool constant_pool)
|
void |
setFields(Field[] fields)
|
void |
setFileName(java.lang.String file_name)
Set File name of class, aka SourceFile attribute value |
void |
setInterfaceNames(java.lang.String[] interface_names)
|
void |
setInterfaces(int[] interfaces)
|
void |
setMajor(int major)
|
void |
setMethods(Method[] methods)
|
void |
setMinor(int minor)
|
void |
setRepository(Repository repository)
Sets the ClassRepository which loaded the JavaClass. |
void |
setSourceFileName(java.lang.String source_file_name)
Set absolute path to file this class was read from. |
void |
setSuperclassName(java.lang.String superclass_name)
|
void |
setSuperclassNameIndex(int superclass_name_index)
|
java.lang.String |
toString()
|
Methods inherited from class org.apache.bcel.classfile.AccessFlags |
---|
getAccessFlags, getModifiers, isAbstract, isAbstract, isAnnotation, isAnnotation, isEnum, isEnum, isFinal, isFinal, isInterface, isInterface, isNative, isNative, isPrivate, isPrivate, isProtected, isProtected, isPublic, isPublic, isStatic, isStatic, isStrictfp, isStrictfp, isSynchronized, isSynchronized, isSynthetic, isSynthetic, isTransient, isTransient, isVolatile, isVolatile, setAccessFlags, setModifiers |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private java.lang.String file_name
private java.lang.String package_name
private java.lang.String source_file_name
private int class_name_index
private int superclass_name_index
private java.lang.String class_name
private java.lang.String superclass_name
private int major
private int minor
private ConstantPool constant_pool
private int[] interfaces
private java.lang.String[] interface_names
private Field[] fields
private Method[] methods
private Attribute[] attributes
private byte source
public static final byte HEAP
public static final byte FILE
public static final byte ZIP
static boolean debug
static char sep
private static BCELComparator _cmp
private transient Repository repository
Constructor Detail |
---|
public JavaClass(int class_name_index, int superclass_name_index, java.lang.String file_name, int major, int minor, int access_flags, ConstantPool constant_pool, int[] interfaces, Field[] fields, Method[] methods, Attribute[] attributes, byte source)
class_name_index
- Index into constant pool referencing a
ConstantClass that represents this class.superclass_name_index
- Index into constant pool referencing a
ConstantClass that represents this class's superclass.file_name
- File namemajor
- Major compiler versionminor
- Minor compiler versionaccess_flags
- Access rights defined by bit flagsconstant_pool
- Array of constantsinterfaces
- Implemented interfacesfields
- Class fieldsmethods
- Class methodsattributes
- Class attributessource
- Read from file or generated in memory?public JavaClass(int class_name_index, int superclass_name_index, java.lang.String file_name, int major, int minor, int access_flags, ConstantPool constant_pool, int[] interfaces, Field[] fields, Method[] methods, Attribute[] attributes)
class_name_index
- Class namesuperclass_name_index
- Superclass namefile_name
- File namemajor
- Major compiler versionminor
- Minor compiler versionaccess_flags
- Access rights defined by bit flagsconstant_pool
- Array of constantsinterfaces
- Implemented interfacesfields
- Class fieldsmethods
- Class methodsattributes
- Class attributesMethod Detail |
---|
public void accept(Visitor v)
accept
in interface Node
v
- Visitor objectstatic final void Debug(java.lang.String str)
public void dump(java.io.File file) throws java.io.IOException
file
- Output file
java.io.IOException
public void dump(java.lang.String _file_name) throws java.io.IOException
_file_name
- Output file name
java.io.IOException
public byte[] getBytes()
public void dump(java.io.OutputStream file) throws java.io.IOException
file
- Output stream
java.io.IOException
public void dump(java.io.DataOutputStream file) throws java.io.IOException
file
- Output stream
java.io.IOException
public Attribute[] getAttributes()
public java.lang.String getClassName()
public java.lang.String getPackageName()
public int getClassNameIndex()
public ConstantPool getConstantPool()
public Field[] getFields()
public java.lang.String getFileName()
public java.lang.String[] getInterfaceNames()
public int[] getInterfaceIndices()
public int getMajor()
public Method[] getMethods()
public Method getMethod(java.lang.reflect.Method m)
public int getMinor()
public java.lang.String getSourceFileName()
public java.lang.String getSuperclassName()
public int getSuperclassNameIndex()
public void setAttributes(Attribute[] attributes)
attributes
- .public void setClassName(java.lang.String class_name)
class_name
- .public void setClassNameIndex(int class_name_index)
class_name_index
- .public void setConstantPool(ConstantPool constant_pool)
constant_pool
- .public void setFields(Field[] fields)
fields
- .public void setFileName(java.lang.String file_name)
public void setInterfaceNames(java.lang.String[] interface_names)
interface_names
- .public void setInterfaces(int[] interfaces)
interfaces
- .public void setMajor(int major)
major
- .public void setMethods(Method[] methods)
methods
- .public void setMinor(int minor)
minor
- .public void setSourceFileName(java.lang.String source_file_name)
public void setSuperclassName(java.lang.String superclass_name)
superclass_name
- .public void setSuperclassNameIndex(int superclass_name_index)
superclass_name_index
- .public java.lang.String toString()
toString
in class java.lang.Object
private static final java.lang.String indent(java.lang.Object obj)
public JavaClass copy()
public final boolean isSuper()
public final boolean isClass()
public final byte getSource()
public Repository getRepository()
public void setRepository(Repository repository)
public final boolean instanceOf(JavaClass super_class) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
- if superclasses or superinterfaces
of this object can't be foundpublic boolean implementationOf(JavaClass inter) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
- if superclasses or superinterfaces
of this class can't be foundpublic JavaClass getSuperClass() throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
- if the superclass can't be foundpublic JavaClass[] getSuperClasses() throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
- if any of the superclasses can't be foundpublic JavaClass[] getInterfaces() throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
public JavaClass[] getAllInterfaces() throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
public static BCELComparator getComparator()
public static void setComparator(BCELComparator comparator)
comparator
- Comparison strategy objectpublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
Object.equals(java.lang.Object)
public int compareTo(java.lang.Object obj)
compareTo
in interface java.lang.Comparable
public int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |