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(java.lang.String className)
Constructor to build ClassFile from scratch.
|
Modifier and Type | Method and Description |
---|---|
void |
addInterface(java.lang.String name)
Adds a new interface, that class represented by this ClassFile
implements.
|
java.lang.String |
getClassName()
Gets the name of the class represented by this ClassFile.
|
ConstantPool |
getConstantPool()
Gets the constant pool of this ClassFile.
|
java.util.List |
getFields()
Gets all the Fields of this class file
|
java.util.List |
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
|
java.util.List |
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.
|
java.lang.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(java.lang.String[] args)
Used for testing purposes.
|
static ClassFile |
parse(java.io.InputStream is)
Parse InputStream and create an instance of ClassFile from stream.
|
static ClassFile |
parse(java.lang.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_ABSTRACT
public static final int ACC_ANNOTATION
public static final int ACC_ENUM
public static final int ACC_FINAL
public static final int ACC_INTERFACE
public static final int ACC_PUBLIC
public static final int ACC_SUPER
public static final int ACC_SYNTHETIC
public ClassFile(java.lang.String className)
className
- fully qualified name of the class.public void addInterface(java.lang.String name)
fully
- qualified name of the interface to implementpublic java.lang.String getClassName()
public ConstantPool getConstantPool()
getConstantPool
in class ProgramElement
public java.util.List getFields()
public java.util.List getInterfaces()
public int getMagicNumber()
public short getMajorVersion()
public java.util.List getMethods()
public short getMinorVersion()
public short getSuperClassIndex()
public java.lang.String getSuperclassName()
public short getThisClassIndex()
public static void main(java.lang.String[] args) throws java.lang.Exception
args
- args[0] is a path to java class filejava.lang.Exception
public static ClassFile parse(java.io.InputStream is) throws ParseException, java.io.IOException
is
- InputStreamParseException
- is thrown, if classfile parser cannot
understand parsed stream.java.io.IOException
- is thrown, if there was problems in reading the
stream.public static ClassFile parse(java.lang.String fileName) throws ParseException, java.io.IOException
fileName
- name of the file, that is read.ParseException
- is thrown, if classfile parser cannot
understand parsed stream.java.io.IOException
- is thrown, if there was problems in reading the
stream.public void setAccessFlags(short access_flags)
public byte[] toBytes()
Copyright © 2001. Documenation generated January 20 2015.