Modifier and Type | Field and Description |
---|---|
static int |
ACC_ABSTRACT
This field represents ACC_ABSTRACT in the access_flags element of a ClassFile structure.
|
static int |
ACC_ANNOTATION
This field represents ACC_ANNOTATION in the access_flags element of a ClassFile structure.
|
static int |
ACC_ENUM
This field represents ACC_ENUM in the access_flags element of a ClassFile structure.
|
static int |
ACC_FINAL
This field represents ACC_FINAL in the access_flags element of a ClassFile structure.
|
static int |
ACC_INTERFACE
This field represents ACC_INTERFACE in the access_flags element of a ClassFile structure.
|
static int |
ACC_MODULE
This field represents ACC_MODULE in the access_flags element of a ClassFile structure.
|
static int |
ACC_PUBLIC
This field represents ACC_PUBLIC in the access_flags element of a ClassFile structure.
|
static int |
ACC_SUPER
This field represents ACC_SUPER in the access_flags element of a ClassFile structure.
|
static int |
ACC_SYNTHETIC
This field represents ACC_SYNTHETIC in the access_flags element of a ClassFile structure.
|
static int |
MAJOR_VERSION_1_0
The major_version for JDK 1.0.
|
static int |
MAJOR_VERSION_1_1
The major_version for JDK 1.1.
|
static int |
MAJOR_VERSION_1_2
The major_version for JDK 1.2.
|
static int |
MAJOR_VERSION_1_3
The major_version for JDK 1.3.
|
static int |
MAJOR_VERSION_1_4
The major_version for JDK 1.4.
|
static int |
MAJOR_VERSION_10_0
The major_version for J2SE 10.0.
|
static int |
MAJOR_VERSION_11_0
The major_version for J2SE 11.0.
|
static int |
MAJOR_VERSION_5_0
The major_version for J2SE 5.0.
|
static int |
MAJOR_VERSION_6_0
The major_version for J2SE 6.0.
|
static int |
MAJOR_VERSION_7_0
The major_version for J2SE 7.0.
|
static int |
MAJOR_VERSION_8_0
The major_version for J2SE 8.0.
|
static int |
MAJOR_VERSION_9_0
The major_version for J2SE 9.0.
|
static int |
MINOR_VERSION_1_0
The minor_version for JDK 1.0.
|
static int |
MINOR_VERSION_1_1
The minor_version for JDK 1.1.
|
static int |
MINOR_VERSION_1_2
The minor_version for JDK 1.2.
|
static int |
MINOR_VERSION_1_3
The minor_version for JDK 1.3.
|
static int |
MINOR_VERSION_1_4
The minor_version for JDK 1.4.
|
static int |
MINOR_VERSION_10_0
The minor_version for JDK 10.0.
|
static int |
MINOR_VERSION_11_0
The minor_version for JDK 11.0.
|
static int |
MINOR_VERSION_5_0
The minor_version for J2SE 5.0.
|
static int |
MINOR_VERSION_6_0
The minor_version for J2SE 6.0.
|
static int |
MINOR_VERSION_7_0
The minor_version for J2SE 7.0.
|
static int |
MINOR_VERSION_8_0
The minor_version for J2SE 8.0.
|
static int |
MINOR_VERSION_9_0
The minor_version for J2SE 9.0.
|
Constructor and Description |
---|
ClassFile()
Constructs a new empty
ClassFile instance. |
Modifier and Type | Method and Description |
---|---|
boolean |
accept(NodeHierarchicalVisitor nodeHierarchicalVisitor)
Accepts a
NodeHierarchicalVisitor . |
boolean |
addAttributeInfo(AttributeInfo attributeInfo)
Adds
attributeInfo to this ClassFile instance, if absent. |
boolean |
addCPInfo(CPInfo cPInfo)
Adds
cPInfo to this ClassFile instance. |
boolean |
addFieldInfo(FieldInfo fieldInfo)
Adds
fieldInfo to this ClassFile instance, if absent. |
boolean |
addInterface(int index)
Adds an interface index to this
ClassFile instance, if absent. |
boolean |
addMethodInfo(MethodInfo methodInfo)
Adds
methodInfo to this ClassFile instance, if absent. |
boolean |
containsAttributeInfo(AttributeInfo attributeInfo)
Returns
true if, and only if, this ClassFile instance contains attributeInfo , false otherwise. |
boolean |
containsCPInfo(CPInfo cPInfo)
Returns
true if, and only if, this ClassFile instance contains cPInfo , false otherwise. |
boolean |
containsFieldInfo(FieldInfo fieldInfo)
Returns
true if, and only if, this ClassFile instance contains fieldInfo , false otherwise. |
boolean |
containsMethodInfo(MethodInfo methodInfo)
Returns
true if, and only if, this ClassFile instance contains methodInfo , false otherwise. |
ClassFile |
copy()
Returns a copy of this
ClassFile instance. |
boolean |
equals(java.lang.Object object)
Compares
object to this ClassFile instance for equality. |
int |
getAccessFlags()
Returns the access_flags of this
ClassFile instance. |
AttributeInfo |
getAttributeInfo(AttributeInfo attributeInfo)
|
AttributeInfo |
getAttributeInfo(int index)
Returns an
AttributeInfo given its index. |
<T extends AttributeInfo> |
getAttributeInfo(int index,
java.lang.Class<T> clazz)
Returns an
AttributeInfo cast to T given its index. |
int |
getAttributeInfoCount()
Returns the number of
AttributeInfo s currently added. |
java.util.List<AttributeInfo> |
getAttributeInfos()
Returns a
List with all currently added AttributeInfo s. |
CPInfo |
getCPInfo(CPInfo cPInfo)
|
CPInfo |
getCPInfo(int index)
Returns a
CPInfo given its index. |
<T extends CPInfo> |
getCPInfo(int index,
java.lang.Class<T> clazz)
Returns a
CPInfo cast to T given its index. |
<T extends CPInfo> |
getCPInfo(T cPInfo,
java.lang.Class<T> clazz)
|
int |
getCPInfoCount()
Returns the number of
CPInfo s currently added. |
java.util.List<CPInfo> |
getCPInfos()
Returns a
List with all currently added CPInfo s. |
FieldInfo |
getFieldInfo(FieldInfo fieldInfo)
|
FieldInfo |
getFieldInfo(int index)
Returns a
FieldInfo given its index. |
int |
getFieldInfoCount()
Returns the number of
FieldInfo s currently added. |
java.util.List<FieldInfo> |
getFieldInfos()
Returns a
List with all currently added FieldInfo s. |
int |
getInterfaceCount()
Returns the number of interfaces currently added.
|
java.util.List<java.lang.Integer> |
getInterfaces()
Returns a
List with all currently added interfaces. |
int |
getMagic()
Returns the magic of this
ClassFile instance. |
int |
getMajorVersion()
Returns the major_version of this
ClassFile instance. |
MethodInfo |
getMethodInfo(int index)
Returns a
MethodInfo given its index. |
MethodInfo |
getMethodInfo(MethodInfo methodInfo)
|
int |
getMethodInfoCount()
Returns the number of
MethodInfo s currently added. |
java.util.List<MethodInfo> |
getMethodInfos()
Returns a
List with all currently added MethodInfo s. |
int |
getMinorVersion()
Returns the minor_version of this
ClassFile instance. |
int |
getSuperClass()
Returns the super_class of this
ClassFile instance. |
int |
getThisClass()
Returns the this_class of this
ClassFile instance. |
int |
hashCode()
Returns a hash code for this
ClassFile instance. |
int |
indexOf(CPInfo cPInfo)
Returns the index of
cPInfo in the constant_pool of this ClassFile instance, or -1 if it is an instance of ConstantUnreachableInfo or it does not exist. |
boolean |
isAbstract()
Returns
true if, and only if, ACC_ABSTRACT is set in the access_flags item of this ClassFile instance, false otherwise. |
boolean |
isAnnotation()
Returns
true if, and only if, ACC_ANNOTATION is set in the access_flags item of this ClassFile instance, false otherwise. |
boolean |
isEnum()
Returns
true if, and only if, ACC_ENUM is set in the access_flags item of this ClassFile instance, false otherwise. |
boolean |
isFinal()
Returns
true if, and only if, ACC_FINAL is set in the access_flags item of this ClassFile instance, false otherwise. |
boolean |
isInterface()
Returns
true if, and only if, ACC_INTERFACE is set in the access_flags item of this ClassFile instance, false otherwise. |
boolean |
isModule()
Returns
true if, and only if, ACC_MODULE is set in the access_flags item of this ClassFile instance, false otherwise. |
boolean |
isPublic()
Returns
true if, and only if, ACC_PUBLIC is set in the access_flags item of this ClassFile instance, false otherwise. |
boolean |
isSuper()
Returns
true if, and only if, ACC_SUPER is set in the access_flags item of this ClassFile instance, false otherwise. |
boolean |
isSynthetic()
Returns
true if, and only if, ACC_SYNTHETIC is set in the access_flags item of this ClassFile instance, false otherwise. |
static ClassFile |
newInstance()
Returns a new empty
ClassFile instance. |
boolean |
removeAttributeInfo(AttributeInfo attributeInfo)
Removes
attributeInfo from this ClassFile instance, if present. |
boolean |
removeCPInfo(CPInfo cPInfo)
Removes
cPInfo from this ClassFile instance, if present. |
boolean |
removeFieldInfo(FieldInfo fieldInfo)
Removes
fieldInfo from this ClassFile instance, if present. |
boolean |
removeInterface(int index)
Removes the interface index
index from this ClassFile instance, if present. |
boolean |
removeMethodInfo(MethodInfo methodInfo)
Removes
methodInfo from this ClassFile instance, if present. |
void |
setAbstract(boolean isAbstract)
Adds or removes the access flag ACC_ABSTRACT.
|
void |
setAccessFlags(int accessFlags)
Sets the access_flags for this
ClassFile instance. |
void |
setAnnotation(boolean isAnnotation)
Adds or removes the access flag ACC_ANNOTATION.
|
boolean |
setAttributeInfo(AttributeInfo attributeInfo,
int index)
Sets
attributeInfo as the AttributeInfo on the given index. |
boolean |
setCPInfo(CPInfo cPInfo,
int index)
Sets
cPInfo as the CPInfo on the given index. |
void |
setEnum(boolean isEnum)
Adds or removes the access flag ACC_ENUM.
|
boolean |
setFieldInfo(FieldInfo fieldInfo,
int index)
Sets
fieldInfo as the FieldInfo on the given index. |
void |
setFinal(boolean isFinal)
Adds or removes the access flag ACC_FINAL.
|
void |
setInterface(boolean isInterface)
Adds or removes the access flag ACC_INTERFACE.
|
void |
setMajorVersion(int majorVersion)
Sets a new major_version for this
ClassFile instance. |
boolean |
setMethodInfo(MethodInfo methodInfo,
int index)
Sets
methodInfo as the MethodInfo on the given index. |
void |
setMinorVersion(int minorVersion)
Sets a new minor_version for this
ClassFile instance. |
void |
setModule(boolean isModule)
Adds or removes the access flag ACC_MODULE.
|
void |
setPublic(boolean isPublic)
Adds or removes the access flag ACC_PUBLIC.
|
void |
setSuper(boolean isSuper)
Adds or removes the access flag ACC_SUPER.
|
void |
setSuperClass(int superClass)
Sets a new super_class for this
ClassFile instance. |
void |
setSynthetic(boolean isSynthetic)
Adds or removes the access flag ACC_SYNTHETIC.
|
void |
setThisClass(int thisClass)
Sets a new this_class for this
ClassFile instance. |
java.lang.String |
toString()
Returns a
String representation of this ClassFile instance. |
Document |
write()
Writes this
ClassFile to a Document . |
java.io.DataOutput |
write(java.io.DataOutput dataOutput)
Writes this
ClassFile to dataOutput . |
Document |
write(Document document)
Writes this
ClassFile to document . |
java.io.DataOutput |
write(java.io.File file)
Writes this
ClassFile to file . |
public static final int ACC_ABSTRACT
public static final int ACC_ANNOTATION
public static final int ACC_ENUM
public static final int ACC_FINAL
public static final int ACC_INTERFACE
public static final int ACC_MODULE
public static final int ACC_PUBLIC
public static final int ACC_SUPER
public static final int ACC_SYNTHETIC
public static final int MAJOR_VERSION_1_0
public static final int MAJOR_VERSION_1_1
public static final int MAJOR_VERSION_1_2
public static final int MAJOR_VERSION_1_3
public static final int MAJOR_VERSION_1_4
public static final int MAJOR_VERSION_10_0
public static final int MAJOR_VERSION_11_0
public static final int MAJOR_VERSION_5_0
public static final int MAJOR_VERSION_6_0
public static final int MAJOR_VERSION_7_0
public static final int MAJOR_VERSION_8_0
public static final int MAJOR_VERSION_9_0
public static final int MINOR_VERSION_1_0
public static final int MINOR_VERSION_1_1
public static final int MINOR_VERSION_1_2
public static final int MINOR_VERSION_1_3
public static final int MINOR_VERSION_1_4
public static final int MINOR_VERSION_10_0
public static final int MINOR_VERSION_11_0
public static final int MINOR_VERSION_5_0
public static final int MINOR_VERSION_6_0
public static final int MINOR_VERSION_7_0
public static final int MINOR_VERSION_8_0
public static final int MINOR_VERSION_9_0
public AttributeInfo getAttributeInfo(AttributeInfo attributeInfo)
AttributeInfo
instance of this ClassFile
instance that is equal to attributeInfo
.
If attributeInfo
is null
, a NullPointerException
will be thrown.
If this ClassFile
instance does not contain an AttributeInfo
instance that is equal to attributeInfo
, an IllegalArgumentException
will be thrown.
attributeInfo
- the AttributeInfo
instance to test for equality againstAttributeInfo
instance of this ClassFile
instance that is equal to attributeInfo
java.lang.IllegalArgumentException
- thrown if, and only if, this ClassFile
instance does not contain an AttributeInfo
instance that is equal to attributeInfo
java.lang.NullPointerException
- thrown if, and only if, attributeInfo
is null
public AttributeInfo getAttributeInfo(int index)
AttributeInfo
given its index.
If index
is less than 0
, or greater than or equal to getAttributeInfoCount()
, an IndexOutOfBoundsException
will be thrown.
index
- the index of the AttributeInfo
AttributeInfo
given its indexjava.lang.IndexOutOfBoundsException
- thrown if, and only if, index
is less than 0
, or greater than or equal to getAttributeInfoCount()
public CPInfo getCPInfo(CPInfo cPInfo)
CPInfo
instance of this ClassFile
instance that is equal to cPInfo
.
If cPInfo
is null
, a NullPointerException
will be thrown.
If this ClassFile
instance does not contain a CPInfo
instance that is equal to cPInfo
, an IllegalArgumentException
will be thrown.
cPInfo
- the CPInfo
instance to test for equality againstCPInfo
instance of this ClassFile
instance that is equal to cPInfo
java.lang.IllegalArgumentException
- thrown if, and only if, this ClassFile
instance does not contain a CPInfo
instance that is equal to cPInfo
java.lang.NullPointerException
- thrown if, and only if, cPInfo
is null
public CPInfo getCPInfo(int index)
CPInfo
given its index.
If index
is less than 0
, or greater than or equal to getCPInfoCount()
, an IndexOutOfBoundsException
will be thrown.
index
- the index of the CPInfo
CPInfo
given its indexjava.lang.IndexOutOfBoundsException
- thrown if, and only if, index
is less than 0
, or greater than or equal to getCPInfoCount()
public ClassFile copy()
ClassFile
instance.ClassFile
instancepublic java.io.DataOutput write(java.io.DataOutput dataOutput)
ClassFile
to dataOutput
.
Returns dataOutput
.
If dataOutput
is null
, a NullPointerException
will be thrown.
If an IOException
is caught, an UncheckedIOException
will be thrown.
This method does not close dataOutput
.
dataOutput
- the DataOutput
to write todataOutput
java.lang.NullPointerException
- thrown if, and only if, dataOutput
is null
java.io.UncheckedIOException
- thrown if, and only if, some IOException
is caughtpublic java.io.DataOutput write(java.io.File file)
ClassFile
to file
.
Returns the DataOutput
that was written to.
If file
is null
, a NullPointerException
will be thrown.
If an IOException
is caught, an UncheckedIOException
will be thrown.
The DataOutput
returned will get closed.
file
- the File
to write toDataOutput
that was written tojava.lang.NullPointerException
- thrown if, and only if, file
is null
java.io.UncheckedIOException
- thrown if, and only if, an IOException
is caughtpublic Document write()
ClassFile
to a Document
.
Returns the Document
.
Calling this method is equivalent to the following:
classFile.write(new Document());
Document
public Document write(Document document)
ClassFile
to document
.
Returns document
.
If document
is null
, a NullPointerException
will be thrown.
document
- the Document
to write todocument
java.lang.NullPointerException
- thrown if, and only if, document
is null
public FieldInfo getFieldInfo(FieldInfo fieldInfo)
FieldInfo
instance of this ClassFile
instance that is equal to fieldInfo
.
If fieldInfo
is null
, a NullPointerException
will be thrown.
If this ClassFile
instance does not contain a FieldInfo
instance that is equal to fieldInfo
, an IllegalArgumentException
will be thrown.
fieldInfo
- the FieldInfo
instance to test for equality againstFieldInfo
instance of this ClassFile
instance that is equal to fieldInfo
java.lang.IllegalArgumentException
- thrown if, and only if, this ClassFile
instance does not contain a FieldInfo
instance that is equal to fieldInfo
java.lang.NullPointerException
- thrown if, and only if, fieldInfo
is null
public FieldInfo getFieldInfo(int index)
FieldInfo
given its index.
If index
is less than 0
, or greater than or equal to getFieldInfoCount()
, an IndexOutOfBoundsException
will be thrown.
index
- the index of the FieldInfo
FieldInfo
given its indexjava.lang.IndexOutOfBoundsException
- thrown if, and only if, index
is less than 0
, or greater than or equal to getFieldInfoCount()
public java.util.List<AttributeInfo> getAttributeInfos()
List
with all currently added AttributeInfo
s.
Modifying the returned List
will not affect this ClassFile
instance.
List
with all currently added AttributeInfo
spublic java.util.List<CPInfo> getCPInfos()
List
with all currently added CPInfo
s.
Modifying the returned List
will not affect this ClassFile
instance.
List
with all currently added CPInfo
spublic java.util.List<FieldInfo> getFieldInfos()
List
with all currently added FieldInfo
s.
Modifying the returned List
will not affect this ClassFile
instance.
List
with all currently added FieldInfo
spublic java.util.List<java.lang.Integer> getInterfaces()
List
with all currently added interfaces.
Modifying the returned List
will not affect this ClassFile
instance.
List
with all currently added interfacespublic java.util.List<MethodInfo> getMethodInfos()
List
with all currently added MethodInfo
s.
Modifying the returned List
will not affect this ClassFile
instance.
List
with all currently added MethodInfo
spublic MethodInfo getMethodInfo(MethodInfo methodInfo)
MethodInfo
instance of this ClassFile
instance that is equal to methodInfo
.
If methodInfo
is null
, a NullPointerException
will be thrown.
If this ClassFile
instance does not contain a MethodInfo
instance that is equal to methodInfo
, an IllegalArgumentException
will be thrown.
methodInfo
- the MethodInfo
instance to test for equality againstMethodInfo
instance of this ClassFile
instance that is equal to methodInfo
java.lang.IllegalArgumentException
- thrown if, and only if, this ClassFile
instance does not contain a MethodInfo
instance that is equal to methodInfo
java.lang.NullPointerException
- thrown if, and only if, methodInfo
is null
public MethodInfo getMethodInfo(int index)
MethodInfo
given its index.
If index
is less than 0
, or greater than or equal to getMethodInfoCount()
, an IndexOutOfBoundsException
will be thrown.
index
- the index of the MethodInfo
MethodInfo
given its indexjava.lang.IndexOutOfBoundsException
- thrown if, and only if, index
is less than 0
, or greater than or equal to getMethodInfoCount()
public java.lang.String toString()
String
representation of this ClassFile
instance.toString
in class java.lang.Object
String
representation of this ClassFile
instancepublic <T extends AttributeInfo> T getAttributeInfo(int index, java.lang.Class<T> clazz)
AttributeInfo
cast to T
given its index.
If index
is less than 0
, or greater than or equal to getAttributeInfoCount()
, an IndexOutOfBoundsException
will be thrown.
If clazz
is null
, a NullPointerException
will be thrown.
If clazz
is not assignable from the AttributeInfo
instance located at index
, an IllegalArgumentException
will be thrown.
T
- the type of the AttributeInfo
to returnindex
- the index of the AttributeInfo
clazz
- the Class
of the AttributeInfo
to returnAttributeInfo
cast to T
given its indexjava.lang.IllegalArgumentException
- thrown if, and only if, clazz
is not assignable from the AttributeInfo
instance located at index
java.lang.IndexOutOfBoundsException
- thrown if, and only if, index
is less than 0
, or greater than or equal to getAttributeInfoCount()
java.lang.NullPointerException
- thrown if, and only if, clazz
is null
public <T extends CPInfo> T getCPInfo(T cPInfo, java.lang.Class<T> clazz)
CPInfo
instance of this ClassFile
instance that is equal to cPInfo
.
If either cPInfo
or clazz
are null
, a NullPointerException
will be thrown.
If this ClassFile
instance does not contain a CPInfo
instance that is equal to cPInfo
, or clazz
is not assignable from the CPInfo
instance, an IllegalArgumentException
will be thrown.
T
- the type of the CPInfo
to returncPInfo
- the CPInfo
instance to test for equality againstclazz
- the Class
of the CPInfo
to returnCPInfo
instance of this ClassFile
instance that is equal to cPInfo
java.lang.IllegalArgumentException
- thrown if, and only if, this ClassFile
instance does not contain a CPInfo
instance that is equal to cPInfo
, or clazz
is not assignable from the CPInfo
instancejava.lang.NullPointerException
- thrown if, and only if, either cPInfo
or clazz
are null
public <T extends CPInfo> T getCPInfo(int index, java.lang.Class<T> clazz)
CPInfo
cast to T
given its index.
If index
is less than 0
, or greater than or equal to getCPInfoCount()
, an IndexOutOfBoundsException
will be thrown.
If clazz
is null
, a NullPointerException
will be thrown.
If clazz
is not assignable from the CPInfo
instance located at index
, an IllegalArgumentException
will be thrown.
T
- the type of the CPInfo
to returnindex
- the index of the CPInfo
clazz
- the Class
of the CPInfo
to returnCPInfo
cast to T
given its indexjava.lang.IllegalArgumentException
- thrown if, and only if, clazz
is not assignable from the CPInfo
instance located at index
java.lang.IndexOutOfBoundsException
- thrown if, and only if, index
is less than 0
, or greater than or equal to getCPInfoCount()
java.lang.NullPointerException
- thrown if, and only if, clazz
is null
public boolean accept(NodeHierarchicalVisitor nodeHierarchicalVisitor)
NodeHierarchicalVisitor
.
Returns the result of nodeHierarchicalVisitor.visitLeave(this)
.
If nodeHierarchicalVisitor
is null
, a NullPointerException
will be thrown.
If a RuntimeException
is thrown by the current NodeHierarchicalVisitor
, a NodeTraversalException
will be thrown with the RuntimeException
wrapped.
This implementation will:
NullPointerException
if nodeHierarchicalVisitor
is null
.NodeTraversalException
if nodeHierarchicalVisitor
throws a RuntimeException
.Node
s, if it has any.accept
in interface Node
nodeHierarchicalVisitor
- the NodeHierarchicalVisitor
to acceptnodeHierarchicalVisitor.visitLeave(this)
NodeTraversalException
- thrown if, and only if, a RuntimeException
is thrown by the current NodeHierarchicalVisitor
java.lang.NullPointerException
- thrown if, and only if, nodeHierarchicalVisitor
is null
public boolean addAttributeInfo(AttributeInfo attributeInfo)
attributeInfo
to this ClassFile
instance, if absent.
Returns true
if, and only if, attributeInfo
was added, false
otherwise.
If attributeInfo
is null
, a NullPointerException
will be thrown.
attributeInfo
- the AttributeInfo
to addtrue
if, and only if, attributeInfo
was added, false
otherwisejava.lang.NullPointerException
- thrown if, and only if, attributeInfo
is null
public boolean addCPInfo(CPInfo cPInfo)
cPInfo
to this ClassFile
instance.
Returns true
if, and only if, cPInfo
was added, false
otherwise.
If cPInfo
is null
, a NullPointerException
will be thrown.
cPInfo
- the CPInfo
to addtrue
if, and only if, cPInfo
was added, false
otherwisejava.lang.NullPointerException
- thrown if, and only if, cPInfo
is null
public boolean addFieldInfo(FieldInfo fieldInfo)
fieldInfo
to this ClassFile
instance, if absent.
Returns true
if, and only if, fieldInfo
was added, false
otherwise.
If fieldInfo
is null
, a NullPointerException
will be thrown.
fieldInfo
- the FieldInfo
to addtrue
if, and only if, fieldInfo
was added, false
otherwisejava.lang.NullPointerException
- thrown if, and only if, fieldInfo
is null
public boolean addInterface(int index)
ClassFile
instance, if absent.
Returns true
if, and only if, the interface index was added, false
otherwise.
If index
is less than or equal to 0
, an IllegalArgumentException
will be thrown.
index
- the interface index to addtrue
if, and only if, the interface index was added, false
otherwisejava.lang.IllegalArgumentException
- thrown if, and only if, index
is less than or equal to 0
public boolean addMethodInfo(MethodInfo methodInfo)
methodInfo
to this ClassFile
instance, if absent.
Returns true
if, and only if, methodInfo
was added, false
otherwise.
If methodInfo
is null
, a NullPointerException
will be thrown.
methodInfo
- the MethodInfo
to addtrue
if, and only if, methodInfo
was added, false
otherwisejava.lang.NullPointerException
- thrown if, and only if, methodInfo
is null
public boolean containsAttributeInfo(AttributeInfo attributeInfo)
true
if, and only if, this ClassFile
instance contains attributeInfo
, false
otherwise.
If attributeInfo
is null
, a NullPointerException
will be thrown.
attributeInfo
- the AttributeInfo
to checktrue
if, and only if, this ClassFile
instance contains attributeInfo
, false
otherwisejava.lang.NullPointerException
- thrown if, and only if, attributeInfo
is null
public boolean containsCPInfo(CPInfo cPInfo)
true
if, and only if, this ClassFile
instance contains cPInfo
, false
otherwise.
If cPInfo
is null
, a NullPointerException
will be thrown.
cPInfo
- the CPInfo
to checktrue
if, and only if, this ClassFile
instance contains cPInfo
, false
otherwisejava.lang.NullPointerException
- thrown if, and only if, cPInfo
is null
public boolean containsFieldInfo(FieldInfo fieldInfo)
true
if, and only if, this ClassFile
instance contains fieldInfo
, false
otherwise.
If fieldInfo
is null
, a NullPointerException
will be thrown.
fieldInfo
- the FieldInfo
to checktrue
if, and only if, this ClassFile
instance contains fieldInfo
, false
otherwisejava.lang.NullPointerException
- thrown if, and only if, fieldInfo
is null
public boolean containsMethodInfo(MethodInfo methodInfo)
true
if, and only if, this ClassFile
instance contains methodInfo
, false
otherwise.
If methodInfo
is null
, a NullPointerException
will be thrown.
methodInfo
- the MethodInfo
to checktrue
if, and only if, this ClassFile
instance contains methodInfo
, false
otherwisejava.lang.NullPointerException
- thrown if, and only if, methodInfo
is null
public boolean equals(java.lang.Object object)
object
to this ClassFile
instance for equality.
Returns true
if, and only if, object
is an instance of ClassFile
, and their respective values are equal, false
otherwise.
equals
in class java.lang.Object
object
- the Object
to compare to this ClassFile
instance for equalitytrue
if, and only if, object
is an instance of ClassFile
, and their respective values are equal, false
otherwisepublic boolean isAbstract()
true
if, and only if, ACC_ABSTRACT is set in the access_flags item of this ClassFile
instance, false
otherwise.true
if, and only if, ACC_ABSTRACT is set in the access_flags item of this ClassFile
instance, false
otherwisepublic boolean isAnnotation()
true
if, and only if, ACC_ANNOTATION is set in the access_flags item of this ClassFile
instance, false
otherwise.true
if, and only if, ACC_ANNOTATION is set in the access_flags item of this ClassFile
instance, false
otherwisepublic boolean isEnum()
true
if, and only if, ACC_ENUM is set in the access_flags item of this ClassFile
instance, false
otherwise.true
if, and only if, ACC_ENUM is set in the access_flags item of this ClassFile
instance, false
otherwisepublic boolean isFinal()
true
if, and only if, ACC_FINAL is set in the access_flags item of this ClassFile
instance, false
otherwise.true
if, and only if, ACC_FINAL is set in the access_flags item of this ClassFile
instance, false
otherwisepublic boolean isInterface()
true
if, and only if, ACC_INTERFACE is set in the access_flags item of this ClassFile
instance, false
otherwise.true
if, and only if, ACC_INTERFACE is set in the access_flags item of this ClassFile
instance, false
otherwisepublic boolean isModule()
true
if, and only if, ACC_MODULE is set in the access_flags item of this ClassFile
instance, false
otherwise.true
if, and only if, ACC_MODULE is set in the access_flags item of this ClassFile
instance, false
otherwisepublic boolean isPublic()
true
if, and only if, ACC_PUBLIC is set in the access_flags item of this ClassFile
instance, false
otherwise.true
if, and only if, ACC_PUBLIC is set in the access_flags item of this ClassFile
instance, false
otherwisepublic boolean isSuper()
true
if, and only if, ACC_SUPER is set in the access_flags item of this ClassFile
instance, false
otherwise.true
if, and only if, ACC_SUPER is set in the access_flags item of this ClassFile
instance, false
otherwisepublic boolean isSynthetic()
true
if, and only if, ACC_SYNTHETIC is set in the access_flags item of this ClassFile
instance, false
otherwise.true
if, and only if, ACC_SYNTHETIC is set in the access_flags item of this ClassFile
instance, false
otherwisepublic boolean removeAttributeInfo(AttributeInfo attributeInfo)
attributeInfo
from this ClassFile
instance, if present.
Returns true
if, and only if, attributeInfo
was removed, false
otherwise.
If attributeInfo
is null
, a NullPointerException
will be thrown.
attributeInfo
- the AttributeInfo
to removetrue
if, and only if, attributeInfo
was removed, false
otherwisejava.lang.NullPointerException
- thrown if, and only if, attributeInfo
is null
public boolean removeCPInfo(CPInfo cPInfo)
cPInfo
from this ClassFile
instance, if present.
Returns true
if, and only if, cPInfo
was removed, false
otherwise.
If cPInfo
is null
, a NullPointerException
will be thrown.
cPInfo
- the CPInfo
to removetrue
if, and only if, cPInfo
was removed, false
otherwisejava.lang.NullPointerException
- thrown if, and only if, cPInfo
is null
public boolean removeFieldInfo(FieldInfo fieldInfo)
fieldInfo
from this ClassFile
instance, if present.
Returns true
if, and only if, fieldInfo
was removed, false
otherwise.
If fieldInfo
is null
, a NullPointerException
will be thrown.
fieldInfo
- the FieldInfo
to removetrue
if, and only if, fieldInfo
was removed, false
otherwisejava.lang.NullPointerException
- thrown if, and only if, fieldInfo
is null
public boolean removeInterface(int index)
index
from this ClassFile
instance, if present.
Returns true
if, and only if, the interface index was removed, false
otherwise.
If index
is less than or equal to 0
, an IllegalArgumentException
will be thrown.
index
- the interface index to removetrue
if, and only if, the interface index was removed, false
otherwisejava.lang.IllegalArgumentException
- thrown if, and only if, index
is less than or equal to 0
public boolean removeMethodInfo(MethodInfo methodInfo)
methodInfo
from this ClassFile
instance, if present.
Returns true
if, and only if, methodInfo
was removed, false
otherwise.
If methodInfo
is null
, a NullPointerException
will be thrown.
methodInfo
- the MethodInfo
to removetrue
if, and only if, methodInfo
was removed, false
otherwisejava.lang.NullPointerException
- thrown if, and only if, methodInfo
is null
public boolean setAttributeInfo(AttributeInfo attributeInfo, int index)
attributeInfo
as the AttributeInfo
on the given index.
Returns true
if, and only if, attributeInfo
was set, false
otherwise.
If attributeInfo
is null
, a NullPointerException
will be thrown.
If index
is less than 0
, or greater than or equal to getAttributeInfoCount()
, an IndexOutOfBoundsException
will be thrown.
attributeInfo
- the AttributeInfo
to setindex
- the index of the AttributeInfo
true
if, and only if, attributeInfo
was set, false
otherwisejava.lang.IndexOutOfBoundsException
- thrown if, and only if, index
is less than 0
, or greater than or equal to getAttributeInfoCount()
java.lang.NullPointerException
- thrown if, and only if, attributeInfo
is null
public boolean setCPInfo(CPInfo cPInfo, int index)
cPInfo
as the CPInfo
on the given index.
Returns true
if, and only if, cPInfo
is not an instance of ConstantUnreachableInfo
and it was set, false
otherwise.
If cPInfo
is null
, a NullPointerException
will be thrown.
If index
is less than 0
, or greater than or equal to getCPInfoCount()
, an IndexOutOfBoundsException
will be thrown.
cPInfo
- the CPInfo
to setindex
- the index of the CPInfo
true
if, and only if, cPInfo
is not an instance of ConstantUnreachableInfo
and it was set, false
otherwisejava.lang.IndexOutOfBoundsException
- thrown if, and only if, index
is less than 0
, or greater than or equal to getCPInfoCount()
java.lang.NullPointerException
- thrown if, and only if, cPInfo
is null
public boolean setFieldInfo(FieldInfo fieldInfo, int index)
fieldInfo
as the FieldInfo
on the given index.
Returns true
if, and only if, fieldInfo
was set, false
otherwise.
If fieldInfo
is null
, a NullPointerException
will be thrown.
If index
is less than 0
, or greater than or equal to getFieldInfoCount()
, an IndexOutOfBoundsException
will be thrown.
fieldInfo
- the FieldInfo
to setindex
- the index of the FieldInfo
true
if, and only if, fieldInfo
was set, false
otherwisejava.lang.IndexOutOfBoundsException
- thrown if, and only if, index
is less than 0
, or greater than or equal to getFieldInfoCount()
java.lang.NullPointerException
- thrown if, and only if, fieldInfo
is null
public boolean setMethodInfo(MethodInfo methodInfo, int index)
methodInfo
as the MethodInfo
on the given index.
Returns true
if, and only if, methodInfo
was set, false
otherwise.
If methodInfo
is null
, a NullPointerException
will be thrown.
If index
is less than 0
, or greater than or equal to getMethodInfoCount()
, an IndexOutOfBoundsException
will be thrown.
methodInfo
- the MethodInfo
to setindex
- the index of the MethodInfo
true
if, and only if, methodInfo
was set, false
otherwisejava.lang.IndexOutOfBoundsException
- thrown if, and only if, index
is less than 0
, or greater than or equal to getMethodInfoCount()
java.lang.NullPointerException
- thrown if, and only if, methodInfo
is null
public int getAccessFlags()
ClassFile
instance.ClassFile
instancepublic int getAttributeInfoCount()
AttributeInfo
s currently added.AttributeInfo
s currently addedpublic int getCPInfoCount()
CPInfo
s currently added.CPInfo
s currently addedpublic int getFieldInfoCount()
FieldInfo
s currently added.FieldInfo
s currently addedpublic int getInterfaceCount()
public int getMagic()
ClassFile
instance.ClassFile
instancepublic int getMajorVersion()
ClassFile
instance.ClassFile
instancepublic int getMethodInfoCount()
MethodInfo
s currently added.MethodInfo
s currently addedpublic int getMinorVersion()
ClassFile
instance.ClassFile
instancepublic int getSuperClass()
ClassFile
instance.ClassFile
instancepublic int getThisClass()
ClassFile
instance.ClassFile
instancepublic int hashCode()
ClassFile
instance.hashCode
in class java.lang.Object
ClassFile
instancepublic int indexOf(CPInfo cPInfo)
cPInfo
in the constant_pool of this ClassFile
instance, or -1
if it is an instance of ConstantUnreachableInfo
or it does not exist.
If cPInfo
is null
, a NullPointerException
will be thrown.
cPInfo
- the CPInfo
to get the index of in this ClassFile
instancecPInfo
in the constant_pool of this ClassFile
instance, or -1
if it is an instance of ConstantUnreachableInfo
or it does not existjava.lang.NullPointerException
- thrown if, and only if, cPInfo
is null
public void setAbstract(boolean isAbstract)
This method turns off the following access flags, if given a parameter argument that is set to true
:
This method turns off the following access flags, if given a parameter argument that is set to false
:
isAbstract
- true
to add the access flag ACC_ABSTRACTpublic void setAccessFlags(int accessFlags)
ClassFile
instance.accessFlags
- the access_flags to setpublic void setAnnotation(boolean isAnnotation)
This method turns off the following access flags, if given a parameter argument that is set to true
:
This method turns on the following access flags, if given a parameter argument that is set to true
:
isAnnotation
- true
to add the access flag ACC_ANNOTATIONpublic void setEnum(boolean isEnum)
This method turns off the following access flags, if given a parameter argument that is set to true
:
isEnum
- true
to add the access flag ACC_ENUMpublic void setFinal(boolean isFinal)
This method turns off the following access flags, if given a parameter argument that is set to true
:
isFinal
- true
to add the access flag ACC_FINALpublic void setInterface(boolean isInterface)
This method turns off the following access flags, if given a parameter argument that is set to true
:
This method turns on the following access flags, if given a parameter argument that is set to true
:
This method turns off the following access flags, if given a parameter argument that is set to false
:
isInterface
- true
to add the access flag ACC_INTERFACEpublic void setMajorVersion(int majorVersion)
ClassFile
instance.
If majorVersion
is less than 0
, an IllegalArgumentException
will be thrown.
majorVersion
- the new major_versionjava.lang.IllegalArgumentException
- thrown if, and only if, majorVersion
is less than 0
public void setMinorVersion(int minorVersion)
ClassFile
instance.
If minorVersion
is less than 0
, an IllegalArgumentException
will be thrown.
minorVersion
- the new minor_versionjava.lang.IllegalArgumentException
- thrown if, and only if, minorVersion
is less than 0
public void setModule(boolean isModule)
This method turns off the following access flags, if given a parameter argument that is set to true
:
isModule
- true
to add the access flag ACC_MODULEpublic void setPublic(boolean isPublic)
This method turns off the following access flags, if given a parameter argument that is set to true
:
isPublic
- true
to add the access flag ACC_PUBLICpublic void setSuper(boolean isSuper)
This method turns off the following access flags, if given a parameter argument that is set to true
:
isSuper
- true
to add the access flag ACC_SUPERpublic void setSuperClass(int superClass)
ClassFile
instance.
If superClass
is less than 0
, an IllegalArgumentException
will be thrown.
superClass
- the new super_class for this ClassFile
instancejava.lang.IllegalArgumentException
- thrown if, and only if, superClass
is less than 0
public void setSynthetic(boolean isSynthetic)
This method turns off the following access flags, if given a parameter argument that is set to true
:
isSynthetic
- true
to add the access flag ACC_SYNTHETICpublic void setThisClass(int thisClass)
ClassFile
instance.
If thisClass
is less than or equal to 0
, an IllegalArgumentException
will be thrown.
thisClass
- the new this_class for this ClassFile
instancejava.lang.IllegalArgumentException
- thrown if, and only if, thisClass
is less than or equal to 0
public static ClassFile newInstance()
ClassFile
instance.ClassFile
instance