| Modifier and Type | Field and Description |
|---|---|
static int |
ACC_ABSTRACT
Declared abstract; must not be instantiated.
|
static int |
ACC_ANNOTATION
Declared as an annotation type.
|
static int |
ACC_BRIDGE
A bridge method, generated by the compiler
|
static int |
ACC_ENUM
Declared as an enum type.
|
static int |
ACC_FINAL
Declared final; no subclasses allowed.
|
static int |
ACC_INTERFACE
Is an interface, not a class.
|
static int |
ACC_NATIVE
Declared native; implemented in a language other than Java
|
static int |
ACC_PUBLIC
Declared public; may be accessed from outside its package.
|
static int |
ACC_STRICT
Declared strictfp; floating-point mode is FP-strict
|
static int |
ACC_SUPER
Treat superclass methods specially when invoked by the invokespecial instruction.
|
static int |
ACC_SYNCHRONIZED
Declared synchronized; invocation is wrapped in a monitor lock
|
static int |
ACC_SYNTHETIC
Declared synthetic; Not present in the source code.
|
static int |
ACC_VARARGS
Declared with variable number of arguments.
|
protected int |
access_flags |
protected int |
magic |
protected int |
major_version |
protected int |
minor_version |
protected int |
super_class |
protected Type |
superClass |
protected int |
this_class |
protected Type |
thisClass |
| Modifier | Constructor and Description |
|---|---|
protected |
ClassFile() |
|
ClassFile(byte[] bytes) |
|
ClassFile(Class<?> cls) |
|
ClassFile(File file) |
|
ClassFile(InputStream in) |
| Modifier and Type | Method and Description |
|---|---|
void |
addAttribute(AttributeInfo ai)
Adds a new attribute
|
protected int |
addConstantInfo(ConstantInfo ci,
int fromIndex) |
void |
addFieldInfo(FieldInfo fieldInfo) |
void |
addInterface(short intf) |
void |
addMethodInfo(MethodInfo methodInfo) |
protected void |
addWrapper(int index,
Object wrapper) |
int |
getAccess_flags() |
AnnotationWrapper |
getAnnotation(Class<? extends Annotation> type) |
String[] |
getArgNames(Member method) |
String |
getClassDescription(int index)
Returns a descriptor to class at index.
|
protected int |
getClassIndex(Type type) |
Type |
getClassName() |
int |
getConstantIndex(double constant)
Returns the constant map index to constant
|
int |
getConstantIndex(float constant)
Returns the constant map index to constant
|
int |
getConstantIndex(int constant)
Returns the constant map index to constant
|
int |
getConstantIndex(long constant)
Returns the constant map index to constant
|
int |
getConstantIndex(String constant)
Returns the constant map index to constant
|
ConstantInfo |
getConstantInfo(int index)
Return constantInfo at index.
|
int |
getConstantPoolSize() |
int |
getConstructorIndex(Member constructor)
Returns the constant map index to constructor
|
Object |
getElement(int index)
Returns a wrapped element from constant map
|
int |
getFieldIndex(Member field)
Returns the constant map index to field.
|
int |
getFieldIndex(Type declaringClass,
String name,
String descriptor)
Returns the constant map index to field
|
int |
getFieldIndex(Type declaringClass,
String name,
Type type)
Returns the constant map index to field
|
List<FieldInfo> |
getFields() |
int |
getMajor_version() |
String |
getMethodDescription(int index)
Returns a descriptor to method at index.
|
int |
getMethodIndex(Member method)
Returns the constant map index to method
|
MethodInfo |
getMethodInfo(Member method)
Returns MethodInfo or null.
|
List<MethodInfo> |
getMethodInfos() |
int |
getMinor_version() |
int |
getNameAndTypeIndex(String name,
String descriptor)
Returns the constant map index to name and type
|
int |
getNameIndex(String name)
Returns the constant map index to name
|
SortedSet<String> |
getReferencedClassnames()
Returns all classnames (in internal form) that this class references
|
int |
getRefIndex(Class<? extends ConstantInfo.Ref> refType,
String fullyQualifiedname,
String name,
String descriptor)
Returns the constant map index to reference
|
String |
getString(int index)
Return a constant string at index.
|
Type |
getSuperClassName() |
Type |
getThisClass() |
boolean |
isImplemented(Member method) |
static void |
main(String[] args) |
boolean |
referencesClass(Type type) |
boolean |
referencesMethod(Member method)
Return true if class contains method ref to given method
|
void |
write(DataOutput out)
Writes the class
|
public static final int ACC_PUBLIC
public static final int ACC_FINAL
public static final int ACC_SUPER
public static final int ACC_SYNCHRONIZED
public static final int ACC_BRIDGE
public static final int ACC_VARARGS
public static final int ACC_NATIVE
public static final int ACC_INTERFACE
public static final int ACC_ABSTRACT
public static final int ACC_STRICT
public static final int ACC_SYNTHETIC
public static final int ACC_ANNOTATION
public static final int ACC_ENUM
protected int magic
protected int minor_version
protected int major_version
protected int access_flags
protected int this_class
protected int super_class
protected Type superClass
protected Type thisClass
protected ClassFile()
public ClassFile(Class<?> cls)
throws IOException
IOExceptionpublic ClassFile(byte[] bytes)
throws IOException
IOExceptionpublic ClassFile(InputStream in)
throws IOException
IOExceptionpublic ClassFile(File file)
throws IOException
IOExceptionpublic AnnotationWrapper getAnnotation(Class<? extends Annotation> type)
public Type getThisClass()
public int getConstantPoolSize()
public int getFieldIndex(Type declaringClass,
String name,
Type type)
declaringClass - name - type - public int getFieldIndex(Type declaringClass,
String name,
String descriptor)
declaringClass - name - descriptor - public int getMethodIndex(Member method)
method - public int getRefIndex(Class<? extends ConstantInfo.Ref> refType, String fullyQualifiedname, String name, String descriptor)
refType - fullyQualifiedname - name - descriptor - public int getNameIndex(String name)
name - public int getNameAndTypeIndex(String name,
String descriptor)
name - descriptor - public final int getConstantIndex(int constant)
constant - public final int getConstantIndex(float constant)
constant - public final int getConstantIndex(double constant)
constant - public final int getConstantIndex(long constant)
constant - public final int getConstantIndex(String constant)
constant - public void addMethodInfo(MethodInfo methodInfo)
public void addFieldInfo(FieldInfo fieldInfo)
public List<FieldInfo> getFields()
public List<MethodInfo> getMethodInfos()
public String[] getArgNames(Member method)
public Type getClassName()
public Type getSuperClassName()
public int getAccess_flags()
public int getMajor_version()
public int getMinor_version()
public SortedSet<String> getReferencedClassnames()
protected int addConstantInfo(ConstantInfo ci, int fromIndex)
protected void addWrapper(int index,
Object wrapper)
public void addInterface(short intf)
public void addAttribute(AttributeInfo ai)
ai - public Object getElement(int index)
index - public int getFieldIndex(Member field)
field - public int getConstructorIndex(Member constructor)
constructor - public String getMethodDescription(int index)
index - public String getClassDescription(int index)
index - public MethodInfo getMethodInfo(Member method)
method - public boolean isImplemented(Member method)
public boolean referencesMethod(Member method)
method - public boolean referencesClass(Type type)
protected final int getClassIndex(Type type)
public final ConstantInfo getConstantInfo(int index)
index - public final String getString(int index)
index - public void write(DataOutput out)
throws IOException
public static void main(String[] args)
args - the command line arguments