/** * Sets the class name * * @param name fully-qualified name */ public void setName(String name) { checkModify(); if (name != null) qualifiedName = name; }
/** * Removes a method declared in this class. * * @param m removed method. * @throws NotFoundException if the method is not found. */ public void removeMethod(CtMethod m) throws NotFoundException { checkModify(); }
/** * Removes a field declared in this class. * * @param f removed field. * @throws NotFoundException if the field is not found. */ public void removeField(CtField f) throws NotFoundException { checkModify(); }
/** * Returns the FieldInfo representing the field in the class file. */ public FieldInfo getFieldInfo() { declaringClass.checkModify(); return fieldInfo; }
/** * Substitutes <code>newName</code> for all occurrences of a class * name <code>oldName</code> in the class file. * * @param oldName replaced class name * @param newName substituted class name */ public void replaceClassName(String oldName, String newName) { checkModify(); }
/** * Adds an interface. * * @param anInterface the added interface. */ public void addInterface(CtClass anInterface) { checkModify(); }
/** * Sets implemented interfaces. If this object represents an interface, * this method sets the interfaces extended by that interface. * * @param list a list of the <code>CtClass</code> objects * representing interfaces, or * <code>null</code> if the class implements * no interfaces. */ public void setInterfaces(CtClass[] list) { checkModify(); }
/** * Adds a constructor. To add a class initializer (static constructor), * call <code>makeClassInitializer()</code>. * * @see #makeClassInitializer() */ public void addConstructor(CtConstructor c) throws CannotCompileException { checkModify(); }
/** * Removes a constructor declared in this class. * * @param c removed constructor. * @throws NotFoundException if the constructor is not found. */ public void removeConstructor(CtConstructor c) throws NotFoundException { checkModify(); }
/** * Adds a method. */ public void addMethod(CtMethod m) throws CannotCompileException { checkModify(); }
/** * Applies the given converter to all methods and constructors * declared in the class. This method calls <code>instrument()</code> * on every <code>CtMethod</code> and <code>CtConstructor</code> object * in the class. * * @param converter specifies how to modify. */ public void instrument(CodeConverter converter) throws CannotCompileException { checkModify(); }
/** * Modifies the bodies of all methods and constructors * declared in the class. This method calls <code>instrument()</code> * on every <code>CtMethod</code> and <code>CtConstructor</code> object * in the class. * * @param editor specifies how to modify. */ public void instrument(ExprEditor editor) throws CannotCompileException { checkModify(); }
/** * Sets the modifiers. * * <p>If the class is a nested class, this method also modifies * the class declaring that nested class (i.e. the enclosing * class is modified). * * @param mod modifiers encoded by * <code>javassist.Modifier</code> * @see Modifier */ public void setModifiers(int mod) { checkModify(); }
/** * Changes the name of this method. */ public void setName(String newname) { declaringClass.checkModify(); methodInfo.setName(newname); }
/** * Changes the name of the field. */ public void setName(String newName) { declaringClass.checkModify(); fieldInfo.setName(newName); }
/** * Returns a class file for this class. * * <p>This method is not available if <code>isFrozen()</code> * is true. */ public ClassFile getClassFile() { checkModify(); return getClassFile2(); }
/** * Sets the encoded modifiers of the field. * * @see Modifier */ public void setModifiers(int mod) { declaringClass.checkModify(); fieldInfo.setAccessFlags(AccessFlag.of(mod)); }
/** * Sets the encoded modifiers of the method/constructor. * * <p>Changing the modifiers may cause a problem. * For example, if a non-static method is changed to static, * the method will be rejected by the bytecode verifier. * * @see Modifier */ public void setModifiers(int mod) { declaringClass.checkModify(); methodInfo.setAccessFlags(AccessFlag.of(mod)); }
/** * Modifies the method/constructor body. * * @param converter specifies how to modify. */ public void instrument(CodeConverter converter) throws CannotCompileException { declaringClass.checkModify(); ConstPool cp = methodInfo.getConstPool(); converter.doit(getDeclaringClass(), methodInfo, cp); }
/** * Set the generic signature of the method. * It represents parameter types including type variables. * See {@link javassist.CtClass#setGenericSignature(String)} * for a code sample. * * @param sig a new generic signature. * @see javassist.bytecode.SignatureAttribute.MethodSignature#encode() * @since 3.17 */ public void setGenericSignature(String sig) { declaringClass.checkModify(); methodInfo.addAttribute(new SignatureAttribute(methodInfo.getConstPool(), sig)); }