public final class CtConstructor extends CtBehavior
isClassInitializer().
 See the super class CtBehavior as well since
 a number of useful methods are in CtBehavior.
methodInfodeclaringClass| Modifier | Constructor and Description | 
|---|---|
|   | CtConstructor(CtClass[] parameters,
             CtClass declaring)Creates a constructor with no constructor body. | 
|   | CtConstructor(CtConstructor src,
             CtClass declaring,
             ClassMap map)Creates a copy of a  CtConstructorobject. | 
| protected  | CtConstructor(MethodInfo minfo,
             CtClass declaring) | 
| Modifier and Type | Method and Description | 
|---|---|
| boolean | callsSuper()Returns true if this constructor calls a constructor
 of the super class. | 
| String | getLongName()Returns the constructor name followed by parameter types
 such as  javassist.CtConstructor(CtClass[],CtClass). | 
| String | getName()Obtains the name of this constructor. | 
| void | insertBeforeBody(String src)Inserts bytecode just after another constructor in the super class
 or this class is called. | 
| boolean | isClassInitializer()Returns true if this object represents a static initializer. | 
| boolean | isConstructor()Returns true if this object represents a constructor. | 
| boolean | isEmpty()Returns true if the constructor (or static initializer)
 is the default one. | 
| void | setBody(CtConstructor src,
       ClassMap map)Copies a constructor body from another constructor. | 
| void | setBody(String src)Sets a constructor body. | 
| CtMethod | toMethod(String name,
        CtClass declaring)Makes a copy of this constructor and converts it into a method. | 
| CtMethod | toMethod(String name,
        CtClass declaring,
        ClassMap map)Makes a copy of this constructor and converts it into a method. | 
addCatch, addCatch, addLocalVariable, addParameter, extendToString, getAnnotation, getAnnotations, getAttribute, getAvailableAnnotations, getAvailableParameterAnnotations, getExceptionTypes, getGenericSignature, getMethodInfo, getMethodInfo2, getModifiers, getParameterAnnotations, getParameterTypes, getSignature, hasAnnotation, insertAfter, insertAfter, insertAt, insertAt, insertBefore, insertParameter, instrument, instrument, setAttribute, setBody, setExceptionTypes, setGenericSignature, setModifiers, useCflowgetDeclaringClass, hasAnnotation, toString, visibleFromprotected CtConstructor(MethodInfo minfo, CtClass declaring)
public CtConstructor(CtClass[] parameters, CtClass declaring)
CtClass.addConstructor().
 The created constructor does not include a constructor body,
 which must be specified with setBody().
declaring - the class to which the created method is added.parameters - a list of the parameter typesCtClass.addConstructor(CtConstructor), 
setBody(String), 
setBody(CtConstructor,ClassMap)public CtConstructor(CtConstructor src, CtClass declaring, ClassMap map) throws CannotCompileException
CtConstructor object.
 The created constructor must be
 added to a class with CtClass.addConstructor().
 All occurrences of class names in the created constructor
 are replaced with names specified by
 map if map is not null.
 
By default, all the occurrences of the names of the class
 declaring src and the superclass are replaced
 with the name of the class and the superclass that
 the created constructor is added to.
 This is done whichever map is null or not.
 To prevent this replacement, call ClassMap.fix()
 or put() to explicitly specify replacement.
 
Note: if the .class notation (for example,
 String.class) is included in an expression, the
 Javac compiler may produce a helper method.
 Since this constructor never
 copies this helper method, the programmers have the responsiblity of
 copying it.  Otherwise, use Class.forName() in the
 expression.
src - the source method.declaring - the class to which the created method is added.map - the hashtable associating original class names
                  with substituted names.
                  It can be null.CannotCompileExceptionCtClass.addConstructor(CtConstructor), 
ClassMap.fix(String)public boolean isConstructor()
public boolean isClassInitializer()
public String getLongName()
javassist.CtConstructor(CtClass[],CtClass).getLongName in class CtBehaviorpublic String getName()
"<clinit>".public boolean isEmpty()
super() (the no-argument constructor of
 the super class).isEmpty in class CtBehaviorpublic boolean callsSuper()
                   throws CannotCompileException
this().CannotCompileExceptionpublic void setBody(String src) throws CannotCompileException
setBody in class CtBehaviorsrc - the source code representing the constructor body.
                  It must be a single statement or block.
                  If it is null, the substituted
                  constructor body does nothing except calling
                  super().CannotCompileExceptionpublic void setBody(CtConstructor src, ClassMap map) throws CannotCompileException
All occurrences of the class names in the copied body
 are replaced with the names specified by
 map if map is not null.
src - the method that the body is copied from.map - the hashtable associating original class names
                  with substituted names.
                  It can be null.CannotCompileExceptionpublic void insertBeforeBody(String src) throws CannotCompileException
src - the source code representing the inserted bytecode.
                  It must be a single statement or block.CannotCompileExceptionpublic CtMethod toMethod(String name, CtClass declaring) throws CannotCompileException
void.  The resulting method must be
 appended to the class specified by declaring.
 If this constructor is a static initializer, the resulting method takes
 no parameter.
 An occurrence of another constructor call this()
 or a super constructor call super() is
 eliminated from the resulting method. 
 
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.
name - the name of the resulting method.declaring - the class declaring the resulting method.CannotCompileExceptionpublic CtMethod toMethod(String name, CtClass declaring, ClassMap map) throws CannotCompileException
void.  The resulting method must be
 appended to the class specified by declaring.
 If this constructor is a static initializer, the resulting method takes
 no parameter.
 An occurrence of another constructor call this()
 or a super constructor call super() is
 eliminated from the resulting method. 
 
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 declaring is
 the same as the class declaring this constructor).
 If the constructor accesses a field, the class declaring the resulting method
 must also declare a field with the same name and type.
name - the name of the resulting method.declaring - the class declaring the resulting method.
                          It is normally the same as the class declaring this
                          constructor.map - the hash table associating original class names
                  with substituted names.  The original class names will be
                  replaced while making a copy.
                  map can be null.CannotCompileExceptionCopyright © 2016 Shigeru Chiba, www.javassist.org. All Rights Reserved.