9.3 Class Information

Following the constant pool is information about the class itself: its name, type, and access flags. For this class, the class information section is

 00015b 0021           access_flags = 33 00015d 0005           this = #5 00015f 0003           super = #3 000161 0000           0 interfaces 

The first two bytes are access flags for the class. They are interpreted as a bit vector, revealing some class-level information. The meaning of these bits, from right to left, is shown in Figure 9.1 and Table 9.3.

Figure 9.1. Class access flags with value 33

graphics/09fig01.gif

ACC_PUBLIC means that the class is public; that is, any other class in any package may reference it. The ACC_SUPER bit has a special meaning for classes containing the invokespecial instruction, as discussed in section 4.5.5. ACC_SUPER corresponds to the super keyword on the .class directive. All class files generated from Java programs should have this bit set.

The next two bytes are a reference into the constant pool that indicates the name of this class. It is expected to be a Class entry. A Class entry contains a reference to a UTF8 constant, in this case constant 19, hello. Similarly, the next two bytes name the superclass of this class. In this case the name of the superclass is java/lang/Object. If the value of these two bytes is 0, then there is no superclass. Only the class java.lang.Object is permitted to have no superclass; in any other class, it is an error. This ensures that Object is always the root of the class hierarchy.

Table 9.3. Class access flags
Bit Name Meaning
1 ACC_PUBLIC The class is public
2-4   unused
5 ACC_FINAL The class is final
6 ACC_SUPER The class is super
7-9   unused
10 ACC_INTERFACE The class is an interface
11   unused
12 ACC_ABSTRACT The class is abstract



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

Similar book on Amazon

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