Class innerClassAttr


public class innerClassAttr
extends attrInfo

This object represents the Java class file inner class information.

Inner classes were added to Java 1.1 and are described by Sun's Inner Class Specification, 2/10/97.

An inner class is a class that is nested inside another class. The inner class exists in the local scope of its enclosing class. So an inner class may access any class variables or member functions of the parent class. It may also reference any visible methods from the parent classes super class.

Although the inner class shares scoping with its parent class, it is compiled into a separate class file. This class has a name that is created from the inner class and its parent class. To quote the Inner class specification (Class Name Transformations):

Names of nested classes are transformed as necessary by the compiler to avoid conflicts with identical names in other scopes. Names are encoded to the virtual machine by taking their source form, qualified with dots, and changing each dot after a class name into a dollar sign.

The JVM has no special support for inner classes. They are supported in the compiler by allowing inner class methods to reference class variables and methods that might not normally be in scope for an external class. To quote Sun's inner class specification "This complicates the compiler's job."

The format for the inner classes attribute is:

innerClasses_attribute {
u2 attribute_name_index;
u4 attribute_name_length;
u2 number_of_classes
innerClassInfo classes[ number_of_classes];

The attribute_name_index and attribute length are read by the attrFactory.allocAttr method. These values are passed into the class constructor.

Here innerClassInfo is

innerClassInfo {
u2 inner_class_info_index;
u2 outer_class_info_index;
u2 inner_name_index;
u2 inner_class_access_flags;

Sun's JVM Specification and inner class specification is difficult to understand when it comes to inner classes.

The inner_class_info_index is either zero or an index into the constant table for a constClass_or_String representing the inner class.

The outer_class_info_index is zero if the inner_class is not a member. Otherwise the value of outer_class_info_index is an index into the constant table for a constClass_or_String representing the class or interface of which the inner_class is a member.

If the inner_class is anonymous, the inner_name_index will be zero. Otherwise this is an index into the constant table for a constUtf8 object which contains the class name.

The inner_class_access_flags are the access mask for the inner class or interface.

Inner Class Summary
(package private)  class innerClassAttr.innerClassInfo
Field Summary
(package private)  innerClassAttr.innerClassInfo[] classInfoTab
Fields inherited from class attr.attrInfo
attrName, len
Fields inherited from class util.dataRead
Constructor Summary
innerClassAttr(java.lang.String name, int length, dStream, constPool constPoolSec)
Methods inherited from class attr.attrInfo
getName, pr
Methods inherited from class util.dataRead
getBytesRead, readU1, readU2, readU4
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait

Field Detail


innerClassAttr.innerClassInfo[] classInfoTab
Constructor Detail


public innerClassAttr(java.lang.String name,
                      int length,
                      constPool constPoolSec)