1 import jas.*;
2 import java.io.*;
3 import sun.tools.java.RuntimeConstants;
4 
5 //
6 // This is program that makes calls into the jas package
7 // to generate a class that does nothing at all.
8 //
9 
10 class simple implements RuntimeConstants
11 {
main(String argv[])12   public static void main(String argv[])
13     throws jasError, IOException
14   {
15 
16                                 // CodeAttr's contain the body of
17                                 // a method.
18 
19     CodeAttr init = new CodeAttr();
20     init.addInsn(new Insn(opc_aload_0));
21     init.addInsn(new Insn(opc_invokenonvirtual,
22                           new MethodCP("java/lang/Object", "<init>", "()V")));
23     init.addInsn(new Insn(opc_return));
24 
25 
26                                 // ClassEnv's are used as a container
27                                 // to hold all information about a class.
28 
29     ClassEnv nclass = new ClassEnv();
30     nclass.setClass(new ClassCP("out"));
31     nclass.setSuperClass(new ClassCP("java/lang/Object"));
32 
33 
34 
35                                 // Add the init code to the class.
36     nclass.addMethod((short)ACC_PUBLIC, "<init>", "()V", init, null);
37 
38 
39                                 // write it all out
40     nclass.write(new DataOutputStream
41                  (new FileOutputStream("out.class")));
42   }
43 }
44 
45 
46