public class JavaClass extends AccessFlags implements Cloneable, Node, Comparable<JavaClass>
ClassGen
Modifier and Type | Field and Description |
---|---|
static JavaClass[] |
EMPTY_ARRAY
Empty array.
|
static String |
EXTENSION
The standard class file extension.
|
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 accessFlags,
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 accessFlags,
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 implicitly 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 fileName)
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() |
String |
getSourceFilePath()
Gets the source file path including the package path.
|
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 superclass)
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 String EXTENSION
public static final JavaClass[] EMPTY_ARRAY
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 accessFlags, ConstantPool constantPool, int[] interfaces, Field[] fields, Method[] methods, Attribute[] attributes)
classNameIndex
- Class namesuperclassNameIndex
- Superclass namefileName
- File namemajor
- Major compiler versionminor
- Minor compiler versionaccessFlags
- Access rights defined by bit flagsconstantPool
- Array of constantsinterfaces
- Implemented interfacesfields
- Class fieldsmethods
- Class methodsattributes
- Class attributespublic JavaClass(int classNameIndex, int superclassNameIndex, String fileName, int major, int minor, int accessFlags, 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 versionaccessFlags
- 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 static BCELComparator getComparator()
public static void setComparator(BCELComparator comparator)
comparator
- Comparison strategy objectpublic void accept(Visitor v)
public int compareTo(JavaClass obj)
compareTo
in interface Comparable<JavaClass>
public void dump(DataOutputStream file) throws IOException
file
- Output streamIOException
- if an I/O error occurs.public void dump(File file) throws IOException
file
- Output fileIOException
- if an I/O error occurs.public void dump(OutputStream file) throws IOException
file
- Output streamIOException
- if an I/O error occurs.public void dump(String fileName) throws IOException
fileName
- Output file nameIOException
- if an I/O error occurs.public boolean equals(Object obj)
equals
in class Object
Object.equals(Object)
public JavaClass[] getAllInterfaces() throws ClassNotFoundException
ClassNotFoundException
- if any of the class's superclasses or interfaces can't be found.public AnnotationEntry[] getAnnotationEntries()
public Attribute[] getAttributes()
public byte[] getBytes()
public String getClassName()
public int getClassNameIndex()
public ConstantPool getConstantPool()
public Field[] getFields()
public String getFileName()
public int[] getInterfaceIndices()
public String[] getInterfaceNames()
public JavaClass[] getInterfaces() throws ClassNotFoundException
ClassNotFoundException
- if any of the class's interfaces can't be found.public int getMajor()
public Method getMethod(Method m)
Method
corresponding to java.lang.reflect.Method if anypublic Method[] getMethods()
public int getMinor()
public String getPackageName()
public Repository getRepository()
public final byte getSource()
public String getSourceFileName()
public String getSourceFilePath()
public 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 String getSuperclassName()
public int getSuperclassNameIndex()
public int hashCode()
hashCode
in class Object
Object.hashCode()
public boolean implementationOf(JavaClass inter) throws ClassNotFoundException
ClassNotFoundException
- if superclasses or superinterfaces of this class can't be foundpublic final boolean instanceOf(JavaClass superclass) throws ClassNotFoundException
ClassNotFoundException
- if superclasses or superinterfaces of this object can't be foundpublic final boolean isAnonymous()
public final boolean isClass()
public final boolean isNested()
public final boolean isSuper()
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 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 setRepository(Repository repository)
public void setSourceFileName(String sourceFileName)
public void setSuperclassName(String superclassName)
superclassName
- .public void setSuperclassNameIndex(int superclassNameIndex)
superclassNameIndex
- .Copyright © 2004–2022 The Apache Software Foundation. All rights reserved.