KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jas > EnclMethAttr


1 /**
2  * EnclMeth attributes are embedded into class files
3  * and used for further ???
4  * @author $Author: Jennifer Lhotak$
5  * @version $Revision: 1.1 $
6  */

7
8 package jas;
9
10 import java.io.*;
11 import java.util.*;
12
13 public class EnclMethAttr {
14
15     static CP attr = new AsciiCP("EnclosingMethod");
16     ClassCP cls;
17     NameTypeCP meth;
18
19     void resolve(ClassEnv e){
20         e.addCPItem(attr);
21         e.addCPItem(cls);
22         e.addCPItem(meth);
23     }
24
25     /**
26     * Note: An enclosing method attr is associated with a <em>class</em>,
27     * so you need to create a new EnclMethAttr for each anon or
28     * local class you create
29     */

30     public EnclMethAttr(String JavaDoc a, String JavaDoc b, String JavaDoc c) { //
31
cls = new ClassCP(a);
32         meth = new NameTypeCP(b, c);
33     }
34
35     int size(){
36         return 4;
37     }
38
39
40     void write(ClassEnv e, DataOutputStream out)
41         throws IOException, jasError
42         {
43         
44         out.writeShort(e.getCPIndex(attr));
45         out.writeInt(4); // fixed length
46
out.writeShort(e.getCPIndex(cls));
47         out.writeShort(e.getCPIndex(meth));
48     }
49 }
50
Popular Tags