From 9b1411e58b65a464f1d92ba1dbdbf00494ca9ffd Mon Sep 17 00:00:00 2001 From: chiba Date: Fri, 24 Jun 2005 09:35:11 +0000 Subject: [PATCH] updates comments git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@186 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- build.xml | 27 ++++++++++++++++++----- sample/evolve/DemoServer.java | 3 ++- sample/evolve/WebPage.class.0 | Bin 686 -> 0 bytes sample/evolve/WebPage.class.1 | Bin 812 -> 0 bytes sample/evolve/WebPage.java | 14 ------------ sample/evolve/demo.html | 3 ++- sample/evolve/sample/evolve/WebPage.java | 20 +++++++++++++++++ sample/evolve/start.html | 14 ++++++------ tutorial/tutorial.html | 21 +++++++++++++++++- 9 files changed, 72 insertions(+), 30 deletions(-) delete mode 100644 sample/evolve/WebPage.class.0 delete mode 100644 sample/evolve/WebPage.class.1 create mode 100644 sample/evolve/sample/evolve/WebPage.java 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 3cc1d7430025b63f50db0668f0dc8add6665aa63..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 686 zcmYjP+iu!G5IxJy)HRntdP|hXp*ILEe&}N;Qbd!s5-m{@5#@1#mD$MNMP^O zj}4pDB^w!RIH;rQ;5jM|USrR}OYAdj)*HPmKIdM*mG7OINGkt;p>hYuMh4zTZUlkV zrBG_`OaJKmNKB2?ilNZeYG$}H10KYJ!M^8a45gk_;#(XJMRd-G0nx>!$-ON@W;W5+ zRCcE0Xe5qhBHCVyK1IUUk>sk&1EIz|B8#3L@nFCSB}?j(>FP06<&9n)fMK`3Iu#Au zkIghTL!l2eU6()|9YqV=7!ky?) zxKpxiwY@{Kw0vRCWk~hTZNFC1gdtsT46uh3{o~|Gf#Df;Deur%hjNkef`IlF&@!rCCW M1RaW7M5fUA2f4AIhX4Qo diff --git a/sample/evolve/WebPage.class.1 b/sample/evolve/WebPage.class.1 deleted file mode 100644 index fe49380ed1ae79191040847d263879934f1f7453..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 812 zcmYjPZBH6O5Pnu(jv}H(!CI?cX>CD}YwNdqUScQ|6AA_irb)jnxPdcwx8&Hv{;ht| zq)qw*`lFi8p+YaYncZienR#Y2fBydbjR+3$K7mpKl?03g3L4&M*w(PGVN*jt@D}eFHVVb&HJ@_B;oi`=P`>RAj~OzL zaG-3*_{5bUaD7I!rE%7-eIJOivZcqcQkC9BaZmNQ69|UnJT_riZQ7n_1#VyXUEX&n zoSqe#mt}}fM)HQzE@a>jMBNTa+Y8cXUks&hbFa!B;azc`N;KtwJ3US)m834ws=T7C zgp&6IFzglXry{ZKK#c=M0m0o%-&VpuF7_UEQ2ZWa$Uda}{}3T@ZSg$q{(YP52PdglYF1vC{K*cV#38> zv71mI!;yJznWuWAQ>&lkuY@ZrBjq}It0Pq4d%BXk8VP+QU7?Suam6%FsiZa(s%yKH zpL$SK37atF%*F?+8u-5OlpZoZng$^ZTc#0ev*=1Pjk)Fy#Uh1bkM<-+n-qRaV0eK% zd7WReturn 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


-- 2.39.5