|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object gnu.bytecode.Type gnu.bytecode.ObjectType gnu.bytecode.ClassType
public class ClassType
Field Summary | |
---|---|
Method |
constructor
|
static int |
JDK_1_1_VERSION
|
static int |
JDK_1_2_VERSION
|
static int |
JDK_1_3_VERSION
|
static int |
JDK_1_4_VERSION
|
static int |
JDK_1_5_VERSION
|
static int |
JDK_1_6_VERSION
|
static int |
JDK_1_7_VERSION
|
static ClassType[] |
noClasses
|
Fields inherited from class gnu.bytecode.ObjectType |
---|
flags |
Constructor Summary | |
---|---|
ClassType()
|
|
ClassType(java.lang.String class_name)
|
Method Summary | |
---|---|
Field |
addField()
Add a new field to this class. |
Field |
addField(java.lang.String name)
Add a new field to this class, and name the field. |
Field |
addField(java.lang.String name,
Type type)
|
Field |
addField(java.lang.String name,
Type type,
int flags)
|
void |
addFields()
Use reflection to add all the declared fields of this class. |
void |
addInterface(ClassType newInterface)
Add an interface to the list of implemented interfaces. |
void |
addMemberClass(ClassType member)
|
void |
addMemberClasses()
|
Method |
addMethod(java.lang.reflect.Constructor method)
|
Method |
addMethod(java.lang.reflect.Method method)
|
Method |
addMethod(java.lang.String name)
|
Method |
addMethod(java.lang.String name,
int flags)
|
Method |
addMethod(java.lang.String name,
int flags,
Type[] arg_types,
Type return_type)
Add a method to this ClassType. |
Method |
addMethod(java.lang.String name,
java.lang.String signature,
int flags)
|
Method |
addMethod(java.lang.String name,
Type[] arg_types,
Type return_type,
int flags)
|
void |
addMethods(java.lang.Class clas)
Use reflection to add all the declared methods of this class. |
void |
addModifiers(int flags)
|
void |
cleanupAfterCompilation()
Clear various object references, to help garbage collection. |
int |
compare(Type other)
Return a numeric code showing "subtype" relationship: 1: if other is a pure subtype of this; 0: if has the same values; -1: if this is a pure subtype of other; -2: if they have values in common but neither is a subtype of the other; -3: if the types have no values in common. |
int |
countMethods(Filter filter,
int searchSupers)
Count methods matching a given filter. |
void |
doFixups()
Do various fixups after generating code but before we can write it out. |
Attribute |
getAttributes()
Get the (first) Attribute of this container. |
short |
getClassfileMajorVersion()
|
short |
getClassfileMinorVersion()
|
int |
getClassfileVersion()
|
CpoolEntry |
getConstant(int i)
|
ConstantPool |
getConstants()
|
ClassType |
getDeclaredClass(java.lang.String simpleName)
|
Field |
getDeclaredField(java.lang.String name)
Find a field with the given name declared in this class. |
Method |
getDeclaredMethod(java.lang.String name,
int argCount)
Get a method with matching name and number of arguments. |
Method |
getDeclaredMethod(java.lang.String name,
Type[] arg_types)
Look for a matching method. |
Method |
getDeclaredMethods()
|
ClassType |
getDeclaringClass()
|
Member |
getEnclosingMember()
|
Field |
getField(java.lang.String name)
Find a field with the given name declared in this class or its ancestors. |
Field |
getField(java.lang.String name,
int mask)
Find a field with the given name declared in this class or its ancestors. |
int |
getFieldCount()
|
Field |
getFields()
Get the fields of this class. |
ClassType[] |
getInterfaces()
|
Method[] |
getMatchingMethods(java.lang.String name,
Type[] paramTypes,
int flags)
|
Method |
getMethod(java.lang.reflect.Method method)
Add a method to this ClassType. |
Method |
getMethod(java.lang.String name,
Type[] arg_types)
|
int |
getMethodCount()
|
Method |
getMethods()
Get the methods of this class. |
Method[] |
getMethods(Filter filter,
boolean searchSupers)
|
Method[] |
getMethods(Filter filter,
int searchSupers)
Get methods matching a given filter. |
int |
getMethods(Filter filter,
int searchSupers,
Method[] result,
int offset)
Deprecated. |
int |
getMethods(Filter filter,
int searchSupers,
java.util.Vector result,
java.lang.String context)
Helper to get methods satisfying a filtering predicate. |
int |
getModifiers()
Return the modifiers (access flags) for this class. |
ClassType |
getOuterLinkType()
|
java.lang.String |
getPackageName()
|
java.lang.String |
getSimpleName()
|
boolean |
getStaticFlag()
|
ClassType |
getSuperclass()
|
boolean |
hasOuterLink()
|
boolean |
implementsInterface(ClassType iface)
True if this class/interface implements the interface iface. |
boolean |
isAccessible(ClassType declaring,
int modifiers)
Check if a component is accessible from this class. |
boolean |
isInterface()
|
boolean |
isSubclass(ClassType other)
|
boolean |
isSubclass(java.lang.String cname)
A more efficient version of isSubclass(ClassType.make(cname)). |
static ClassType |
make(java.lang.String name)
Find a ClassType with the given name, or create a new one. |
static ClassType |
make(java.lang.String name,
ClassType superClass)
|
void |
readExternal(java.io.ObjectInput in)
|
java.lang.Object |
readResolve()
|
void |
setAttributes(Attribute attributes)
Set the (list of) Attributes of this container. |
void |
setClassfileVersion(int code)
|
void |
setClassfileVersion(int major,
int minor)
|
void |
setClassfileVersionJava5()
|
void |
setEnclosingMember(Member member)
|
void |
setInterface(boolean val)
|
void |
setInterfaces(ClassType[] interfaces)
|
void |
setModifiers(int flags)
Set the modifiers (access flags) for this class. |
void |
setName(java.lang.String name)
Sets the name of the class being defined in this classfile. |
Field |
setOuterLink(ClassType outer)
Note that this class needs an other link ("this$0") field. |
void |
setSourceFile(java.lang.String name)
Set the name of the SourceFile associated with this class. |
void |
setStratum(java.lang.String stratum)
Create a SourceDebugExtAttr , if needed, and
set the "stratum". |
void |
setSuper(ClassType superClass)
|
void |
setSuper(java.lang.String name)
Set the superclass of the is class. |
static byte[] |
to_utf8(java.lang.String str)
Convert a String to a Utf8 byte array. |
java.lang.String |
toString()
|
void |
writeExternal(java.io.ObjectOutput out)
|
byte[] |
writeToArray()
|
void |
writeToFile()
|
void |
writeToFile(java.lang.String filename)
|
void |
writeToStream(java.io.OutputStream stream)
|
Methods inherited from class gnu.bytecode.ObjectType |
---|
coerceFromObject, emitCoerceFromObject, getContextClass, getImplementationType, getInternalName, getReflectClass, isExisting, isInstance, promote, setExisting |
Methods inherited from class gnu.bytecode.Type |
---|
coerceToObject, emitCoerceToObject, emitIsInstance, getName, getSignature, getSize, getSizeInWords, getType, hashCode, isMoreSpecific, isSubtype, isValidJavaTypeName, isVoid, lookupType, lowestCommonSuperType, make, printSignature, registerTypeForClass, setReflectClass, setSignature, signatureLength, signatureLength, signatureToName, signatureToPrimitive, signatureToType, signatureToType, swappedCompareResult |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface gnu.bytecode.Member |
---|
getName |
Field Detail |
---|
public static final int JDK_1_1_VERSION
public static final int JDK_1_2_VERSION
public static final int JDK_1_3_VERSION
public static final int JDK_1_4_VERSION
public static final int JDK_1_5_VERSION
public static final int JDK_1_6_VERSION
public static final int JDK_1_7_VERSION
public static final ClassType[] noClasses
public Method constructor
Constructor Detail |
---|
public ClassType()
public ClassType(java.lang.String class_name)
Method Detail |
---|
public short getClassfileMajorVersion()
public short getClassfileMinorVersion()
public void setClassfileVersion(int major, int minor)
public void setClassfileVersion(int code)
public int getClassfileVersion()
public void setClassfileVersionJava5()
public static ClassType make(java.lang.String name)
name
- the name of the class (e..g. "java.lang.String").public static ClassType make(java.lang.String name, ClassType superClass)
public final Attribute getAttributes()
AttrContainer
getAttributes
in interface AttrContainer
public final void setAttributes(Attribute attributes)
AttrContainer
setAttributes
in interface AttrContainer
public final ConstantPool getConstants()
public final CpoolEntry getConstant(int i)
public final int getModifiers()
getModifiers
in interface Member
public final boolean getStaticFlag()
getStaticFlag
in interface Member
public final void setModifiers(int flags)
public final void addModifiers(int flags)
public java.lang.String getSimpleName()
public void addMemberClass(ClassType member)
public ClassType getDeclaredClass(java.lang.String simpleName)
public ClassType getDeclaringClass()
getDeclaringClass
in interface Member
public Member getEnclosingMember()
public void setEnclosingMember(Member member)
public void addMemberClasses()
public final boolean hasOuterLink()
public ClassType getOuterLinkType()
public final Field setOuterLink(ClassType outer)
outer
- the outer classpublic boolean isAccessible(ClassType declaring, int modifiers)
declaring
- the class containing the component (a field, method,
or inner class)modifiers
- the access flags of the component
public void setName(java.lang.String name)
setName
in interface Member
setName
in class Type
name
- the name to give to the classpublic void setStratum(java.lang.String stratum)
SourceDebugExtAttr
, if needed, and
set the "stratum". The stratum is typically a programming language
such as "JSP", "Scheme", or "Java" (the default).
public void setSourceFile(java.lang.String name)
public void setSuper(java.lang.String name)
name
- name of super class, or null if this is "Object".public void setSuper(ClassType superClass)
public ClassType getSuperclass()
public java.lang.String getPackageName()
public ClassType[] getInterfaces()
public void setInterfaces(ClassType[] interfaces)
public void addInterface(ClassType newInterface)
public final boolean isInterface()
public final void setInterface(boolean val)
public final Field getFields()
public final int getFieldCount()
public Field getDeclaredField(java.lang.String name)
public Field getField(java.lang.String name, int mask)
getField
in class ObjectType
name
- the name of the field.mask
- of match a field whose modifiers has one of these bits set.
Howeve, if mask is -1, ignore the access flags.
public Field getField(java.lang.String name)
public Field addField()
public Field addField(java.lang.String name)
name
- the name of the new fieldpublic final Field addField(java.lang.String name, Type type)
public final Field addField(java.lang.String name, Type type, int flags)
public void addFields()
public final Method getMethods()
public final int getMethodCount()
public Method addMethod(java.lang.String name)
public Method addMethod(java.lang.String name, int flags)
public Method addMethod(java.lang.String name, Type[] arg_types, Type return_type, int flags)
public Method addMethod(java.lang.String name, int flags, Type[] arg_types, Type return_type)
public Method addMethod(java.lang.reflect.Method method)
public Method addMethod(java.lang.reflect.Constructor method)
public Method addMethod(java.lang.String name, java.lang.String signature, int flags)
public Method getMethod(java.lang.reflect.Method method)
public final Method getDeclaredMethods()
public final int countMethods(Filter filter, int searchSupers)
filter
- to select methods to returnsearchSupers
- 0 if only current class should be searched,
1 if superclasses should also be searched,
2 if super-interfaces should also be search
public Method[] getMethods(Filter filter, boolean searchSupers)
public Method[] getMethods(Filter filter, int searchSupers)
filter
- to select methods to returnsearchSupers
- 0 if only current class should be searched,
1 if superclasses should also be searched,
2 if super-interfaces should also be searched
public int getMethods(Filter filter, int searchSupers, Method[] result, int offset)
filter
- to select methods to returnsearchSupers
- 0 if only current class should be searched,
1 if superclasses should also be searched,
2 if super-interfaces should also be searchedresult
- array to place selected methods inoffset
- start of where in result to place result
public int getMethods(Filter filter, int searchSupers, java.util.Vector result, java.lang.String context)
getMethods
in class ObjectType
filter
- to select methods to returnsearchSupers
- 0 if only current class should be searched,
1 if superclasses should also be searched,
2 if super-interfaces should also be searchedresult
- Vector to add selected methods incontext
- If non-null, skip if class not visible in named package.
public Method getDeclaredMethod(java.lang.String name, Type[] arg_types)
name
- method namearg_types
- parameter types that must match.
Can also be null, to match any parameter type list.
Otherwise, an element of arg_types must be the same type (equals),
though a null element of arg_types is a wildcard that matches any type.public Method getDeclaredMethod(java.lang.String name, int argCount)
public Method getMethod(java.lang.String name, Type[] arg_types)
getMethod
in class ObjectType
public void addMethods(java.lang.Class clas)
clas
- should be the same as getReflectClass().public Method[] getMatchingMethods(java.lang.String name, Type[] paramTypes, int flags)
public void doFixups()
public void writeToStream(java.io.OutputStream stream) throws java.io.IOException
java.io.IOException
public void writeToFile(java.lang.String filename) throws java.io.IOException
java.io.IOException
public void writeToFile() throws java.io.IOException
java.io.IOException
public byte[] writeToArray()
public static byte[] to_utf8(java.lang.String str)
str
- the input String.
public final boolean implementsInterface(ClassType iface)
public final boolean isSubclass(java.lang.String cname)
cname
- a class name - cannot be an interface namepublic final boolean isSubclass(ClassType other)
public int compare(Type other)
Type
compare
in class ObjectType
public java.lang.String toString()
toString
in class Type
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
java.io.IOException
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
java.io.IOException
java.lang.ClassNotFoundException
public java.lang.Object readResolve() throws java.io.ObjectStreamException
java.io.ObjectStreamException
public void cleanupAfterCompilation()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |