public class JavaClass extends AccessFlags implements Cloneable, Node, Comparable
ClassGen
,
Serialized FormModifier and Type | Field and Description |
---|---|
static byte |
FILE |
static byte |
HEAP |
static byte |
ZIP |
access_flags
Constructor and Description |
---|
JavaClass(int class_name_index,
int superclass_name_index,
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,
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.
|
Modifier and Type | Method and Description |
---|---|
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(Object obj)
Return the natural ordering of two JavaClasses.
|
JavaClass |
copy() |
void |
dump(DataOutputStream file)
Dump Java class to output stream in binary format.
|
void |
dump(File file)
Dump class to a file.
|
void |
dump(OutputStream file)
Dump Java class to output stream in binary format.
|
void |
dump(String _file_name)
Dump class to a file named file_name.
|
boolean |
equals(Object obj)
Return value as defined by given BCELComparator strategy.
|
JavaClass[] |
getAllInterfaces()
Get all interfaces implemented by this JavaClass (transitively).
|
Attribute[] |
getAttributes() |
byte[] |
getBytes() |
String |
getClassName() |
int |
getClassNameIndex() |
static BCELComparator |
getComparator() |
ConstantPool |
getConstantPool() |
Field[] |
getFields() |
String |
getFileName() |
int[] |
getInterfaceIndices() |
String[] |
getInterfaceNames() |
JavaClass[] |
getInterfaces()
Get interfaces directly implemented by this JavaClass.
|
int |
getMajor() |
Method |
getMethod(Method m) |
Method[] |
getMethods() |
int |
getMinor() |
String |
getPackageName() |
Repository |
getRepository()
Gets the ClassRepository which holds its definition.
|
byte |
getSource() |
String |
getSourceFileName() |
JavaClass |
getSuperClass() |
JavaClass[] |
getSuperClasses() |
String |
getSuperclassName() |
int |
getSuperclassNameIndex() |
int |
hashCode()
Return value as defined by given BCELComparator strategy.
|
boolean |
implementationOf(JavaClass inter) |
boolean |
instanceOf(JavaClass super_class)
Equivalent to runtime "instanceof" operator.
|
boolean |
isClass() |
boolean |
isSuper() |
void |
setAttributes(Attribute[] attributes) |
void |
setClassName(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(String file_name)
Set File name of class, aka SourceFile attribute value
|
void |
setInterfaceNames(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(String source_file_name)
Set absolute path to file this class was read from.
|
void |
setSuperclassName(String superclass_name) |
void |
setSuperclassNameIndex(int superclass_name_index) |
String |
toString() |
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
public static final byte HEAP
public static final byte FILE
public static final byte ZIP
public JavaClass(int class_name_index, int superclass_name_index, 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, 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 attributespublic void accept(Visitor v)
public void dump(File file) throws IOException
file
- Output fileIOException
public void dump(String _file_name) throws IOException
_file_name
- Output file nameIOException
public byte[] getBytes()
public void dump(OutputStream file) throws IOException
file
- Output streamIOException
public void dump(DataOutputStream file) throws IOException
file
- Output streamIOException
public Attribute[] getAttributes()
public String getClassName()
public String getPackageName()
public int getClassNameIndex()
public ConstantPool getConstantPool()
public Field[] getFields()
public String getFileName()
public String[] getInterfaceNames()
public int[] getInterfaceIndices()
public int getMajor()
public Method[] getMethods()
public Method getMethod(Method m)
public int getMinor()
public String getSourceFileName()
public String getSuperclassName()
public int getSuperclassNameIndex()
public void setAttributes(Attribute[] attributes)
attributes
- .public void setClassName(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(String file_name)
public void setInterfaceNames(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(String source_file_name)
public void setSuperclassName(String superclass_name)
superclass_name
- .public void setSuperclassNameIndex(int superclass_name_index)
superclass_name_index
- .public String toString()
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 ClassNotFoundException
ClassNotFoundException
- if superclasses or superinterfaces
of this object can't be foundpublic boolean implementationOf(JavaClass inter) throws ClassNotFoundException
ClassNotFoundException
- if superclasses or superinterfaces
of this class can't be foundpublic JavaClass getSuperClass() throws ClassNotFoundException
ClassNotFoundException
- if the superclass can't be foundpublic JavaClass[] getSuperClasses() throws ClassNotFoundException
ClassNotFoundException
- if any of the superclasses can't be foundpublic JavaClass[] getInterfaces() throws ClassNotFoundException
ClassNotFoundException
public JavaClass[] getAllInterfaces() throws ClassNotFoundException
ClassNotFoundException
public static BCELComparator getComparator()
public static void setComparator(BCELComparator comparator)
comparator
- Comparison strategy objectpublic boolean equals(Object obj)
equals
in class Object
Object.equals(java.lang.Object)
public int compareTo(Object obj)
compareTo
in interface Comparable
public int hashCode()
hashCode
in class Object
Object.hashCode()
Copyright © 2014. All rights reserved.