9.5 Class Attributes

The class file ends with a list of attributes. These are formatted just like field or method attributes. As with other attributes, the class file can have any attributes it wants here, but only the SourceFile attribute is defined in The Java Language Specification:

 0001c5 0001               1 class file attributes                           Attribute 0: 0001c7 0012                   name #18<SourceFile> 0001c9 00000002               length = 2 0001cd 0010                   SourceFile #16<hello.java> 

The SourceFile attribute is only two bytes long. Those two bytes are used to specify a UTF8 constant that names the file used as input to the compiler. This can be used by debuggers in conjunction with the LineNumberTable attributes to show the source line being executed.

The value of the attribute is the name of the source file without any path information. Therefore, hello.java is acceptable here, but /home/josh/hello.java would not be.



Programming for the Java Virtual Machine
Programming for the Javaв„ў Virtual Machine
ISBN: 0201309726
EAN: 2147483647
Year: 1998
Pages: 158
Authors: Joshua Engel

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net