JVM Knowledge

The SourceDebugExtension attribute is an optional attribute in the attributes table of a ClassFile structure (§4.1).

There may be at most one SourceDebugExtension attribute in the attributes table of a ClassFile structure.

The SourceDebugExtension attribute has the following format:

SourceDebugExtension_attribute {
    u2 attribute_name_index;
    u4 attribute_length;
    u1 debug_extension[attribute_length];
}

The items of the SourceDebugExtension_attribute structure are as follows:

  • attribute_name_index

    The value of the attribute_name_index item must be a valid index into the constant_pool table. The constant_pool entry at that index must be a CONSTANT_Utf8_info structure (§4.4.7) representing the string "SourceDebugExtension".

  • attribute_length

    The value of the attribute_length item indicates the length of the attribute, excluding the initial six bytes.

  • debug_extension[]

    The debug_extension array holds extended debugging information which has no semantic effect on the Java Virtual Machine. The information is represented using a modified UTF-8 string (§4.4.7) with no terminating zero byte.

    Note that the debug_extension array may denote a string longer than that which can be represented with an instance of class String.