public class ClassFile extends Object
To assemble a file, you first construct a jasmin.ClassFile object, then call readJasmin() to read in the contents of a Jasmin assembly file, then call write() to write out the binary representation of the class file.
There are a few other utility methods as well. See Main.java for an example which uses all of the public methods provided in ClassFile.
| Constructor and Description |
|---|
ClassFile()
Makes a new ClassFile object, used to represent a Java class file.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDeprecatedToField() |
void |
addGenericAttrToClass(GenericAttr g) |
void |
addGenericAttrToField(String name,
byte[] value) |
void |
addGenericAttrToMethod(String name,
byte[] value) |
void |
addSootCodeAttr(String name,
String value) |
int |
errorCount()
Returns the number of warnings/errors encountered while parsing a file.
|
String |
getClassName()
Returns the name of the class in the file (i.e.
|
void |
readJasmin(InputStream input,
String name,
boolean numberLines)
Parses a Jasmin file, converting it internally into a binary
representation.
|
void |
write(OutputStream outp)
Writes the binary data for the class represented by this ClassFile
object to the specified
output stream, using the Java Class File format.
|
public ClassFile()
public void addGenericAttrToMethod(String name, byte[] value)
public void addGenericAttrToField(String name, byte[] value)
public void addDeprecatedToField()
public void addGenericAttrToClass(GenericAttr g)
public void readJasmin(InputStream input, String name, boolean numberLines) throws IOException, Exception
input - is the stream containing the Jasmin assembly code for the
class.name - is the name of the stream. This name will be
concatenated to error messages printed to System.err.numberLines - true if you want Jasmin to generate line
numbers automatically, based on the assembly source, or
false if you are using the ".line" directive and don't
want Jasmin to help out.IOExceptionExceptionpublic int errorCount()
public String getClassName()
public void write(OutputStream outp) throws IOException, jasError
IOExceptionjasErrorCopyright © 2019 Sable. All rights reserved.