]> source.dussan.org Git - javassist.git/commitdiff
updates comments
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Fri, 24 Jun 2005 09:35:11 +0000 (09:35 +0000)
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Fri, 24 Jun 2005 09:35:11 +0000 (09:35 +0000)
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@186 30ef5769-5b8d-40dd-aea6-55b5d6557bb3

build.xml
sample/evolve/DemoServer.java
sample/evolve/WebPage.class.0 [deleted file]
sample/evolve/WebPage.class.1 [deleted file]
sample/evolve/WebPage.java
sample/evolve/demo.html
sample/evolve/sample/evolve/WebPage.java [new file with mode: 0644]
sample/evolve/start.html
tutorial/tutorial.html

index 3c3e3bdccf1ed67e338d2c873ee8bd7711110e0f..9663a986539b2dc472c53a3f9de930343e53e130 100644 (file)
--- a/build.xml
+++ b/build.xml
            deprecation="on"
            optimize="off"
            includes="sample/**"
-           excludes="sample/hotswap/**">
+           excludes="sample/hotswap/**,sample/evolve/sample/**">
             <classpath refid="classpath"/>
     </javac>
+
+    <copy file="sample/vector/Test.j"
+          todir="${build.classes.dir}/sample/vector"/>
+
+    <javac srcdir="${basedir}/sample/evolve"
+           destdir="${build.classes.dir}/sample/evolve/"
+           debug="on"
+           deprecation="on"
+           optimize="off"
+           includes="sample/**">
+            <classpath refid="classpath"/>
+    </javac>
+    <copy todir="${build.classes.dir}/sample/evolve">
+      <fileset dir="sample/evolve"/>
+    </copy>
+    <copy file="${build.classes.dir}/sample/evolve/WebPage.class"
+          tofile="${build.classes.dir}/sample/evolve/WebPage.class.0"/>
+    <copy file="${build.classes.dir}/sample/evolve/sample/evolve/WebPage.class"
+          tofile="${build.classes.dir}/sample/evolve/WebPage.class.1"/>
+
     <javac srcdir="${basedir}/sample/hotswap"
            destdir="${build.classes.dir}"
            debug="on"
            includes="*">
             <classpath refid="classpath"/>
     </javac>
-    <copy file="sample/vector/Test.j"
-          todir="${build.classes.dir}/sample/vector"/>
-    <copy todir="${build.classes.dir}/sample/evolve">
-      <fileset dir="sample/evolve"/>
-    </copy>
     <echo>To run the sample programs without ant, change the current directory 
 to ${build.classes.dir}.</echo>
   </target>
index d69d055fc06a447882a17765c4f4977c5401c774..dd64c55070fe7ef3ab5cbdca8e350a06a2212618 100644 (file)
@@ -19,7 +19,8 @@ import java.io.*;
  * server overwrites WebPage.class (class file) and calls update()\r
  * in VersionManager so that WebPage.class is loaded into the JVM\r
  * again.  The new contents of WebPage.class are copied from\r
- * either WebPage.class.0 or WebPage.class.1.\r
+ * either sample/evolve/WebPage.class\r
+ * or sample/evolve/sample/evolve/WebPage.class.\r
  */\r
 public class DemoServer extends Webserver {\r
 \r
diff --git a/sample/evolve/WebPage.class.0 b/sample/evolve/WebPage.class.0
deleted file mode 100644 (file)
index 3cc1d74..0000000
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 (file)
index fe49380..0000000
Binary files a/sample/evolve/WebPage.class.1 and /dev/null differ
index 7c2b7cfb80f099fba5580287d8d3ddcd7f436e41..7d420fef8cccc1b11d054944dcb3e9dc039558f6 100644 (file)
@@ -8,7 +8,6 @@ import java.util.*;
  * show() on the created object.\r
  */\r
 \r
-// WebPage.class.0\r
 public class WebPage {\r
     public void show(OutputStreamWriter out) throws IOException {\r
        Calendar c = new GregorianCalendar();\r
@@ -16,16 +15,3 @@ public class WebPage {
        out.write("<P><A HREF=\"demo.html\">Return to the home page.</A>");\r
     }\r
 }\r
-/*\r
-// WebPage.class.1\r
-public class WebPage {\r
-    public void show(OutputStreamWriter out) throws IOException {\r
-       out.write("<H2>Current Time:</H2>");\r
-       Calendar c = new GregorianCalendar();\r
-       out.write("<CENTER><H3><FONT color=\"blue\">");\r
-       out.write(c.getTime().toString());\r
-       out.write("</FONT></H3></CENTER><HR>");\r
-       out.write("<P><A HREF=\"demo.html\">Return to the home page.</A>");\r
-    }\r
-}\r
-*/\r
index 6be4a2c391cc6cd3a13248f5509b9802af50542d..3eedf3da5a0c9cd207783c3ac56a624c391cc850 100644 (file)
@@ -31,7 +31,8 @@ again, you will see a different page on your browser.
 \r
 <P>Web server: <A HREF="DemoServer.java"><code>DemoServer.java</code></A>\r
 \r
-<P>WebPage: <A HREF="WebPage.java"><code>WebPage.java</code></A>\r
+<P>WebPage: <A HREF="WebPage.java"><code>WebPage.java</code></A> and\r
+another  <A HREF="sample/evolve/WebPage.java"><code>WebPage.java</code></A>\r
 \r
 <P>Class loader: <A HREF="DemoLoader.java"><code>DemoLoader.java</code></A>,\r
        <A HREF="Evolution.java"><code>Evolution.java</code></A>, and\r
diff --git a/sample/evolve/sample/evolve/WebPage.java b/sample/evolve/sample/evolve/WebPage.java
new file mode 100644 (file)
index 0000000..507b956
--- /dev/null
@@ -0,0 +1,20 @@
+package sample.evolve;\r
+\r
+import java.io.*;\r
+import java.util.*;\r
+\r
+/**\r
+ * Updatable class.  DemoServer instantiates this class and calls\r
+ * show() on the created object.\r
+ */\r
+\r
+public class WebPage {\r
+    public void show(OutputStreamWriter out) throws IOException {\r
+       out.write("<H2>Current Time:</H2>");\r
+       Calendar c = new GregorianCalendar();\r
+       out.write("<CENTER><H3><FONT color=\"blue\">");\r
+       out.write(c.getTime().toString());\r
+       out.write("</FONT></H3></CENTER><HR>");\r
+       out.write("<P><A HREF=\"demo.html\">Return to the home page.</A>");\r
+    }\r
+}\r
index d31d9d0856a89c630f7bb2e61d979f09bb893a79..8ab3f940152bf7a5cd20c7d26d484f0cfab5775e 100644 (file)
@@ -1,14 +1,14 @@
 <h2>Instructions</h2>\r
 \r
 <p>1. Compile <code>sample/evolve/*.java</code>.\r
-       Copy <code>WebPage.class</code> to <code>WebPage.class.0</code>.\r
 \r
-<p>2. Edit <code>Webpage.java</code>, compile it,\r
-       and copy <code>WebPage.class</code> to <code>WebPage.class.1</code>.\r
-<br><code>WebPage.class.0</code> and\r
-       <code>WebPage.class.1</code> are used\r
-       for changing the contents of <code>WebPage.class</code> during\r
-       the demo.\r
+<p>2. change the current directory to <code>sample/evolve</code><br>\r
+and compile there <code>sample/evolve/WebPage.java</code><br>\r
+(i.e. compile <code>sample/evolve/sample/evolve/WebPage.java</code>).\r
+\r
+<p>The two versions of <code>WebPage.class</code> are used<br>\r
+for changing the contents of <code>WebPage.class</code> during\r
+the demo.\r
 \r
 <p>3. Run the server on the local host (where your web browser is running):\r
 \r
index 709d21482c69df9d53b501a54c9e8634076de32a..4670424e170d9b6cdcb925f72e89f558387d37b0 100644 (file)
@@ -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 <a href="#hotswap">Section 3.6</a>.
 </ul>
 
 <p>If the same class file is loaded by two distinct class loaders,
@@ -999,6 +1000,24 @@ binary code license.</i>
 
 <p><br>
 
+<a name="hotswap">
+<h3>3.6 Reloading a class at runtime</h3></a>
+
+<p>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.
+<em>The JVM does not allow schema changes between the two versions.</em>
+They have the same set of methods and fields.
+
+<p>Javassist provides a convenient class for reloading a class at runtime.
+For more information, see the API documentation of
+<code>javassist.tool.HotSwapper</code>.
+
+<p><br>
+
 <a href="tutorial2.html">Next page</a>
 
 <hr>