1 import java.io.*;
2 import javassist.util.HotSwapper;
3 
4 public class Test {
main(String[] args)5     public static void main(String[] args) throws Exception {
6         HotSwapper hs = new HotSwapper(8000);
7         new HelloWorld().print();
8 
9         File newfile = new File("logging/HelloWorld.class");
10         byte[] bytes = new byte[(int)newfile.length()];
11         new FileInputStream(newfile).read(bytes);
12         System.out.println("** reload a logging version");
13 
14         hs.reload("HelloWorld", bytes);
15         new HelloWorld().print();
16 
17         newfile = new File("HelloWorld.class");
18         bytes = new byte[(int)newfile.length()];
19         new FileInputStream(newfile).read(bytes);
20         System.out.println("** reload the original version");
21 
22         hs.reload("HelloWorld", bytes);
23         new HelloWorld().print();
24     }
25 }
26