blob: 0cff5538fffc9649faf97a2e24a8c2ea97211fc0 (
plain)
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
|
package javassist.compiler;
import java.io.*;
import javassist.*;
import javassist.bytecode.*;
public class CodeTest implements TokenId {
public static void main(String[] args) throws Exception {
ClassPool loader = ClassPool.getDefault();
CtClass c = loader.get(args[0]);
String line
= new BufferedReader(new InputStreamReader(System.in)).readLine();
Bytecode b = new Bytecode(c.getClassFile().getConstPool(), 0, 0);
Javac jc = new Javac(b, c);
CtMember obj = jc.compile(line);
if (obj instanceof CtMethod)
c.addMethod((CtMethod)obj);
else
c.addConstructor((CtConstructor)obj);
c.writeFile();
}
}
|