isClassInitializer().
See the super class CtBehavior as well since
a number of useful methods are in CtBehavior.
CtClass#getDeclaredConstructors(), CtClass#getClassInitializer(), CtNewConstructor
| Access | Constructor and Description |
|---|---|
| protected | |
| public | CtConstructor(CtClass[]
a list of the parameter types parameters, CtClass the class to which the created method is added. declaring)Creates a constructor with no constructor body. |
| public | CtConstructor(CtConstructor
the source method. src, CtClass the class to which the created method is added. declaring, ClassMap the hashtable associating original class names
with substituted names.
It can be map)null.Creates a copy of a |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public String | getLongName()
Implements abstract javassist. Returns the constructor name followed by parameter types
such as |
| public String | |
| pack-priv int | |
| private String | |
| public void | insertBeforeBody(String
the source code representing the inserted bytecode.
It must be a single statement or block. src)Inserts bytecode just after another constructor in the super class or this class is called. |
| public boolean | |
| public boolean | |
| public boolean | isEmpty()
Implements abstract javassist. Returns true if the constructor (or static initializer) is the default one. |
| private static void | |
| public void | setBody(String
the source code representing the constructor body.
It must be a single statement or block.
If it is src)null, the substituted
constructor body does nothing except calling
super().Overrides javassist. Sets a constructor body. |
| public void | setBody(CtConstructor
the method that the body is copied from. src, ClassMap the hashtable associating original class names
with substituted names.
It can be map)null.Copies a constructor body from another constructor. |
| public CtMethod | |
| public CtMethod | toMethod(String
the name of the resulting method. name, CtClass the class declaring the resulting method.
It is normally the same as the class declaring this
constructor. declaring, ClassMap the hash table associating original class names
with substituted names. The original class names will be
replaced while making a copy.
map)map can be null.Makes a copy of this constructor and converts it into a method. |
| CtConstructor | back to summary |
|---|---|
| protected CtConstructor(MethodInfo minfo, CtClass declaring) | |
| CtConstructor | back to summary |
|---|---|
| public CtConstructor(CtClass[] parameters, CtClass declaring) Creates a constructor with no constructor body.
The created constructor
must be added to a class with The created constructor does not include a constructor body,
which must be specified with | |
| CtConstructor | back to summary |
|---|---|
| public CtConstructor(CtConstructor src, CtClass declaring, ClassMap map) throws CannotCompileException Creates a copy of a All occurrences of class names in the created constructor
are replaced with names specified by
By default, all the occurrences of the names of the class
declaring Note if the
| |
| callsSuper | back to summary |
|---|---|
| public boolean callsSuper() throws CannotCompileException Returns true if this constructor calls a constructor
of the super class. This method returns false if it
calls another constructor of this class by | |
| getLongName | back to summary |
|---|---|
| public String getLongName() Implements abstract javassist. Returns the constructor name followed by parameter types
such as
| |
| getName | back to summary |
|---|---|
| public String getName() Implements abstract javassist. Obtains the name of this constructor.
It is the same as the simple name of the class declaring this
constructor. If this object represents a class initializer,
then this method returns
| |
| getStartPosOfBody | back to summary |
|---|---|
| pack-priv int getStartPosOfBody(CodeAttribute ca) throws CannotCompileException Overrides javassist.
| |
| getSuperclassName | back to summary |
|---|---|
| private String getSuperclassName() | |
| insertBeforeBody | back to summary |
|---|---|
| public void insertBeforeBody(String src) throws CannotCompileException Inserts bytecode just after another constructor in the super class or this class is called. It does not work if this object represents a class initializer.
| |
| isClassInitializer | back to summary |
|---|---|
| public boolean isClassInitializer() Returns true if this object represents a static initializer. | |
| isConstructor | back to summary |
|---|---|
| public boolean isConstructor() Returns true if this object represents a constructor. | |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Implements abstract javassist. Returns true if the constructor (or static initializer)
is the default one. This method returns true if the constructor
takes some arguments but it does not perform anything except
calling
| |
| removeConsCall | back to summary |
|---|---|
| private static void removeConsCall(CodeAttribute ca) throws CannotCompileException | |
| setBody | back to summary |
|---|---|
| public void setBody(String src) throws CannotCompileException Overrides javassist. Sets a constructor body. | |
| setBody | back to summary |
|---|---|
| public void setBody(CtConstructor src, ClassMap map) throws CannotCompileException Copies a constructor body from another constructor. All occurrences of the class names in the copied body
are replaced with the names specified by
| |
| toMethod | back to summary |
|---|---|
| public CtMethod toMethod(String name, CtClass declaring) throws CannotCompileException Makes a copy of this constructor and converts it into a method.
The signature of the mehtod is the same as the that of this constructor.
The return type is An occurrence of another constructor call The immediate super class of the class declaring this constructor must be also a super class of the class declaring the resulting method. If the constructor accesses a field, the class declaring the resulting method must also declare a field with the same name and type. | |
| toMethod | back to summary |
|---|---|
| public CtMethod toMethod(String name, CtClass declaring, ClassMap map) throws CannotCompileException Makes a copy of this constructor and converts it into a method.
The signature of the method is the same as the that of this constructor.
The return type is An occurrence of another constructor call The immediate super class of the class declaring this constructor
must be also a super class of the class declaring the resulting method
(this is obviously true if the second parameter
| |