public class ClassFile extends ProgramElement
Modifier and Type | Field and Description |
---|---|
static int |
ACC_ABSTRACT
Class is abstract
|
static int |
ACC_ANNOTATION
Class is an Annotation
|
static int |
ACC_ENUM
Class is an Enum
|
static int |
ACC_FINAL
Final.
|
static int |
ACC_INTERFACE
Class is an interface
|
static int |
ACC_PUBLIC
Public access.
|
static int |
ACC_SUPER
Super bit.
|
static int |
ACC_SYNTHETIC
Class is synthetic
|
access_flags, attributes, constantPool
Constructor and Description |
---|
ClassFile(String className)
Constructor to build ClassFile from scratch.
|
Modifier and Type | Method and Description |
---|---|
String |
getClassName()
Gets the name of the class represented by this ClassFile.
|
ConstantPool |
getConstantPool()
Gets the constant pool of this ClassFile.
|
List<Field> |
getFields()
Gets all the Fields of this class file
|
List<Interface> |
getInterfaces()
Gets all the Interfaces of this class file
|
int |
getMagicNumber()
Gets the magic number
|
short |
getMajorVersion()
Gets the major version of the class file
|
List<Method> |
getMethods()
Gets all the Methods of this class file
|
short |
getMinorVersion()
Gets the minor version of the class file
|
short |
getSuperClassIndex()
Gets the index in constant-pool, that holds a class-info for super class
of this class.
|
String |
getSuperclassName()
Gets the name of the superclass of the class represented by this
ClassFile.
|
short |
getThisClassIndex()
Gets the index in constant-pool, that holds a class-info of this class.
|
static void |
main(String[] args) |
static ClassFile |
parse(InputStream is)
Parse InputStream and create an instance of ClassFile from stream.
|
static ClassFile |
parse(String fileName)
Parse given file and create an instance of ClassFile from it.
|
void |
setAccessFlags(short access_flags) |
byte[] |
toBytes()
Converts this ClassFile into bytes.
|
getAccessFlags, getAttribute, getAttributes, readAttributes, writeAttributes
public static final int ACC_PUBLIC
public static final int ACC_FINAL
public static final int ACC_SUPER
public static final int ACC_INTERFACE
public static final int ACC_ABSTRACT
public static final int ACC_SYNTHETIC
public static final int ACC_ANNOTATION
public static final int ACC_ENUM
public ClassFile(String className)
className
- fully qualified name of the class.public static ClassFile parse(String fileName) throws ParseException, IOException
fileName
- name of the file, that is read.ParseException
- is thrown, if classfile parser cannot understand parsed
stream.IOException
- is thrown, if there was problems in reading the stream.public static ClassFile parse(InputStream is) throws ParseException, IOException
is
- InputStreamParseException
- is thrown, if classfile parser cannot understand parsed
stream.IOException
- is thrown, if there was problems in reading the stream.public ConstantPool getConstantPool()
getConstantPool
in class ProgramElement
public int getMagicNumber()
public short getMinorVersion()
public short getMajorVersion()
public List<Field> getFields()
public List<Interface> getInterfaces()
public List<Method> getMethods()
public String getClassName()
public String getSuperclassName()
public void setAccessFlags(short access_flags)
public short getSuperClassIndex()
public short getThisClassIndex()
public byte[] toBytes()
Copyright © 2017. All rights reserved.