The SourceFile attribute is an optional fixed-length attribute in the attributes table of a ClassFile structure (§4.1).
There may be at most one SourceFile attribute in the attributes table of a ClassFile structure.
The SourceFile attribute has the following format:
SourceFile_attribute {
u2 attribute_name_index;
u4 attribute_length;
u2 sourcefile_index;
}
The items of the SourceFile_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 "SourceFile". -
attribute_length
The value of the
attribute_lengthitem of aSourceFile_attributestructure must be two. -
sourcefile_index
The value of the
sourcefile_indexitem must be a valid index into theconstant_pooltable. Theconstant_poolentry at that index must be aCONSTANT_Utf8_infostructure representing a string.The string referenced by the
sourcefile_indexitem will be interpreted as indicating the name of the source file from which thisclassfile was compiled. It will not be interpreted as indicating the name of a directory containing the file or an absolute path name for the file; such platform-specific additional information must be supplied by the run-time interpreter or development tool at the time the file name is actually used.