CtClass represents a class.
It is obtained from ClassPool.
ClassPool#get(String)
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class |
| Modifier and Type | Field and Description |
|---|---|
| public static CtClass | booleanType
The |
| public static CtClass | byteType
The |
| public static CtClass | charType
The |
| public static String | debugDump
If the value of this field is not null, then all class files modified by Javassist are saved under the directory specified by this variable. |
| public static CtClass | doubleType
The |
| public static CtClass | floatType
The |
| public static CtClass | intType
The |
| pack-priv static final String | |
| public static CtClass | longType
The |
| pack-priv static CtClass[] | |
| protected String | |
| public static CtClass | shortType
The |
| public static final String | version
The version number of this release. |
| public static CtClass | voidType
The |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public void | |
| public void | addField(CtField f, CtField.
specifies the initial value of the field. initAdds a field with an initial value. |
| public void | |
| public void | |
| pack-priv void | |
| pack-priv void | |
| public void | debugWriteFile()
Writes a class file as |
| public void | debugWriteFile(String
it must end without a directory separator. directoryName)Writes a class file as |
| public void | |
| public void | |
| protected void | |
| public void | |
| public AccessorMaker | |
| public Object | Returns: the annotation if found, otherwisenull.the annotation type. clz)Returns the annotation if the class has the specified annotation type. |
| public Object[] | Returns: an array of annotation-type objects.Returns the annotations associated with this class. |
| public byte[] | |
| public Object[] | Returns: an array of annotation-type objects.Returns the annotations associated with this class. |
| public ClassFile | |
| public ClassFile | |
| public CtConstructor | |
| public ClassPool | |
| public CtClass | getComponentType()
If this object represents an array, this method returns the component type of the array. |
| public CtConstructor | getConstructor(String
method descriptor desc)Returns the constructor with the given signature, which is represented by a character string called method descriptor. |
| public CtConstructor[] | getConstructors()
Returns an array containing |
| public CtBehavior[] | |
| public CtClass[] | |
| public CtConstructor | getDeclaredConstructor(CtClass[]
parameter types. params)Returns a constructor receiving the specified parameters. |
| public CtConstructor[] | |
| public CtField | getDeclaredField(String name)
Retrieves the field with the specified name among the fields declared in the class. |
| public CtField | getDeclaredField(String
the field name. name, String the type descriptor of the field. It is available by
desc)CtField#getSignature().Retrieves the field with the specified name and type among the fields declared in the class. |
| public CtField[] | |
| public CtMethod | getDeclaredMethod(String
method name name, CtClass[] parameter types params)Retrieves the method with the specified name and parameter types among the methods declared in the class. |
| public CtMethod | getDeclaredMethod(String name)
Retrieves the method with the specified name among the methods declared in the class. |
| public CtMethod[] | |
| public CtMethod[] | getDeclaredMethods(String
method name. name)Retrieves methods with the specified name among the methods declared in the class. |
| public CtClass | Returns: null if this class is a top-level class or an anonymous class.If this class is a member class or interface of another class, then the class enclosing this class is returned. |
| public CtBehavior | Returns: null if this class is not a local class or an anonymous class.Returns the immediately enclosing method of this class. |
| public final CtMethod | Returns: null if this class is not a local class or an anonymous class.
Deprecated
The enclosing method might be a constructor.
Use
getEnclosingBehavior().
Returns the immediately enclosing method of this class. |
| public CtField | |
| public CtField | getField(String
the field name. name, String the type descriptor of the field. It is available by
desc)CtField#getSignature().Returns the field with the specified name and type. |
| pack-priv CtField | |
| public CtField[] | getFields()
Returns an array containing |
| public String | Returns: null if the generic signature is not included.Returns the generic signature of the class. |
| public CtClass[] | getInterfaces()
Obtains the class objects representing the interfaces implemented by the class or, if this object represents an interface, the interfaces extended by that interface. |
| public CtMethod | |
| public CtMethod[] | getMethods()
Returns an array containing |
| public int | |
| public String | |
| public CtClass[] | |
| public final String | |
| public synchronized Collection | Returns: aCollection<String> object.Returns a collection of the names of all the classes referenced in this class. |
| public final String | |
| public CtClass | |
| public URL | |
| public boolean | Returns: true if the annotation is found, otherwise false.the annotation type. annotationType)Returns true if the class has the specified annotation type. |
| public boolean | Returns: true if the annotation is found, otherwise false.the name of annotation type. annotationTypeName)Returns true if the class has the specified annotation type. |
| pack-priv void | |
| public void | instrument(CodeConverter
specifies how to modify. converter)Applies the given converter to all methods and constructors declared in the class. |
| public void | instrument(ExprEditor
specifies how to modify. editor)Modifies the bodies of all methods and constructors declared in the class. |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | isFrozen()
Returns true if the class has been loaded or written out and thus it cannot be modified any more. |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | isPrimitive()
Returns |
| public static void | |
| public CtConstructor | |
| protected DataOutputStream | |
| public CtClass | makeNestedClass(String
the simple name of the nested class. name, boolean true if the nested class is static. isStatic)Makes a new public nested class. |
| public String | |
| public void | prune()
Discards unnecessary attributes, in particular,
|
| public void | rebuildClassFile()
If this method is called, the class file will be
rebuilt when it is finally generated by
|
| public void | |
| public void | |
| public void | |
| public void | replaceClassName(String
replaced class name oldName, String substituted class name newName)Substitutes |
| public void | replaceClassName(ClassMap
the hashtable associating replaced class names
with substituted names. map)Changes class names appearing in the class file according to the
given |
| public void | |
| public void | |
| public void | setInterfaces(CtClass[]
a list of the list)CtClass objects
representing interfaces, or
null if the class implements
no interfaces.Sets implemented interfaces. |
| public void | |
| public void | |
| public void | |
| public boolean | Returns: the previous status of pruning. true if pruning is already stopped.disallow pruning if true. Otherwise, allow. stop)Disallows (or allows) automatically pruning this |
| public boolean | subclassOf(CtClass superclass)
Determines whether the class directly or indirectly extends the given class. |
| public boolean | |
| public byte[] | |
| public void | toBytecode(DataOutputStream
the output stream that a class file is written to. out)Converts this class to a class file. |
| public Class | |
| public Class | |
| public Class | toClass(MethodHandles.
used when loading the class. It has to have
an access right to define a new class. lookupConverts this class to a |
| public Class | toClass(ClassLoader
the class loader used to load this class.
If it is null, the class loader returned by
loader, ProtectionDomain ClassPool#getClassLoader() is used.the protection domain that the class belongs to.
If it is null, the default domain created
by domain)java.lang.ClassLoader is used.Converts this class to a |
| public final Class | toClass(ClassLoader loader)
Deprecated
Replaced by
toClass(ClassLoader, ProtectionDomain)
Converts this class to a |
| public String | |
| public void | |
| public void |