KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > polyglot > types > reflect > InnerClasses


1 package polyglot.types.reflect;
2
3 import java.util.*;
4 import java.io.*;
5
6 /**
7  * Exceptions describes the types of exceptions that a method may throw.
8  * The Exceptions attribute stores a list of indices into the constant
9  * pool of the typs of exceptions thrown by the method.
10  *
11  * @see polyglot.types.reflect Method
12  *
13  * @author Nate Nystrom
14  * (<a HREF="mailto:nystrom@cs.purdue.edu">nystrom@cs.purdue.edu</a>)
15  */

16 class InnerClasses extends Attribute {
17   Info[] classes;
18
19   static class Info {
20     int classIndex;
21     int outerClassIndex;
22     int nameIndex;
23     int modifiers;
24   }
25
26   /**
27    * Constructor. Create an Exceptions attribute from a data stream.
28    *
29    * @param in
30    * The data stream of the class file.
31    * @param nameIndex
32    * The index into the constant pool of the name of the attribute.
33    * @param length
34    * The length of the attribute, excluding the header.
35    * @exception IOException
36    * If an error occurs while reading.
37    */

38   InnerClasses(DataInputStream in, int nameIndex, int length) throws IOException
39   {
40     super(nameIndex, length);
41
42     int count = in.readUnsignedShort();
43
44     classes = new Info[count];
45
46     for (int i = 0; i < count; i++) {
47       classes[i] = new Info();
48
49       // index of a Constant.CLASS
50
classes[i].classIndex = in.readUnsignedShort();
51
52       // index of a Constant.CLASS != 0 iff a member class.
53
classes[i].outerClassIndex = in.readUnsignedShort();
54
55       // index of a Constant.UTF == 0 iff an anonymous class.
56
classes[i].nameIndex = in.readUnsignedShort();
57
58       // modifiers of inner class
59
classes[i].modifiers = in.readUnsignedShort();
60     }
61   }
62 }
63
Popular Tags