public class ClassFile extends Object
Constructor and Description |
---|
ClassFile(File file,
boolean includeCode)
Create a new ClassFile object.
|
ClassFile(InputStream classData)
Create a new ClassFile object.
|
ClassFile(InputStream classData,
boolean includeCode)
Create a new ClassFile object.
|
ClassFile(String classFileName)
Create a new ClassFile object.
|
ClassFile(String classFileName,
boolean includeCode)
Create a new ClassFile object.
|
Modifier and Type | Method and Description |
---|---|
int |
getAccess()
Returns the access permissions of this class or interface.
|
Set<ClassName> |
getAllClassNames()
Return the collection of all unique class references in this class.
|
Annotation |
getAnnotation(ClassName annotationClass)
Returns the annotation for a specified annotation type, or null if
no annotation of that type exists for this class.
|
Collection<Annotation> |
getAnnotations()
Returns all runtime annotations defined for this class.
|
AttributeMap |
getAttributes()
Returns a map of the raw attributes for this classfile.
|
List<BootstrapMethod> |
getBootstrapMethods()
Return the content of the
BootstrapMethods attribute. |
ConstantPool |
getConstantPool()
Returns the ConstantPool object associated with this ClassFile.
|
EnclosingMethod |
getEnclosingMethod()
Returns the enclosing method for this class.
|
Collection<InnerClass> |
getInnerClasses() |
Collection<ClassName> |
getInterfaces() |
int |
getMajorVersion()
Returns the major version number of this classfile.
|
Method |
getMethod(String name,
String signature)
Looks up a method by its name and type signature, as defined
by the Java Virtual Machine Specification, section 4.3.3.
|
int |
getMethodCount() |
Collection<Method> |
getMethods() |
int |
getMinorVersion()
Returns the minor version number of this classfile.
|
Module |
getModule()
Returns the content of the
Module attribute. |
ClassName |
getModuleMainClass()
Returns the content of the
ModuleMainClass attribute. |
List<String> |
getModulePackages()
Returns the content of the
ModulePackages attribute. |
ModuleTarget |
getModuleTarget()
Returns the content of the
ModuleTarget attribute. |
ClassName |
getName()
Returns the name of this class.
|
String |
getSourceFileName() |
ClassName |
getSuperClass()
Returns the name of this class's superclass.
|
String |
getTypeSignature()
Returns the generic type information associated with this class.
|
Variable |
getVariable(String name)
Looks up a variable by its name.
|
int |
getVariableCount() |
Collection<Variable> |
getVariables() |
boolean |
isAnnotation()
Returns true if this class is an annotation type.
|
boolean |
isAnnotationPresent(ClassName annotationClass)
Returns true if an annotation of the specified type is defined for
this class.
|
boolean |
isDeprecated() |
boolean |
isEnum()
Returns true if this class defines an enum type.
|
boolean |
isModule()
Returns true if this class defines a module.
|
boolean |
isSynthetic() |
String |
toString() |
public ClassFile(InputStream classData) throws IOException
classData
- an InputStream from which the defining bytes of this
class or interface are read.IOException
- if InputStream can't be read, or if the class data
is malformed.public ClassFile(String classFileName) throws IOException
classFileName
- the path of a class file.IOException
- if file cannot be opened or read.public ClassFile(File file, boolean includeCode) throws IOException
file
- a File instance of a class file.includeCode
- true if this classfile should support operations
at the bytecode level. Specify false to conserve
memory if code access isn't needed.IOException
- if file cannot be opened or read.public ClassFile(InputStream classData, boolean includeCode) throws IOException
classData
- an InputStream from which the defining bytes of this
class or interface are read.includeCode
- true if this classfile should support operations
at the bytecode level. Specify false to conserve
memory if code access isn't needed.IOException
- if InputStream can't be read, or if the class data
is malformed.public ClassFile(String classFileName, boolean includeCode) throws IOException
classFileName
- the path of a class file.includeCode
- true if this classfile should support operations
at the bytecode level. Specify false to conserve
memory if code access isn't needed.IOException
- if file cannot be opened or read.public final ConstantPool getConstantPool()
public final int getAccess()
Access
public final ClassName getName()
public final ClassName getSuperClass()
public final Collection<ClassName> getInterfaces()
public final Variable getVariable(String name)
name
- the name of the variablepublic final Collection<Variable> getVariables()
public final int getVariableCount()
public final Method getMethod(String name, String signature)
name
- the name of the methodsignature
- the method's type signaturepublic final Collection<Method> getMethods()
public final int getMethodCount()
public final String getSourceFileName()
public final boolean isDeprecated()
public final boolean isSynthetic()
public final boolean isAnnotation()
public final boolean isEnum()
public final boolean isModule()
public final AttributeMap getAttributes()
Field.getAttributes()
public final Collection<InnerClass> getInnerClasses()
public final List<BootstrapMethod> getBootstrapMethods()
BootstrapMethods
attribute.List
of BootstrapMethodpublic final Module getModule()
Module
attribute.Module
or null when there is no Module
attribute.public final List<String> getModulePackages()
ModulePackages
attribute.List
of packages or null when there is no ModulePackages
attribute.public final ClassName getModuleMainClass()
ModuleMainClass
attribute.ModuleMainClass
attribute.public final ModuleTarget getModuleTarget()
ModuleTarget
attribute.ModuleTarget
or null when there is no ModuleTarget
attribute.public int getMajorVersion()
public int getMinorVersion()
public String getTypeSignature()
public EnclosingMethod getEnclosingMethod()
public final Collection<Annotation> getAnnotations()
public final Annotation getAnnotation(ClassName annotationClass)
annotationClass
- type of annotationpublic final boolean isAnnotationPresent(ClassName annotationClass)
annotationClass
- type of annotationpublic final Set<ClassName> getAllClassNames()