Class SourceFile


  • public class SourceFile
    extends AttributeInfo
    The SourceFile attribute, an optional fixed-length attribute in the attributes table of a ClassFile. There can be no more than one SourceFile attribute for a given ClassFile.
    Version:
    1.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int sourceFileIndex
      Index into the constant pool of a ConstantUtf8Info structure representing the name of the source file from which this class file was compiled.
    • Constructor Summary

      Constructors 
      Constructor Description
      SourceFile​(ClassFile cf, int sourceFileIndex)
      Constructor.
    • Field Detail

      • sourceFileIndex

        private int sourceFileIndex
        Index into the constant pool of a ConstantUtf8Info structure representing the name of the source file from which this class file was compiled.
    • Constructor Detail

      • SourceFile

        public SourceFile​(ClassFile cf,
                          int sourceFileIndex)
        Constructor.
        Parameters:
        cf - The class file.
        sourceFileIndex - Index into the constant pool of a ConstantUtf8Info structure representing the source file name.
    • Method Detail

      • getSourceFileName

        public java.lang.String getSourceFileName()
        Returns the name of the source file that was compiled to create this class file.
        Returns:
        The name of the source file.
      • toString

        public java.lang.String toString()
        Returns a string representation of this attribute. Useful for debugging.
        Overrides:
        toString in class java.lang.Object
        Returns:
        A string representation of this attribute.