Contents Prev Next


2 Class File Format

2.1 - Format
2.2 - Signatures
2.3 - Constant Pool
2.4 - Fields
2.5 - Methods
2.6 - Attributes

This chapter documents the Java class (.class) file format.

Each class file contains the compiled version of either a Java class or a Java interface. Compliant Java interpreters must be capable of dealing with all class files that conform to the following specification.

A Java class file consists of a stream of 8-bit bytes. All 16-bit and 32-bit quantities are constructed by reading in two or four 8-bit bytes, respectively. The bytes are joined together in network (big-endian) order, where the high bytes come first. This format is supported by the Java java.io.DataInput and java.io.DataOutput interfaces, and classes such as java.io.DataInputStream and java.io.DataOutputStream.

The class file format is described here using a structure notation. Successive fields in the structure appear in the external representation without padding or alignment. Variable size arrays, often of variable sized elements are called tables and are commonplace in these structures.

The types u1, u2, and u4 mean an unsigned one-, two-, or four-byte quantity, respectively, which are read by method such as readUnsignedByte, readUnsignedShort and readInt of the java.io.DataInput interface.


Contents Prev Next