Class jasmin.ClassFile
All Packages Class Hierarchy This Package Previous Next Index
Class jasmin.ClassFile
java.lang.Object
|
+----jasmin.ClassFile
- public class ClassFile
- extends Object
A ClassFile object is used to represent the binary data that makes up a
Java class file - it also serves as the public
API to the Jasmin assembler, though users should beware: the API
is likely to change in future versions (though its such a small API
at the moment that changes are likely to have only a small impact).
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.
-
ClassFile()
- Makes a new ClassFile object, used to represent a Java class file.
-
errorCount()
- Returns the number of warnings/errors encountered while parsing a file.
-
getClassName()
- Returns the name of the class in the file (i.e.
-
readJasmin(InputStream, String, boolean)
- Parses a Jasmin file, converting it internally into a binary
representation.
-
write(OutputStream)
- Writes the binary data for the class represented by this ClassFile
object to the specified
output stream, using the Java Class File format.
ClassFile
public ClassFile()
- Makes a new ClassFile object, used to represent a Java class file.
You can then use readJasmin to read in a class file stored in
Jasmin assembly format.
readJasmin
public void readJasmin(InputStream input,
String name,
boolean numberLines) throws IOException, Exception
- Parses a Jasmin file, converting it internally into a binary
representation.
If something goes wrong, this throws one of
an IOException, or a jasError, or one of a few other exceptions.
I'll tie this down more formally in the next version.
- Parameters:
- 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.
errorCount
public int errorCount()
- Returns the number of warnings/errors encountered while parsing a file.
0 if everything went OK.
getClassName
public String getClassName()
- Returns the name of the class in the file (i.e. the string given to
the .class parameter in Jasmin)
write
public void write(OutputStream outp) throws IOException, jasError
- Writes the binary data for the class represented by this ClassFile
object to the specified
output stream, using the Java Class File format. Throws either an
IOException or a jasError if something goes wrong.
All Packages Class Hierarchy This Package Previous Next Index