From: chiba Date: Fri, 24 Jun 2005 09:35:11 +0000 (+0000) Subject: updates comments X-Git-Tag: rel_3_17_1_ga~438 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9b1411e58b65a464f1d92ba1dbdbf00494ca9ffd;p=javassist.git updates comments git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@186 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- diff --git a/build.xml b/build.xml index 3c3e3bdc..9663a986 100644 --- a/build.xml +++ b/build.xml @@ -52,9 +52,29 @@ deprecation="on" optimize="off" includes="sample/**" - excludes="sample/hotswap/**"> + excludes="sample/hotswap/**,sample/evolve/sample/**"> + + + + + + + + + + + + - - - - To run the sample programs without ant, change the current directory to ${build.classes.dir}. diff --git a/sample/evolve/DemoServer.java b/sample/evolve/DemoServer.java index d69d055f..dd64c550 100644 --- a/sample/evolve/DemoServer.java +++ b/sample/evolve/DemoServer.java @@ -19,7 +19,8 @@ import java.io.*; * server overwrites WebPage.class (class file) and calls update() * in VersionManager so that WebPage.class is loaded into the JVM * again. The new contents of WebPage.class are copied from - * either WebPage.class.0 or WebPage.class.1. + * either sample/evolve/WebPage.class + * or sample/evolve/sample/evolve/WebPage.class. */ public class DemoServer extends Webserver { diff --git a/sample/evolve/WebPage.class.0 b/sample/evolve/WebPage.class.0 deleted file mode 100644 index 3cc1d743..00000000 Binary files a/sample/evolve/WebPage.class.0 and /dev/null differ diff --git a/sample/evolve/WebPage.class.1 b/sample/evolve/WebPage.class.1 deleted file mode 100644 index fe49380e..00000000 Binary files a/sample/evolve/WebPage.class.1 and /dev/null differ diff --git a/sample/evolve/WebPage.java b/sample/evolve/WebPage.java index 7c2b7cfb..7d420fef 100644 --- a/sample/evolve/WebPage.java +++ b/sample/evolve/WebPage.java @@ -8,7 +8,6 @@ import java.util.*; * show() on the created object. */ -// WebPage.class.0 public class WebPage { public void show(OutputStreamWriter out) throws IOException { Calendar c = new GregorianCalendar(); @@ -16,16 +15,3 @@ public class WebPage { out.write("

Return to the home page."); } } -/* -// WebPage.class.1 -public class WebPage { - public void show(OutputStreamWriter out) throws IOException { - out.write("

Current Time:

"); - Calendar c = new GregorianCalendar(); - out.write("

"); - out.write(c.getTime().toString()); - out.write("


"); - out.write("

Return to the home page."); - } -} -*/ diff --git a/sample/evolve/demo.html b/sample/evolve/demo.html index 6be4a2c3..3eedf3da 100644 --- a/sample/evolve/demo.html +++ b/sample/evolve/demo.html @@ -31,7 +31,8 @@ again, you will see a different page on your browser.

Web server: DemoServer.java -

WebPage: WebPage.java +

WebPage: WebPage.java and +another WebPage.java

Class loader: DemoLoader.java, Evolution.java, and diff --git a/sample/evolve/sample/evolve/WebPage.java b/sample/evolve/sample/evolve/WebPage.java new file mode 100644 index 00000000..507b9564 --- /dev/null +++ b/sample/evolve/sample/evolve/WebPage.java @@ -0,0 +1,20 @@ +package sample.evolve; + +import java.io.*; +import java.util.*; + +/** + * Updatable class. DemoServer instantiates this class and calls + * show() on the created object. + */ + +public class WebPage { + public void show(OutputStreamWriter out) throws IOException { + out.write("

Current Time:

"); + Calendar c = new GregorianCalendar(); + out.write("

"); + out.write(c.getTime().toString()); + out.write("


"); + out.write("

Return to the home page."); + } +} diff --git a/sample/evolve/start.html b/sample/evolve/start.html index d31d9d08..8ab3f940 100644 --- a/sample/evolve/start.html +++ b/sample/evolve/start.html @@ -1,14 +1,14 @@

Instructions

1. Compile sample/evolve/*.java. - Copy WebPage.class to WebPage.class.0. -

2. Edit Webpage.java, compile it, - and copy WebPage.class to WebPage.class.1. -
WebPage.class.0 and - WebPage.class.1 are used - for changing the contents of WebPage.class during - the demo. +

2. change the current directory to sample/evolve
+and compile there sample/evolve/WebPage.java
+(i.e. compile sample/evolve/sample/evolve/WebPage.java). + +

The two versions of WebPage.class are used
+for changing the contents of WebPage.class during +the demo.

3. Run the server on the local host (where your web browser is running): diff --git a/tutorial/tutorial.html b/tutorial/tutorial.html index 709d2148..4670424e 100644 --- a/tutorial/tutorial.html +++ b/tutorial/tutorial.html @@ -584,7 +584,8 @@ Once a class loader loads a class, it cannot reload a modified version of that class during runtime. Thus, you cannot alter the definition of a class after the JVM loads it. However, the JPDA (Java Platform Debugger Architecture) provides -limited ability for reloading a class. See "HotSwap" of JPDA for details. +limited ability for reloading a class. +See Section 3.6.

If the same class file is loaded by two distinct class loaders, @@ -999,6 +1000,24 @@ binary code license.


+ +

3.6 Reloading a class at runtime

+ +

If the JVM is launched with the JPDA (Java Platform Debugger +Architecture) enabled, a class is dynamically reloadable. After the +JVM loads a class, the old version of the class definition can be +unloaded and a new one can be reloaded again. That is, the definition +of that class can be dynamically modified during runtime. However, +the new class definition must be somewhat compatible to the old one. +The JVM does not allow schema changes between the two versions. +They have the same set of methods and fields. + +

Javassist provides a convenient class for reloading a class at runtime. +For more information, see the API documentation of +javassist.tool.HotSwapper. + +


+ Next page