01: package org.apache.bcel.classfile;
02:
03: import java.io.*;
04:
05: /**
06: * Circumvent package private access.
07: *
08: * @author Johann Gyger
09: */
10: public class ProseSupport {
11:
12: /**
13: * Create new BCEL constant pool based on <code>code</code>.
14: *
15: * @param code constant pool bytecode
16: * @return New BCEL constant pool
17: */
18: public static ConstantPool getConstantPool(byte[] code) {
19: try {
20: return new ConstantPool(new DataInputStream(
21: new ByteArrayInputStream(code)));
22: } catch (IOException e) {
23: throw new RuntimeException("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(
37: new ByteArrayInputStream(code)), cp);
38: } catch (IOException e) {
39: throw new RuntimeException("Invalid bytecode", e);
40: }
41: }
42:
43: }
|