Class SourceFileAttribute


  • public class SourceFileAttribute
    extends Attribute
    The SourceFile attribute: the constant-pool index of the source file name Utf8.
    • Constructor Detail

      • SourceFileAttribute

        public SourceFileAttribute​(ClassFile classFile,
                                   String name,
                                   MemberEntry parent,
                                   int nameIndex,
                                   int length)
        Creates the attribute shell for parsing.
        Parameters:
        classFile - the class the attribute belongs to
        name - the attribute name
        parent - the member the attribute belongs to, or null for a class-level attribute
        nameIndex - constant-pool index of the name Utf8
        length - the attribute length in bytes
    • Method Detail

      • getSourceFileIndex

        public int getSourceFileIndex()
        Returns:
        the source file index
      • getClassFile

        public ClassFile getClassFile()
        Returns:
        the class file
      • read

        public void read​(ClassFile classFile,
                         int length)
        Description copied from class: Attribute
        Reads the attribute data from the class file.
        Specified by:
        read in class Attribute
        Parameters:
        classFile - The ClassFile utility to read data.
        length - The length of the attribute.
      • updateLength

        public void updateLength()
        Description copied from class: Attribute
        Recomputes the attribute length field from the current in-memory content.
        Specified by:
        updateLength in class Attribute
      • resolveSourceFileName

        public String resolveSourceFileName​(int sourceFileIndex)
        Helper method to retrieve the source file name from the constant pool.
        Parameters:
        sourceFileIndex - The index of the Utf8Item in the constant pool.
        Returns:
        The source file name as a String.