An 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 big-endian order.
The class file format is described in terms similar to a C structure. However, unlike a C structure,
Attributes are used at several different places in the class format. All attributes have the following format:
The attribute_name is a 16-bit index into the class's constant pool; the value of constant_pool[attribute_name] will be a string giving the name of the attribute. The field attribute_length gives the length of the subsequent information in bytes. This length does not include the four bytes of the attribute_name and attribute_length.
In the following text, whenever we allow attributes, we give the name of the attributes that are currently understood. In the future, more attributes will be added. Class file readers are expected to skip over and ignore the information in any attributes that they do not understand.
Generated with CERN WebMaker