File: simple.java

package info (click to toggle)
jasmin-sable 2.4.0-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,232 kB
  • ctags: 1,458
  • sloc: java: 9,167; xml: 109; makefile: 19; csh: 16; sh: 1
file content (44 lines) | stat: -rw-r--r-- 1,208 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import jas.*;
import java.io.*;

//
// This is program that makes calls into the jas package
// to generate a class that does nothing at all.
//

class simple implements RuntimeConstants
{
  public static void main(String argv[])
    throws jasError, IOException
  {

                                // CodeAttr's contain the body of
                                // a method.

    CodeAttr init = new CodeAttr();
    init.addInsn(new Insn(opc_aload_0));
    init.addInsn(new Insn(opc_invokenonvirtual,
                          new MethodCP("java/lang/Object", "<init>", "()V")));
    init.addInsn(new Insn(opc_return));


                                // ClassEnv's are used as a container
                                // to hold all information about a class.

    ClassEnv nclass = new ClassEnv();
    nclass.setClass(new ClassCP("out"));
    nclass.setSuperClass(new ClassCP("java/lang/Object"));



                                // Add the init code to the class.
    nclass.addMethod((short)ACC_PUBLIC, "<init>", "()V", init, null);


                                // write it all out
    nclass.write(new DataOutputStream
                 (new FileOutputStream("out.class")));
  }
}