module ClassFile: sig
.. end
Class file definition as well as i/o functions.
Class file instances are low-level Java class definitions,
high-level definitions being provided by ClassDefinition.t
instances.
Type
type
t = {
}
This structure is barely a translation from the class file as it is
defined in Sun's Java specification.
x_count fields are redundant
as they represent the length of
x fields but are nevertheless
kept to ensure that this structure is as close as possible from the
Java specification.
The only slight difference is related to the constant pool.
As a constant pool is indexed from 1 to size - 1, it has thus
been decided to create an array of size size
and to put a dummy
value at index 0 (this dummy value is also used for the auxiliary
index of the elements (double and long ones) that use two indexes in
the constant pool).
Exception
type
error =
| |
Invalid_magic_number of Utils.u4 |
| |
Unsupported_version of Utils.u2 * Utils.u2 |
| |
Invalid_this |
| |
Invalid_super |
| |
Invalid_super_interface |
| |
Invalid_parent_interface |
exception Exception of error
val string_of_error : error -> string
I/O functions
val read : InputStream.t -> t
read st
reads a class file from the passed stream.
Raises Exception
if the read structure is not a valid class file.
Raises InputStream.Exception
if an i/o error occurs.
Raises ConstantPool.Exception
if the underlying constant pool is
not consistent.
val write : t -> OutputStream.t -> unit
write cf st
writes the class file cf
onto the stream st
.
Raises OutputStream.Exception
if an i/o error occurs.