aboutsummaryrefslogtreecommitdiffstats
path: root/sample
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2005-06-21 16:39:16 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2005-06-21 16:39:16 +0000
commitaa0900d4cf6479bc598951ea446ea3f5f95a23b6 (patch)
tree50c3f9505a0df1d86805bae0c29073d3bc909959 /sample
parent5de7634f05f343ff9573e140ea78a224d4ae3aa4 (diff)
downloadjavassist-aa0900d4cf6479bc598951ea446ea3f5f95a23b6.tar.gz
javassist-aa0900d4cf6479bc598951ea446ea3f5f95a23b6.zip
HotSwap support
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@184 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'sample')
-rw-r--r--sample/hotswap/HelloWorld.java5
-rw-r--r--sample/hotswap/Test.java25
-rw-r--r--sample/hotswap/logging/HelloWorld.java6
3 files changed, 36 insertions, 0 deletions
diff --git a/sample/hotswap/HelloWorld.java b/sample/hotswap/HelloWorld.java
new file mode 100644
index 00000000..51d8fcd9
--- /dev/null
+++ b/sample/hotswap/HelloWorld.java
@@ -0,0 +1,5 @@
+public class HelloWorld {
+ public void print() {
+ System.out.println("hello world");
+ }
+}
diff --git a/sample/hotswap/Test.java b/sample/hotswap/Test.java
new file mode 100644
index 00000000..c0ae1771
--- /dev/null
+++ b/sample/hotswap/Test.java
@@ -0,0 +1,25 @@
+import java.io.*;
+import javassist.tool.HotSwapper;
+
+public class Test {
+ public static void main(String[] args) throws Exception {
+ HotSwapper hs = new HotSwapper(8000);
+ new HelloWorld().print();
+
+ File newfile = new File("logging/HelloWorld.class");
+ byte[] bytes = new byte[(int)newfile.length()];
+ new FileInputStream(newfile).read(bytes);
+ System.out.println("** reload a logging version");
+
+ hs.reload("HelloWorld", bytes);
+ new HelloWorld().print();
+
+ newfile = new File("HelloWorld.class");
+ bytes = new byte[(int)newfile.length()];
+ new FileInputStream(newfile).read(bytes);
+ System.out.println("** reload the original version");
+
+ hs.reload("HelloWorld", bytes);
+ new HelloWorld().print();
+ }
+}
diff --git a/sample/hotswap/logging/HelloWorld.java b/sample/hotswap/logging/HelloWorld.java
new file mode 100644
index 00000000..88f08664
--- /dev/null
+++ b/sample/hotswap/logging/HelloWorld.java
@@ -0,0 +1,6 @@
+public class HelloWorld {
+ public void print() {
+ System.out.println("** HelloWorld.print()");
+ System.out.println("hello world");
+ }
+}