The LineNumberTable attribute is an optional variable-length attribute in the attributes table of a Code attribute (§4.7.3). It may be used by debuggers to determine which part of the code array corresponds to a given line number in the original source file.
If multiple LineNumberTable attributes are present in the attributes table of a Code attribute, then they may appear in any order.
There may be more than one LineNumberTable attribute per line of a source file in the attributes table of a Code attribute. That is, LineNumberTable attributes may together represent a given line of a source file, and need not be one-to-one with source lines.
The LineNumberTable attribute has the following format:
LineNumberTable_attribute {
u2 attribute_name_index;
u4 attribute_length;
u2 line_number_table_length;
{ u2 start_pc;
u2 line_number;
} line_number_table[line_number_table_length];
}
The items of the LineNumberTable_attribute structure are as follows:
-
attribute_name_index
The value of the
attribute_name_indexitem must be a valid index into theconstant_pooltable. Theconstant_poolentry at that index must be aCONSTANT_Utf8_infostructure (§4.4.7) representing the string "LineNumberTable". -
attribute_length
The value of the
attribute_lengthitem indicates the length of the attribute, excluding the initial six bytes. -
line_number_table_length
The value of the
line_number_table_lengthitem indicates the number of entries in theline_number_tablearray. -
line_number_table[]
Each entry in the
line_number_tablearray indicates that the line number in the original source file changes at a given point in thecodearray. Eachline_number_tableentry must contain the following two items:-
start_pc
The value of the
start_pcitem must indicate the index into thecodearray at which the code for a new line in the original source file begins.The value of
start_pcmust be less than the value of thecode_lengthitem of theCodeattribute of which thisLineNumberTableis an attribute. -
line_number
The value of the
line_numberitem must give the corresponding line number in the original source file.
-