Package org.aspectj.apache.bcel.generic
Class ClassGen
java.lang.Object
org.aspectj.apache.bcel.classfile.Modifiers
org.aspectj.apache.bcel.generic.ClassGen
- All Implemented Interfaces:
Cloneable
Template class for building up a java class. May be initialized with an existing java class.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidaddEmptyConstructor(int access_flags)Convenience method.voidAdd a field to this class.voidaddInterface(String name)voidclone()booleancontainsField(Field f)containsMethod(String name, String signature)findsField(String name)getAttribute(String attributeName)intField[]String[]int[]intgetMajor()getMethodAt(int pos)Method[]intgetMinor()longgetSUID()Calculate the SerialVersionUID for a class.intbooleanhasAttribute(String attributeName)booleanbooleanisEnum()voidvoidvoidremoveField(Field f)voidremoveInterface(String name)voidremoveMethod(Method m)voidreplaceField(Field old, Field new_)Replace given field with new one.voidreplaceMethod(Method old, Method new_)Replace given method with new one.voidsetClassName(String name)voidsetClassNameIndex(int class_name_index)voidsetConstantPool(ConstantPool constant_pool)voidvoidsetMajor(int major)voidsetMethodAt(Method method, int pos)voidsetMethods(Method[] methods)voidsetMinor(int minor)voidsetSuperclassName(String name)voidsetSuperclassNameIndex(int superclass_name_index)Methods inherited from class org.aspectj.apache.bcel.classfile.Modifiers
getModifiers, isAbstract, isBridge, isFinal, isInterface, isNative, isPrivate, isProtected, isPublic, isStatic, isStrictfp, isSynchronized, isTransient, isVarargs, isVolatile, setModifiers
-
Constructor Details
-
ClassGen
public ClassGen(String classname, String superclassname, String filename, int modifiers, String[] interfacenames, ConstantPool cpool) -
ClassGen
-
ClassGen
-
-
Method Details
-
getJavaClass
- Returns:
- build and return a JavaClass
-
addInterface
-
removeInterface
-
getMajor
public int getMajor() -
setMajor
public void setMajor(int major) -
setMinor
public void setMinor(int minor) -
getMinor
public int getMinor() -
addAttribute
-
addAnnotation
-
addMethod
-
addEmptyConstructor
public void addEmptyConstructor(int access_flags)Convenience method. Add an empty constructor to this class that does nothing but calling super().- Parameters:
access- rights for constructor
-
addField
Add a field to this class.- Parameters:
f- field to add
-
containsField
-
findsField
- Returns:
- field object with given name, or null if not found
-
containsMethod
- Returns:
- method object with given name and signature, or null if not found
-
removeAttribute
-
removeAnnotation
-
removeMethod
-
replaceMethod
Replace given method with new one. If the old one does not exist add the new_ method to the class anyway. -
replaceField
Replace given field with new one. If the old one does not exist add the new_ field to the class anyway. -
removeField
-
getClassName
-
getSuperclassName
-
getFileName
-
setClassName
-
setSuperclassName
-
getMethods
-
setMethods
-
setFields
-
setMethodAt
-
getMethodAt
-
getInterfaceNames
-
getInterfaces
public int[] getInterfaces() -
getFields
-
getAttributes
-
getAnnotations
-
getConstantPool
-
setConstantPool
-
setClassNameIndex
public void setClassNameIndex(int class_name_index) -
setSuperclassNameIndex
public void setSuperclassNameIndex(int superclass_name_index) -
getSuperclassNameIndex
public int getSuperclassNameIndex() -
getClassNameIndex
public int getClassNameIndex() -
clone
-
isAnnotation
public final boolean isAnnotation() -
isEnum
public final boolean isEnum() -
getSUID
public long getSUID()Calculate the SerialVersionUID for a class. -
hasAttribute
-
getAttribute
-