| java.lang.Object gnu.bytecode.Type gnu.bytecode.ObjectType gnu.bytecode.ClassType
All known Subclasses: gnu.expr.PairClassType,
Method Summary | |
public Field | addField() Add a new field to this class. | public Field | addField(String name) Add a new field to this class, and name the field. | final public Field | addField(String name, Type type) | final public Field | addField(String name, Type type, int flags) | public void | addFields() Use reflection to add all the declared fields of this class.
Does not add private or package-private fields.
Does not check for duplicate (already-known) fields.
Is not thread-safe if another thread may access this ClassType. | public void | addInterface(ClassType newInterface) Add an interface to the list of implemented interfaces. | Method | addMethod() | public Method | addMethod(String name) | public Method | addMethod(String name, int flags) | public Method | addMethod(String name, Type[] arg_types, Type return_type, int flags) | public Method | addMethod(String name, int flags, Type[] arg_types, Type return_type) Add a method to this ClassType.
If an existing method matches, return that. | public Method | addMethod(String name, String signature, int flags) | public void | addMethods(Class clas) Use reflection to add all the declared methods of this class.
Does not add constructors nor private or package-private methods.
Does not check for duplicate (already-known) methods.
Parameters: clas - should be the same as getReflectClass(). | public void | cleanupAfterCompilation() Clear various object references, to help garbage collection. | public int | compare(Type other) | final public int | countMethods(Filter filter, int searchSupers) Count methods matching a given filter. | public void | doFixups() Do various fixups after generating code but before we can write it out.
This includes assigning constant pool indexes where needed,
finalizing labels, etc. | final public Attribute | getAttributes() | public short | getClassfileMajorVersion() | public short | getClassfileMinorVersion() | final public CpoolEntry | getConstant(int i) | final public ConstantPool | getConstants() | public Field | getDeclaredField(String name) Find a field with the given name declared in this class. | public Method | getDeclaredMethod(String name, Type[] arg_types) Look for a matching method. | public Method | getDeclaredMethod(String name, int argCount) Get a method with matching name and number of arguments. | final public synchronized Method | getDeclaredMethods() | public Field | getField(String name, int mask) Find a field with the given name declared in this class or its ancestors.
Parameters: name - the name of the field. Parameters: 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(String name) Find a field with the given name declared in this class or its ancestors. | final public int | getFieldCount() | final public synchronized Field | getFields() Get the fields of this class. | public synchronized ClassType[] | getInterfaces() | public Method[] | getMatchingMethods(String name, Type[] paramTypes, int flags) | public Method | getMethod(java.lang.reflect.Method method) Add a method to this ClassType.
If an existing method matches, return that. | public Method | getMethod(String name, Type[] arg_types) | final public int | getMethodCount() | final public Method | getMethods() Get the methods of this class. | public Method[] | getMethods(Filter filter, boolean searchSupers) | public Method[] | getMethods(Filter filter, int searchSupers) Get methods matching a given filter. | public int | getMethods(Filter filter, int searchSupers, Method[] result, int offset) Helper to get methods satisfying a filtering predicate. | public int | getMethods(Filter filter, int searchSupers, Vector result, String context) Helper to get methods satisfying a filtering predicate.
Parameters: filter - to select methods to return Parameters: searchSupers - 0 if only current class should be searched,1 if superclasses should also be searched,2 if super-interfaces should also be searched Parameters: result - Vector to add selected methods in Parameters: context - If non-null, skip if class not visible in named package. | final public int | getModifiers() Return the modifiers (access flags) for this class. | public ClassType | getOuterLinkType() | public String | getPackageName() | public ClassType | getSuperclass() | final public boolean | hasOuterLink() | final public boolean | implementsInterface(ClassType iface) True if this class/interface implements the interface iface. | public boolean | isAccessible(ClassType declaring, int modifiers) Check if a component is accessible from this class. | final public boolean | isInterface() | final public boolean | isSubclass(String cname) A more efficient version of isSubclass(ClassType.make(cname)). | final public boolean | isSubclass(ClassType other) | public static ClassType | make(String name) Find a ClassType with the given name, or create a new one.
Use this for "library classes", where you need the field/method types,
but not one where you are about to generate code for.
Parameters: name - the name of the class (e..g. | public static ClassType | make(String name, ClassType superClass) | public void | readExternal(ObjectInput in) | public Object | readResolve() | final public void | setAttributes(Attribute attributes) | public void | setClassfileVersion(int major, int minor) | public void | setClassfileVersionJava5() | final public void | setInterface(boolean val) | public void | setInterfaces(ClassType[] interfaces) | final public void | setModifiers(int flags) Set the modifiers (access flags) for this class. | public void | setName(String name) Sets the name of the class being defined in this classfile. | final public Field | setOuterLink(ClassType outer) Note that this class needs an other link ("this$0") field. | public void | setSourceFile(String name) Set the name of the SourceFile associated with this class. | public void | setStratum(String stratum) Create a SourceDebugExtAttr , if needed, and
set the "stratum". | public void | setSuper(String name) Set the superclass of the is class. | public void | setSuper(ClassType superClass) | public String | toString() | public static byte[] | to_utf8(String str) Convert a String to a Utf8 byte array.
Parameters: str - the input String. | public void | writeExternal(ObjectOutput out) | public byte[] | writeToArray() | public void | writeToFile(String filename) | public void | writeToFile() | public void | writeToStream(OutputStream stream) |
Code_name_index | int Code_name_index(Code) | | Constant pool index of "Code".
|
ConstantValue_name_index | int ConstantValue_name_index(Code) | | Constant pool index of "ConstantValue".
|
LineNumberTable_name_index | int LineNumberTable_name_index(Code) | | Constant pool index of "LineNumberTable".
|
LocalVariableTable_name_index | int LocalVariableTable_name_index(Code) | | Constant pool index of "LocalVariableTable".
|
access_flags | public int access_flags(Code) | | |
classfileFormatVersion | int classfileFormatVersion(Code) | | |
emitDebugInfo | boolean emitDebugInfo(Code) | | |
fields_count | int fields_count(Code) | | |
interfaceIndexes | int[] interfaceIndexes(Code) | | |
methods_count | int methods_count(Code) | | |
superClass | ClassType superClass(Code) | | The super (base) class of the current class.
X.superClass == null means the superClass has not been specified,
and defaults to java.lang.Object.
|
superClassIndex | int superClassIndex(Code) | | The constant pool index of the superClass, or -1 if unassigned.
|
thisClassIndex | int thisClassIndex(Code) | | |
ClassType | public ClassType()(Code) | | |
addField | public Field addField()(Code) | | Add a new field to this class.
|
addField | public Field addField(String name)(Code) | | Add a new field to this class, and name the field.
Parameters: name - the name of the new field |
addFields | public void addFields()(Code) | | Use reflection to add all the declared fields of this class.
Does not add private or package-private fields.
Does not check for duplicate (already-known) fields.
Is not thread-safe if another thread may access this ClassType.
|
addInterface | public void addInterface(ClassType newInterface)(Code) | | Add an interface to the list of implemented interfaces.
|
addMethod | public Method addMethod(String name, int flags, Type[] arg_types, Type return_type)(Code) | | Add a method to this ClassType.
If an existing method matches, return that. Otherwise, create
a new one.
In contrast, the other addMethod methods always create new Methods.
|
addMethods | public void addMethods(Class clas)(Code) | | Use reflection to add all the declared methods of this class.
Does not add constructors nor private or package-private methods.
Does not check for duplicate (already-known) methods.
Parameters: clas - should be the same as getReflectClass(). |
cleanupAfterCompilation | public void cleanupAfterCompilation()(Code) | | Clear various object references, to help garbage collection.
|
countMethods | final public int countMethods(Filter filter, int searchSupers)(Code) | | Count methods matching a given filter.
Parameters: filter - to select methods to return Parameters: searchSupers - 0 if only current class should be searched,1 if superclasses should also be searched,2 if super-interfaces should also be search number of methods that match |
doFixups | public void doFixups()(Code) | | Do various fixups after generating code but before we can write it out.
This includes assigning constant pool indexes where needed,
finalizing labels, etc.
|
getClassfileMajorVersion | public short getClassfileMajorVersion()(Code) | | |
getClassfileMinorVersion | public short getClassfileMinorVersion()(Code) | | |
getDeclaredField | public Field getDeclaredField(String name)(Code) | | Find a field with the given name declared in this class.
the matching field, or null if there is no such field. |
getDeclaredMethod | public Method getDeclaredMethod(String name, Type[] arg_types)(Code) | | Look for a matching method.
Parameters: name - method name Parameters: arg_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. |
getDeclaredMethod | public Method getDeclaredMethod(String name, int argCount)(Code) | | Get a method with matching name and number of arguments.
|
getDeclaredMethods | final public synchronized Method getDeclaredMethods()(Code) | | |
getField | public Field getField(String name, int mask)(Code) | | Find a field with the given name declared in this class or its ancestors.
Parameters: name - the name of the field. Parameters: mask - of match a field whose modifiers has one of these bits set.Howeve, if mask is -1, ignore the access flags. the matching field, or null if there is no such field. |
getField | public Field getField(String name)(Code) | | Find a field with the given name declared in this class or its ancestors.
the matching field, or null if there is no such field. |
getFieldCount | final public int getFieldCount()(Code) | | |
getFields | final public synchronized Field getFields()(Code) | | Get the fields of this class.
|
getInterfaces | public synchronized ClassType[] getInterfaces()(Code) | | the interfaces this class is declared to implement(not those inherited from its superclass/superinterfaces). |
getMethodCount | final public int getMethodCount()(Code) | | |
getMethods | final public Method getMethods()(Code) | | Get the methods of this class.
|
getMethods | public Method[] getMethods(Filter filter, int searchSupers)(Code) | | Get methods matching a given filter.
Parameters: filter - to select methods to return Parameters: searchSupers - 0 if only current class should be searched,1 if superclasses should also be searched,2 if super-interfaces should also be searched a fresh array containing the methods satisfying the filter |
getMethods | public int getMethods(Filter filter, int searchSupers, Method[] result, int offset)(Code) | | Helper to get methods satisfying a filtering predicate.
Parameters: filter - to select methods to return Parameters: searchSupers - 0 if only current class should be searched,1 if superclasses should also be searched,2 if super-interfaces should also be searched Parameters: result - array to place selected methods in Parameters: offset - start of where in result to place result number of methods placed in result array |
getMethods | public int getMethods(Filter filter, int searchSupers, Vector result, String context)(Code) | | Helper to get methods satisfying a filtering predicate.
Parameters: filter - to select methods to return Parameters: searchSupers - 0 if only current class should be searched,1 if superclasses should also be searched,2 if super-interfaces should also be searched Parameters: result - Vector to add selected methods in Parameters: context - If non-null, skip if class not visible in named package. number of methods placed in result array |
getModifiers | final public int getModifiers()(Code) | | Return the modifiers (access flags) for this class.
|
hasOuterLink | final public boolean hasOuterLink()(Code) | | |
implementsInterface | final public boolean implementsInterface(ClassType iface)(Code) | | True if this class/interface implements the interface iface.
|
isAccessible | public boolean isAccessible(ClassType declaring, int modifiers)(Code) | | Check if a component is accessible from this class.
Parameters: declaring - the class containing the component (a field, method,or inner class) Parameters: modifiers - the access flags of the component true if the specified component can be accessed from this class. |
isInterface | final public boolean isInterface()(Code) | | |
isSubclass | final public boolean isSubclass(String cname)(Code) | | A more efficient version of isSubclass(ClassType.make(cname)).
Does not cause the named class be loaded if it hasn't been.
Parameters: cname - a class name - cannot be an interface name |
make | public static ClassType make(String name)(Code) | | Find a ClassType with the given name, or create a new one.
Use this for "library classes", where you need the field/method types,
but not one where you are about to generate code for.
Parameters: name - the name of the class (e..g. "java.lang.String"). |
setClassfileVersion | public void setClassfileVersion(int major, int minor)(Code) | | |
setClassfileVersionJava5 | public void setClassfileVersionJava5()(Code) | | |
setInterface | final public void setInterface(boolean val)(Code) | | |
setModifiers | final public void setModifiers(int flags)(Code) | | Set the modifiers (access flags) for this class.
|
setName | public void setName(String name)(Code) | | Sets the name of the class being defined in this classfile.
Parameters: name - the name to give to the class |
setOuterLink | final public Field setOuterLink(ClassType outer)(Code) | | Note that this class needs an other link ("this$0") field.
This is only allowed if !isExisting().
Adjust any existing "" methods to take the extra
implicit parameter.
Parameters: outer - the outer class |
setSourceFile | public void setSourceFile(String name)(Code) | | Set the name of the SourceFile associated with this class.
|
setStratum | public void setStratum(String stratum)(Code) | | Create a SourceDebugExtAttr , if needed, and
set the "stratum". The stratum is typically a programming language
such as "JSP", "Scheme", or "Java" (the default).
|
setSuper | public void setSuper(String name)(Code) | | Set the superclass of the is class.
Parameters: name - name of super class, or null if this is "Object". |
to_utf8 | public static byte[] to_utf8(String str)(Code) | | Convert a String to a Utf8 byte array.
Parameters: str - the input String. the input encoded as a utf8 byte array. |
writeToArray | public byte[] writeToArray()(Code) | | |
|
|