1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.bcel.verifier.tests;
18
19 import java.io.IOException;
20 import java.io.OutputStream;
21
22 import org.apache.bcel.Const;
23 import org.apache.bcel.generic.ClassGen;
24 import org.apache.bcel.generic.InstructionConst;
25 import org.apache.bcel.generic.InstructionList;
26 import org.apache.bcel.generic.MethodGen;
27 import org.apache.bcel.generic.Type;
28
29 public class TestThrow01Creator extends TestCreator {
30 private final ClassGen cg;
31
32 public TestThrow01Creator() {
33 cg = new ClassGen(TEST_PACKAGE + ".TestThrow01", "java.lang.Object", "TestThrow01.java", Const.ACC_PUBLIC | Const.ACC_SUPER, new String[] {});
34 }
35
36 @Override
37 public void create(final OutputStream out) throws IOException {
38 final InstructionList il = new InstructionList();
39 final MethodGen method = new MethodGen(Const.ACC_STATIC, Type.VOID, Type.NO_ARGS, new String[0], "b", cg.getClassName(), il, cg.getConstantPool());
40 il.append(InstructionConst.getInstruction(Const.ATHROW));
41 method.setMaxStack();
42 method.setMaxLocals();
43 cg.addMethod(method.getMethod());
44 il.dispose();
45 cg.getJavaClass().dump(out);
46 }
47 }