KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > bcel > classfile > ProseSupport


1 package org.apache.bcel.classfile;
2
3 import java.io.*;
4
5 /**
6  * Circumvent package private access.
7  *
8  * @author Johann Gyger
9  */

10 public class ProseSupport {
11
12
13   /**
14    * Create new BCEL constant pool based on <code>code</code>.
15    *
16    * @param code constant pool bytecode
17    * @return New BCEL constant pool
18    */

19   public static ConstantPool getConstantPool(byte[] code) {
20     try {
21       return new ConstantPool(new DataInputStream(new ByteArrayInputStream(code)));
22     } catch (IOException e) {
23       throw new RuntimeException JavaDoc("Invalid bytecode", e);
24     }
25   }
26
27   /**
28    * Create new BCEL method based on <code>code</code>.
29    *
30    * @param code method bytecode
31    * @param cp
32    * @return New BCEL method
33    */

34   public static Method getMethod(byte[] code, ConstantPool cp) {
35     try {
36       return new Method(new DataInputStream(new ByteArrayInputStream(code)), cp);
37     } catch (IOException e) {
38       throw new RuntimeException JavaDoc("Invalid bytecode", e);
39     }
40   }
41
42 }
43
Popular Tags