Klasse JavaClass
java.lang.Object
org.aspectj.apache.bcel.classfile.Modifiers
org.aspectj.apache.bcel.classfile.JavaClass
Represents a Java class, i.e., the data structures, constant pool, fields, methods and commands contained in a Java .class file.
See JVM specification for details.
The intent of this class is to represent a parsed or otherwise existing class file. Those interested in programatically
generating classes should see the ClassGen class.
-
Feldübersicht
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoidCalled by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class.voiddump(DataOutputStream file) Dump Java class to output stream in binary format.voidDump class to a file.voiddump(OutputStream file) Dump Java class to output stream in binary format.voidDump class to a file named file_name.Get all interfaces implemented by this JavaClass (transitively).byte[]getBytes()intField[]final StringHunts for a signature attribute on the member and returns its contents.int[]String[]Get interfaces directly implemented by this JavaClass.intgetMajor()getMethod(Constructor<?> c) Method[]intgetMinor()Gets the ClassRepository which holds its definition.final SignatureintbooleanimplementationOf(JavaClass inter) final booleaninstanceOf(JavaClass super_class) Equivalent to runtime "instanceof" operator.final booleanReturns true if this class represents an annotation, i.e. it was a 'public @interface blahblah' declarationfinal booleanfinal booleanisClass()final booleanisEnum()Returns true if this class represents an enum typebooleanfinal booleanisNested()final booleanisSuper()voidsetAttributes(Attribute[] attributes) voidsetClassName(String class_name) voidsetClassNameIndex(int class_name_index) voidsetConstantPool(ConstantPool constant_pool) voidvoidsetFileName(String file_name) Set File name of class, aka SourceFile attribute valuevoidsetInterfaceNames(String[] interface_names) voidsetInterfaces(int[] interfaces) voidsetMajor(int major) voidsetMethods(Method[] methods) voidsetMinor(int minor) voidsetRepository(Repository repository) Sets the ClassRepository which loaded the JavaClass.voidsetSourceFileName(String source_file_name) Set absolute path to file this class was read from.voidsetSuperclassName(String superclass_name) voidsetSuperclassNameIndex(int superclass_name_index) toString()Von Klasse geerbte Methoden org.aspectj.apache.bcel.classfile.Modifiers
getModifiers, isAbstract, isBridge, isFinal, isInterface, isNative, isPrivate, isProtected, isPublic, isStatic, isStrictfp, isSynchronized, isTransient, isVarargs, isVolatile, setModifiers
-
Konstruktordetails
-
JavaClass
public JavaClass(int classnameIndex, int superclassnameIndex, String filename, int major, int minor, int access_flags, ConstantPool cpool, int[] interfaces, Field[] fields, Method[] methods, Attribute[] attributes)
-
-
Methodendetails
-
accept
Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class. I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. -
dump
Dump class to a file.- Parameter:
file- Output file- Löst aus:
IOException
-
dump
Dump class to a file named file_name.- Parameter:
file_name- Output file name- Löst aus:
IOException
-
getBytes
public byte[] getBytes()- Gibt zurück:
- class in binary format
-
dump
Dump Java class to output stream in binary format.- Löst aus:
IOException
-
dump
Dump Java class to output stream in binary format.- Löst aus:
IOException
-
getAttributes
-
getAnnotations
-
getClassName
- Gibt zurück:
- Class name.
-
getPackageName
- Gibt zurück:
- Package name.
-
getClassNameIndex
public int getClassNameIndex() -
getConstantPool
-
getFields
- Gibt zurück:
- Fields, i.e., variables of the class. Like the JVM spec mandates for the classfile format, these fields are those specific to this class, and not those of the superclass or superinterfaces.
-
getFileName
- Gibt zurück:
- File name of class, aka SourceFile attribute value
-
getInterfaceNames
- Gibt zurück:
- Names of implemented interfaces.
-
getInterfaceIndices
public int[] getInterfaceIndices()- Gibt zurück:
- Indices in constant pool of implemented interfaces.
-
getMajor
public int getMajor() -
getMethods
- Gibt zurück:
- Methods of the class.
-
getMethod
- Gibt zurück:
- A org.aspectj.apache.bcel.classfile.Method corresponding to java.lang.reflect.Method if any
-
getMethod
-
getField
-
getMinor
public int getMinor()- Gibt zurück:
- Minor number of class file version.
-
getSourceFileName
- Gibt zurück:
- sbsolute path to file where this class was read from
-
getSuperclassName
- Gibt zurück:
- Superclass name.
-
getSuperclassNameIndex
public int getSuperclassNameIndex()- Gibt zurück:
- Class name index.
-
setAttributes
- Parameter:
attributes- .
-
setClassName
- Parameter:
class_name- .
-
setClassNameIndex
public void setClassNameIndex(int class_name_index) - Parameter:
class_name_index- .
-
setConstantPool
- Parameter:
constant_pool- .
-
setFields
- Parameter:
fields- .
-
setFileName
Set File name of class, aka SourceFile attribute value -
setInterfaceNames
- Parameter:
interface_names- .
-
setInterfaces
public void setInterfaces(int[] interfaces) - Parameter:
interfaces- .
-
setMajor
public void setMajor(int major) -
setMethods
-
setMinor
public void setMinor(int minor) -
setSourceFileName
Set absolute path to file this class was read from. -
setSuperclassName
- Parameter:
superclass_name- .
-
setSuperclassNameIndex
public void setSuperclassNameIndex(int superclass_name_index) - Parameter:
superclass_name_index- .
-
toString
-
isSuper
public final boolean isSuper() -
isClass
public final boolean isClass() -
isAnonymous
public final boolean isAnonymous() -
isNested
public final boolean isNested() -
isAnnotation
public final boolean isAnnotation()Returns true if this class represents an annotation, i.e. it was a 'public @interface blahblah' declaration -
isEnum
public final boolean isEnum()Returns true if this class represents an enum type -
getRepository
Gets the ClassRepository which holds its definition. By default this is the same as SyntheticRepository.getInstance(); -
setRepository
Sets the ClassRepository which loaded the JavaClass. Should be called immediately after parsing is done. -
instanceOf
Equivalent to runtime "instanceof" operator.- Gibt zurück:
- true if this JavaClass is derived from teh super class
-
implementationOf
- Gibt zurück:
- true, if clazz is an implementation of interface inter
-
getSuperClass
- Gibt zurück:
- the superclass for this JavaClass object, or null if this is java.lang.Object
-
getSuperClasses
- Gibt zurück:
- list of super classes of this class in ascending order, i.e., java.lang.Object is always the last element
-
getInterfaces
Get interfaces directly implemented by this JavaClass. -
getAllInterfaces
Get all interfaces implemented by this JavaClass (transitively). -
getGenericSignature
Hunts for a signature attribute on the member and returns its contents. So where the 'regular' signature may be Ljava/util/Vector; the signature attribute will tell us e.g. "Ungültige Eingabe: "<"E:>Ljava/lang/Object". We can learn the type variable names, their bounds, and the true superclass and superinterface types (including any parameterizations) Coded for performance - searches for the attribute only when requested - only searches for it once. -
isGeneric
public boolean isGeneric() -
getSignatureAttribute
-