Package javassist

Class CtClassType

    • Field Detail

      • wasChanged

        boolean wasChanged
      • wasFrozen

        private boolean wasFrozen
      • wasPruned

        boolean wasPruned
      • gcConstPool

        boolean gcConstPool
      • rawClassfile

        byte[] rawClassfile
      • memberCache

        private java.lang.ref.WeakReference memberCache
      • hiddenMethods

        private java.util.Hashtable hiddenMethods
      • uniqueNumberSeed

        private int uniqueNumberSeed
      • doPruning

        private boolean doPruning
      • getCount

        private int getCount
    • Constructor Detail

      • CtClassType

        CtClassType​(java.lang.String name,
                    ClassPool cp)
      • CtClassType

        CtClassType​(java.io.InputStream ins,
                    ClassPool cp)
             throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • extendToString

        protected void extendToString​(java.lang.StringBuffer buffer)
        Description copied from class: CtClass
        Implemented in subclasses to add to the CtClass.toString() result. Subclasses should put a space before each token added to the buffer.
        Overrides:
        extendToString in class CtClass
      • exToString

        private void exToString​(java.lang.StringBuffer buffer,
                                java.lang.String msg,
                                CtMember head,
                                CtMember tail)
      • getClassFile2

        public ClassFile getClassFile2()
        Description copied from class: CtClass
        Returns a class file for this class (read only). Normal applications do not need calling this method. Use getClassFile().

        The ClassFile object obtained by this method is read only. Changes to this object might not be reflected on a class file generated by toBytecode(), toClass(), etc.

        This method is available even if isFrozen() is true. However, if the class is frozen, it might be also pruned.

        Overrides:
        getClassFile2 in class CtClass
        See Also:
        CtClass.getClassFile(), CtClass.isFrozen(), CtClass.prune()
      • getClassFile3

        public ClassFile getClassFile3​(boolean doCompress)
      • compress

        void compress()
        Invoked from ClassPool#compress(). It releases the class files that have not been recently used if they are unmodified.
        Overrides:
        compress in class CtClass
      • saveClassFile

        private void saveClassFile()
        Converts a ClassFile object into a byte array for saving memory space.
      • removeClassFile

        private void removeClassFile()
      • setClassFile

        private ClassFile setClassFile​(ClassFile cf)
        Updates classfile if it is null.
      • setClassPool

        void setClassPool​(ClassPool cp)
      • isModified

        public boolean isModified()
        Description copied from class: CtClass
        Returns true if the definition of the class has been modified.
        Overrides:
        isModified in class CtClass
      • checkModify

        void checkModify()
                  throws java.lang.RuntimeException
        Overrides:
        checkModify in class CtClass
        Throws:
        java.lang.RuntimeException
      • defrost

        public void defrost()
        Description copied from class: CtClass
        Defrosts the class so that the class can be modified again.

        To avoid changes that will be never reflected, the class is frozen to be unmodifiable if it is loaded or written out. This method should be called only in a case that the class will be reloaded or written out later again.

        If defrost() will be called later, pruning must be disallowed in advance.

        Overrides:
        defrost in class CtClass
        See Also:
        CtClass.isFrozen(), CtClass.stopPruning(boolean), CtClass.detach()
      • setName

        public void setName​(java.lang.String name)
                     throws java.lang.RuntimeException
        Description copied from class: CtClass
        Sets the class name
        Overrides:
        setName in class CtClass
        Parameters:
        name - fully-qualified name
        Throws:
        java.lang.RuntimeException
      • getGenericSignature

        public java.lang.String getGenericSignature()
        Description copied from class: CtClass
        Returns the generic signature of the class.

        The generics of Java is implemented by the erasure technique. After compilation, all type parameters are dropped off from the main part of a class file. However, for reflection, the type parameters are encoded into generic signatures and attached to a class file.

        Overrides:
        getGenericSignature in class CtClass
        Returns:
        null if the generic signature is not included.
        See Also:
        SignatureAttribute.toClassSignature(String), CtMember.getGenericSignature()
      • setGenericSignature

        public void setGenericSignature​(java.lang.String sig)
        Description copied from class: CtClass
        Sets the generic signature of the class.

        The generics of Java is implemented by the erasure technique. After compilation, all type parameters are dropped off from the main part of a class file. However, for reflection, the type parameters must be encoded into generic signatures and attached to a class file.

        For example,

        class List<T> {
             T value;
             T get() { return value; }
             void set(T v) { value = v; }
         }
         

        this class is generated by the following code:

         ClassPool pool = ClassPool.getDefault();
         CtClass cc = pool.makeClass("List");
         CtClass objectClass = pool.get(CtClass.javaLangObject);
         ClassSignature cs = new ClassSignature(
                                 new TypeParameter[] { new TypeParameter("T") });
         cc.setGenericSignature(cs.encode());    // <T:Ljava/lang/Object;>Ljava/lang/Object;
        
         CtField f = new CtField(objClass, "value", cc);
         TypeVariable tvar = new TypeVariable("T");
         f.setGenericSignature(tvar.encode());   // TT;
         cc.addField(f);
        
         CtMethod m = CtNewMethod.make("public Object get(){return value;}", cc);
         MethodSignature ms = new MethodSignature(null, null, tvar, null);
         m.setGenericSignature(ms.encode());     // ()TT;
         cc.addMethod(m);
        
         CtMethod m2 = CtNewMethod.make("public void set(Object v){value = v;}", cc);
         MethodSignature ms2 = new MethodSignature(null, new Type[] { tvar },
                                                   new BaseType("void"), null);
         m2.setGenericSignature(ms2.encode());   // (TT;)V;
         cc.addMethod(m2);
        
         cc.writeFile();
         

        The generated class file is equivalent to the following:

        class List {
             Object value;
             Object get() { return value; }
             void set(Object v) { value = v; }
         }

        but it includes generic signatures for the class, the field, and the methods so that the type variable T can be accessible through reflection.

        MethodSignature is a utility class. You can directly pass the signature string to the setGenericSignature method. For the specification of the signatures, see Section 4.7.9.1 Signatures of The Java Virtual Machine Specification (Java SE 8).

        Overrides:
        setGenericSignature in class CtClass
        Parameters:
        sig - a generic signature.
        See Also:
        SignatureAttribute.ClassSignature.encode(), SignatureAttribute.MethodSignature.encode(), CtMember.setGenericSignature(String)
      • replaceClassName

        public void replaceClassName​(ClassMap classnames)
                              throws java.lang.RuntimeException
        Description copied from class: CtClass
        Changes class names appearing in the class file according to the given map.

        All the class names appearing in the class file are tested with map to determine whether each class name is replaced or not. Thus this method can be used for collecting all the class names in the class file. To do that, first define a subclass of ClassMap so that get() records all the given parameters. Then, make an instance of that subclass as an empty hash-table. Finally, pass that instance to this method. After this method finishes, that instance would contain all the class names appearing in the class file.

        Overrides:
        replaceClassName in class CtClass
        Parameters:
        classnames - the hashtable associating replaced class names with substituted names.
        Throws:
        java.lang.RuntimeException
      • replaceClassName

        public void replaceClassName​(java.lang.String oldname,
                                     java.lang.String newname)
                              throws java.lang.RuntimeException
        Description copied from class: CtClass
        Substitutes newName for all occurrences of a class name oldName in the class file.
        Overrides:
        replaceClassName in class CtClass
        Parameters:
        oldname - replaced class name
        newname - substituted class name
        Throws:
        java.lang.RuntimeException
      • isInterface

        public boolean isInterface()
        Description copied from class: CtClass
        Determines whether this object represents a class or an interface. It returns true if this object represents an interface.
        Overrides:
        isInterface in class CtClass
      • isAnnotation

        public boolean isAnnotation()
        Description copied from class: CtClass
        Determines whether this object represents an annotation type. It returns true if this object represents an annotation type.
        Overrides:
        isAnnotation in class CtClass
      • isEnum

        public boolean isEnum()
        Description copied from class: CtClass
        Determines whether this object represents an enum. It returns true if this object represents an enum.
        Overrides:
        isEnum in class CtClass
      • getModifiers

        public int getModifiers()
        Description copied from class: CtClass
        Returns the modifiers for this class, encoded in an integer. For decoding, use javassist.Modifier.

        If the class is a static nested class (a.k.a. static inner class), the returned modifiers include Modifier.STATIC.

        Overrides:
        getModifiers in class CtClass
        See Also:
        Modifier
      • setModifiers

        public void setModifiers​(int mod)
        Description copied from class: CtClass
        Sets the modifiers.

        If the class is a nested class, this method also modifies the class declaring that nested class (i.e. the enclosing class is modified).

        Overrides:
        setModifiers in class CtClass
        Parameters:
        mod - modifiers encoded by javassist.Modifier
        See Also:
        Modifier
      • hasAnnotation

        public boolean hasAnnotation​(java.lang.String annotationName)
        Description copied from class: CtClass
        Returns true if the class has the specified annotation type.
        Overrides:
        hasAnnotation in class CtClass
        Parameters:
        annotationName - the name of annotation type.
        Returns:
        true if the annotation is found, otherwise false.
      • getAnnotation

        public java.lang.Object getAnnotation​(java.lang.Class clz)
                                       throws java.lang.ClassNotFoundException
        Description copied from class: CtClass
        Returns the annotation if the class has the specified annotation type. For example, if an annotation @Author is associated with this class, an Author object is returned. The member values can be obtained by calling methods on the Author object.
        Overrides:
        getAnnotation in class CtClass
        Parameters:
        clz - the annotation type.
        Returns:
        the annotation if found, otherwise null.
        Throws:
        java.lang.ClassNotFoundException
      • getAnnotations

        public java.lang.Object[] getAnnotations()
                                          throws java.lang.ClassNotFoundException
        Description copied from class: CtClass
        Returns the annotations associated with this class. For example, if an annotation @Author is associated with this class, the returned array contains an Author object. The member values can be obtained by calling methods on the Author object.
        Overrides:
        getAnnotations in class CtClass
        Returns:
        an array of annotation-type objects.
        Throws:
        java.lang.ClassNotFoundException
        See Also:
        CtMember.getAnnotations()
      • getAvailableAnnotations

        public java.lang.Object[] getAvailableAnnotations()
        Description copied from class: CtClass
        Returns the annotations associated with this class. This method is equivalent to getAnnotations() except that, if any annotations are not on the classpath, they are not included in the returned array.
        Overrides:
        getAvailableAnnotations in class CtClass
        Returns:
        an array of annotation-type objects.
        See Also:
        CtClass.getAnnotations(), CtMember.getAvailableAnnotations()
      • getAnnotations

        private java.lang.Object[] getAnnotations​(boolean ignoreNotFound)
                                           throws java.lang.ClassNotFoundException
        Throws:
        java.lang.ClassNotFoundException
      • toAnnoType

        private static java.lang.Object toAnnoType​(Annotation anno,
                                                   ClassPool cp)
                                            throws java.lang.ClassNotFoundException
        Throws:
        java.lang.ClassNotFoundException
      • subclassOf

        public boolean subclassOf​(CtClass superclass)
        Description copied from class: CtClass
        Determines whether the class directly or indirectly extends the given class. If this class extends a class A and the class A extends a class B, then subclassof(B) returns true.

        This method returns true if the given class is identical to the class represented by this object.

        Overrides:
        subclassOf in class CtClass
      • getSuperclass

        public CtClass getSuperclass()
                              throws NotFoundException
        Description copied from class: CtClass
        Obtains the class object representing the superclass of the class. It returns null if this object represents the java.lang.Object class and thus it does not have the super class.

        If this object represents an interface, this method always returns the java.lang.Object class. To obtain the super interfaces extended by that interface, call getInterfaces().

        Overrides:
        getSuperclass in class CtClass
        Throws:
        NotFoundException
      • getInterfaces

        public CtClass[] getInterfaces()
                                throws NotFoundException
        Description copied from class: CtClass
        Obtains the class objects representing the interfaces implemented by the class or, if this object represents an interface, the interfaces extended by that interface.
        Overrides:
        getInterfaces in class CtClass
        Throws:
        NotFoundException
      • setInterfaces

        public void setInterfaces​(CtClass[] list)
        Description copied from class: CtClass
        Sets implemented interfaces. If this object represents an interface, this method sets the interfaces extended by that interface.
        Overrides:
        setInterfaces in class CtClass
        Parameters:
        list - a list of the CtClass objects representing interfaces, or null if the class implements no interfaces.
      • addInterface

        public void addInterface​(CtClass anInterface)
        Description copied from class: CtClass
        Adds an interface.
        Overrides:
        addInterface in class CtClass
        Parameters:
        anInterface - the added interface.
      • getDeclaringClass

        public CtClass getDeclaringClass()
                                  throws NotFoundException
        Description copied from class: CtClass
        If this class is a member class or interface of another class, then the class enclosing this class is returned.
        Overrides:
        getDeclaringClass in class CtClass
        Returns:
        null if this class is a top-level class or an anonymous class.
        Throws:
        NotFoundException
      • getEnclosingBehavior

        public CtBehavior getEnclosingBehavior()
                                        throws NotFoundException
        Description copied from class: CtClass
        Returns the immediately enclosing method of this class. It might be not a method but a constructor. This method works only with JDK 1.5 or later.
        Overrides:
        getEnclosingBehavior in class CtClass
        Returns:
        null if this class is not a local class or an anonymous class.
        Throws:
        NotFoundException
      • makeNestedClass

        public CtClass makeNestedClass​(java.lang.String name,
                                       boolean isStatic)
        Description copied from class: CtClass
        Makes a new public nested class. If this method is called, the CtClass, which encloses the nested class, is modified since a class file includes a list of nested classes.

        The current implementation only supports a static nested class. isStatic must be true.

        Overrides:
        makeNestedClass in class CtClass
        Parameters:
        name - the simple name of the nested class.
        isStatic - true if the nested class is static.
      • nameReplaced

        private void nameReplaced()
      • hasMemberCache

        protected CtMember.Cache hasMemberCache()
        Returns null if members are not cached.
      • makeFieldCache

        private void makeFieldCache​(CtMember.Cache cache)
      • makeBehaviorCache

        private void makeBehaviorCache​(CtMember.Cache cache)
      • getFields

        public CtField[] getFields()
        Description copied from class: CtClass
        Returns an array containing CtField objects representing all the non-private fields of the class. That array includes non-private fields inherited from the superclasses.
        Overrides:
        getFields in class CtClass
      • getFields

        private static void getFields​(java.util.ArrayList alist,
                                      CtClass cc)
      • getField

        public CtField getField​(java.lang.String name,
                                java.lang.String desc)
                         throws NotFoundException
        Description copied from class: CtClass
        Returns the field with the specified name and type. The returned field may be a private field declared in a super class or interface. Unlike Java, the JVM allows a class to have multiple fields with the same name but different types.
        Overrides:
        getField in class CtClass
        Parameters:
        name - the field name.
        desc - the type descriptor of the field. It is available by CtField.getSignature().
        Throws:
        NotFoundException
        See Also:
        CtField.getSignature()
      • getField2

        CtField getField2​(java.lang.String name,
                          java.lang.String desc)
        Overrides:
        getField2 in class CtClass
        Returns:
        null if the specified field is not found.
      • getDeclaredFields

        public CtField[] getDeclaredFields()
        Description copied from class: CtClass
        Gets all the fields declared in the class. The inherited fields are not included.

        Note: the result does not include inherited fields.

        Overrides:
        getDeclaredFields in class CtClass
      • getDeclaredField

        public CtField getDeclaredField​(java.lang.String name,
                                        java.lang.String desc)
                                 throws NotFoundException
        Description copied from class: CtClass
        Retrieves the field with the specified name and type among the fields declared in the class. Unlike Java, the JVM allows a class to have multiple fields with the same name but different types.

        Note: this method does not search the super classes.

        Overrides:
        getDeclaredField in class CtClass
        Parameters:
        name - the field name.
        desc - the type descriptor of the field. It is available by CtField.getSignature().
        Throws:
        NotFoundException
        See Also:
        CtField.getSignature()
      • getDeclaredField2

        private CtField getDeclaredField2​(java.lang.String name,
                                          java.lang.String desc)
      • getConstructors

        public CtConstructor[] getConstructors()
        Description copied from class: CtClass
        Returns an array containing CtConstructor objects representing all the non-private constructors of the class.
        Overrides:
        getConstructors in class CtClass
      • isPubCons

        private static boolean isPubCons​(CtConstructor cons)
      • getConstructor

        public CtConstructor getConstructor​(java.lang.String desc)
                                     throws NotFoundException
        Description copied from class: CtClass
        Returns the constructor with the given signature, which is represented by a character string called method descriptor. For details of the method descriptor, see the JVM specification or javassist.bytecode.Descriptor.
        Overrides:
        getConstructor in class CtClass
        Parameters:
        desc - method descriptor
        Throws:
        NotFoundException
        See Also:
        Descriptor
      • getMethods

        public CtMethod[] getMethods()
        Description copied from class: CtClass
        Returns an array containing CtMethod objects representing all the non-private methods of the class. That array includes non-private methods inherited from the superclasses.
        Overrides:
        getMethods in class CtClass
      • getMethods0

        private static void getMethods0​(java.util.HashMap h,
                                        CtClass cc)
      • getMethod

        public CtMethod getMethod​(java.lang.String name,
                                  java.lang.String desc)
                           throws NotFoundException
        Description copied from class: CtClass
        Returns the method with the given name and signature. The returned method may be declared in a super class. The method signature is represented by a character string called method descriptor, which is defined in the JVM specification.
        Overrides:
        getMethod in class CtClass
        Parameters:
        name - method name
        desc - method descriptor
        Throws:
        NotFoundException
        See Also:
        CtBehavior.getSignature(), Descriptor
      • getMethod0

        private static CtMethod getMethod0​(CtClass cc,
                                           java.lang.String name,
                                           java.lang.String desc)
      • getDeclaredMethods

        public CtMethod[] getDeclaredMethods()
        Description copied from class: CtClass
        Gets all methods declared in the class. The inherited methods are not included.
        Overrides:
        getDeclaredMethods in class CtClass
        See Also:
        CtMethod
      • getDeclaredMethods

        public CtMethod[] getDeclaredMethods​(java.lang.String name)
                                      throws NotFoundException
        Description copied from class: CtClass
        Retrieves methods with the specified name among the methods declared in the class. Multiple methods with different parameters may be returned.

        Note: this method does not search the superclasses.

        Overrides:
        getDeclaredMethods in class CtClass
        Parameters:
        name - method name.
        Throws:
        NotFoundException
      • getDeclaredMethod

        public CtMethod getDeclaredMethod​(java.lang.String name)
                                   throws NotFoundException
        Description copied from class: CtClass
        Retrieves the method with the specified name among the methods declared in the class. If there are multiple methods with the specified name, then this method returns one of them.

        Note: this method does not search the superclasses.

        Overrides:
        getDeclaredMethod in class CtClass
        Throws:
        NotFoundException
        See Also:
        CtMethod
      • getDeclaredMethod

        public CtMethod getDeclaredMethod​(java.lang.String name,
                                          CtClass[] params)
                                   throws NotFoundException
        Description copied from class: CtClass
        Retrieves the method with the specified name and parameter types among the methods declared in the class.

        Note: this method does not search the superclasses.

        Overrides:
        getDeclaredMethod in class CtClass
        Parameters:
        name - method name
        params - parameter types
        Throws:
        NotFoundException
        See Also:
        CtMethod
      • addField

        public void addField​(CtField f,
                             java.lang.String init)
                      throws CannotCompileException
        Description copied from class: CtClass
        Adds a field with an initial value.

        The CtField belonging to another CtClass cannot be directly added to this class. Only a field created for this class can be added.

        The initial value is given as an expression written in Java. Any regular Java expression can be used for specifying the initial value. The followings are examples.

         cc.addField(f, "0")               // the initial value is 0.
         cc.addField(f, "i + 1")           // i + 1.
         cc.addField(f, "new Point()");    // a Point object.
         

        Here, the type of variable cc is CtClass. The type of f is CtField.

        Note: do not change the modifier of the field (in particular, do not add or remove static to/from the modifier) after it is added to the class by addField().

        Overrides:
        addField in class CtClass
        init - an expression for the initial value.
        Throws:
        CannotCompileException
        See Also:
        CtField.Initializer.byExpr(String), CtField(CtField,CtClass)
      • addField

        public void addField​(CtField f,
                             CtField.Initializer init)
                      throws CannotCompileException
        Description copied from class: CtClass
        Adds a field with an initial value.

        The CtField belonging to another CtClass cannot be directly added to this class. Only a field created for this class can be added.

        For example,

         CtClass cc = ...;
         addField(new CtField(CtClass.intType, "i", cc),
                  CtField.Initializer.constant(1));
         

        This code adds an int field named "i". The initial value of this field is 1.

        Overrides:
        addField in class CtClass
        init - specifies the initial value of the field.
        Throws:
        CannotCompileException
        See Also:
        CtField(CtField,CtClass)
      • getAttribute

        public byte[] getAttribute​(java.lang.String name)
        Description copied from class: CtClass
        Obtains an attribute with the given name. If that attribute is not found in the class file, this method returns null.

        This is a convenient method mainly for obtaining a user-defined attribute. For dealing with attributes, see the javassist.bytecode package. For example, the following expression returns all the attributes of a class file.

         getClassFile().getAttributes()
         
        Overrides:
        getAttribute in class CtClass
        Parameters:
        name - attribute name
        See Also:
        AttributeInfo
      • setAttribute

        public void setAttribute​(java.lang.String name,
                                 byte[] data)
        Description copied from class: CtClass
        Adds a named attribute. An arbitrary data (smaller than 64Kb) can be saved in the class file. Some attribute name are reserved by the JVM. The attributes with the non-reserved names are ignored when a class file is loaded into the JVM. If there is already an attribute with the same name, this method substitutes the new one for it.

        This is a convenient method mainly for adding a user-defined attribute. For dealing with attributes, see the javassist.bytecode package. For example, the following expression adds an attribute info to a class file.

         getClassFile().addAttribute(info)
         
        Overrides:
        setAttribute in class CtClass
        Parameters:
        name - attribute name
        data - attribute value
        See Also:
        AttributeInfo
      • instrument

        public void instrument​(CodeConverter converter)
                        throws CannotCompileException
        Description copied from class: CtClass
        Applies the given converter to all methods and constructors declared in the class. This method calls instrument() on every CtMethod and CtConstructor object in the class.
        Overrides:
        instrument in class CtClass
        Parameters:
        converter - specifies how to modify.
        Throws:
        CannotCompileException
      • instrument

        public void instrument​(ExprEditor editor)
                        throws CannotCompileException
        Description copied from class: CtClass
        Modifies the bodies of all methods and constructors declared in the class. This method calls instrument() on every CtMethod and CtConstructor object in the class.
        Overrides:
        instrument in class CtClass
        Parameters:
        editor - specifies how to modify.
        Throws:
        CannotCompileException
      • prune

        public void prune()
        Description copied from class: CtClass
        Discards unnecessary attributes, in particular, CodeAttributes (method bodies) of the class, to minimize the memory footprint. After calling this method, the class is read only. It cannot be modified any more. Furthermore, toBytecode(), writeFile(), toClass(), or instrument() cannot be called. However, the method names and signatures in the class etc. are still accessible.

        toBytecode(), writeFile(), and toClass() internally call this method if automatic pruning is on.

        According to some experiments, pruning does not really reduce memory consumption. Only about 20%. Since pruning takes time, it might not pay off. So the automatic pruning is off by default.

        Overrides:
        prune in class CtClass
        See Also:
        CtClass.prune(), CtClass.stopPruning(boolean)
      • rebuildClassFile

        public void rebuildClassFile()
        Description copied from class: CtClass
        If this method is called, the class file will be rebuilt when it is finally generated by toBytecode() and writeFile(). For a performance reason, the symbol table of the class file may contain unused entries, for example, after a method or a filed is deleted. This method removes those unused entries. This removal will minimize the size of the class file.
        Overrides:
        rebuildClassFile in class CtClass
      • toBytecode

        public void toBytecode​(java.io.DataOutputStream out)
                        throws CannotCompileException,
                               java.io.IOException
        Description copied from class: CtClass
        Converts this class to a class file. Once this method is called, further modifications are not possible any more.

        This method dose not close the output stream in the end.

        Overrides:
        toBytecode in class CtClass
        Parameters:
        out - the output stream that a class file is written to.
        Throws:
        CannotCompileException
        java.io.IOException
      • dumpClassFile

        private void dumpClassFile​(ClassFile cf)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • checkPruned

        private void checkPruned​(java.lang.String method)
      • stopPruning

        public boolean stopPruning​(boolean stop)
        Description copied from class: CtClass
        Disallows (or allows) automatically pruning this CtClass object.

        Javassist can automatically prune a CtClass object when toBytecode() (or toClass(), writeFile()) is called. Since a ClassPool holds all instances of CtClass even after toBytecode() (or toClass(), writeFile()) is called, pruning may significantly save memory consumption.

        If ClassPool.doPruning is true, the automatic pruning is on by default. Otherwise, it is off. The default value of ClassPool.doPruning is false.

        Overrides:
        stopPruning in class CtClass
        Parameters:
        stop - disallow pruning if true. Otherwise, allow.
        Returns:
        the previous status of pruning. true if pruning is already stopped.
        See Also:
        CtClass.detach(), CtClass.prune(), ClassPool.doPruning
      • getHiddenMethods

        java.util.Hashtable getHiddenMethods()
      • getUniqueNumber

        int getUniqueNumber()
      • makeUniqueName

        public java.lang.String makeUniqueName​(java.lang.String prefix)
        Description copied from class: CtClass
        Makes a unique member name. This method guarantees that the returned name is not used as a prefix of any methods or fields visible in this class. If the returned name is XYZ, then any method or field names in this class do not start with XYZ.
        Overrides:
        makeUniqueName in class CtClass
        Parameters:
        prefix - the prefix of the member name.
      • notFindInArray

        private static boolean notFindInArray​(java.lang.String prefix,
                                              java.lang.String[] values)
      • makeMemberList

        private void makeMemberList​(java.util.HashMap table)