public class JavaClass extends AccessFlags implements Cloneable, Node, Comparable<JavaClass>
ClassGen
Modifier and Type | Field and Description |
---|---|
static byte |
FILE |
static byte |
HEAP |
static byte |
ZIP |
access_flags
Constructor and Description |
---|
JavaClass(int classNameIndex,
int superclassNameIndex,
String fileName,
int major,
int minor,
int access_flags,
ConstantPool constantPool,
int[] interfaces,
Field[] fields,
Method[] methods,
Attribute[] attributes)
Constructor gets all contents as arguments.
|
JavaClass(int classNameIndex,
int superclassNameIndex,
String fileName,
int major,
int minor,
int access_flags,
ConstantPool constantPool,
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(JavaClass 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 fileName.
|
boolean |
equals(Object obj)
Return value as defined by given BCELComparator strategy.
|
JavaClass[] |
getAllInterfaces()
Get all interfaces implemented by this JavaClass (transitively).
|
AnnotationEntry[] |
getAnnotationEntries() |
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()
returns the super class name of this class.
|
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 |
isAnonymous() |
boolean |
isClass() |
boolean |
isNested() |
boolean |
isSuper() |
void |
setAttributes(Attribute[] attributes) |
void |
setClassName(String className) |
void |
setClassNameIndex(int classNameIndex) |
static void |
setComparator(BCELComparator comparator) |
void |
setConstantPool(ConstantPool constantPool) |
void |
setFields(Field[] fields) |
void |
setFileName(String fileName)
Set File name of class, aka SourceFile attribute value
|
void |
setInterfaceNames(String[] interfaceNames) |
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 sourceFileName)
Set absolute path to file this class was read from.
|
void |
setSuperclassName(String superclassName) |
void |
setSuperclassNameIndex(int superclassNameIndex) |
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, isVarArgs, isVarArgs, isVolatile, isVolatile, setAccessFlags, setModifiers
public static final byte HEAP
public static final byte FILE
public static final byte ZIP
public JavaClass(int classNameIndex, int superclassNameIndex, String fileName, int major, int minor, int access_flags, ConstantPool constantPool, int[] interfaces, Field[] fields, Method[] methods, Attribute[] attributes, byte source)
classNameIndex
- Index into constant pool referencing a
ConstantClass that represents this class.superclassNameIndex
- Index into constant pool referencing a
ConstantClass that represents this class's superclass.fileName
- File namemajor
- Major compiler versionminor
- Minor compiler versionaccess_flags
- Access rights defined by bit flagsconstantPool
- Array of constantsinterfaces
- Implemented interfacesfields
- Class fieldsmethods
- Class methodsattributes
- Class attributessource
- Read from file or generated in memory?public JavaClass(int classNameIndex, int superclassNameIndex, String fileName, int major, int minor, int access_flags, ConstantPool constantPool, int[] interfaces, Field[] fields, Method[] methods, Attribute[] attributes)
classNameIndex
- Class namesuperclassNameIndex
- Superclass namefileName
- File namemajor
- Major compiler versionminor
- Minor compiler versionaccess_flags
- Access rights defined by bit flagsconstantPool
- 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 AnnotationEntry[] getAnnotationEntries()
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)
Method
corresponding to
java.lang.reflect.Method if anypublic int getMinor()
public String getSourceFileName()
public String getSuperclassName()
public int getSuperclassNameIndex()
public void setAttributes(Attribute[] attributes)
attributes
- .public void setClassName(String className)
className
- .public void setClassNameIndex(int classNameIndex)
classNameIndex
- .public void setConstantPool(ConstantPool constantPool)
constantPool
- .public void setFields(Field[] fields)
fields
- .public void setFileName(String fileName)
public void setInterfaceNames(String[] interfaceNames)
interfaceNames
- .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 sourceFileName)
public void setSuperclassName(String superclassName)
superclassName
- .public void setSuperclassNameIndex(int superclassNameIndex)
superclassNameIndex
- .public String toString()
public JavaClass copy()
public final boolean isSuper()
public final boolean isClass()
public final boolean isAnonymous()
public final boolean isNested()
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(JavaClass obj)
compareTo
in interface Comparable<JavaClass>
public int hashCode()
hashCode
in class Object
Object.hashCode()
Copyright © 2004–2023 The Apache Software Foundation. All rights reserved.