Skip to content

Commit

Permalink
updates comments
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@186 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
  • Loading branch information
chiba committed Jun 24, 2005
1 parent cb8fe91 commit 9b1411e
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 30 deletions.
27 changes: 21 additions & 6 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,29 @@
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"
Expand All @@ -72,11 +92,6 @@
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>
Expand Down
3 changes: 2 additions & 1 deletion sample/evolve/DemoServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
* 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 {

Expand Down
Binary file removed sample/evolve/WebPage.class.0
Binary file not shown.
Binary file removed sample/evolve/WebPage.class.1
Binary file not shown.
14 changes: 0 additions & 14 deletions sample/evolve/WebPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,10 @@
* show() on the created object.
*/

// WebPage.class.0
public class WebPage {
public void show(OutputStreamWriter out) throws IOException {
Calendar c = new GregorianCalendar();
out.write(c.getTime().toString());
out.write("<P><A HREF=\"demo.html\">Return to the home page.</A>");
}
}
/*
// WebPage.class.1
public class WebPage {
public void show(OutputStreamWriter out) throws IOException {
out.write("<H2>Current Time:</H2>");
Calendar c = new GregorianCalendar();
out.write("<CENTER><H3><FONT color=\"blue\">");
out.write(c.getTime().toString());
out.write("</FONT></H3></CENTER><HR>");
out.write("<P><A HREF=\"demo.html\">Return to the home page.</A>");
}
}
*/
3 changes: 2 additions & 1 deletion sample/evolve/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ <H3>Source files</H3>

<P>Web server: <A HREF="DemoServer.java"><code>DemoServer.java</code></A>

<P>WebPage: <A HREF="WebPage.java"><code>WebPage.java</code></A>
<P>WebPage: <A HREF="WebPage.java"><code>WebPage.java</code></A> and
another <A HREF="sample/evolve/WebPage.java"><code>WebPage.java</code></A>

<P>Class loader: <A HREF="DemoLoader.java"><code>DemoLoader.java</code></A>,
<A HREF="Evolution.java"><code>Evolution.java</code></A>, and
Expand Down
20 changes: 20 additions & 0 deletions sample/evolve/sample/evolve/WebPage.java
Original file line number Diff line number Diff line change
@@ -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("<H2>Current Time:</H2>");
Calendar c = new GregorianCalendar();
out.write("<CENTER><H3><FONT color=\"blue\">");
out.write(c.getTime().toString());
out.write("</FONT></H3></CENTER><HR>");
out.write("<P><A HREF=\"demo.html\">Return to the home page.</A>");
}
}
14 changes: 7 additions & 7 deletions sample/evolve/start.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<h2>Instructions</h2>

<p>1. Compile <code>sample/evolve/*.java</code>.
Copy <code>WebPage.class</code> to <code>WebPage.class.0</code>.

<p>2. Edit <code>Webpage.java</code>, compile it,
and copy <code>WebPage.class</code> to <code>WebPage.class.1</code>.
<br><code>WebPage.class.0</code> and
<code>WebPage.class.1</code> are used
for changing the contents of <code>WebPage.class</code> during
the demo.
<p>2. change the current directory to <code>sample/evolve</code><br>
and compile there <code>sample/evolve/WebPage.java</code><br>
(i.e. compile <code>sample/evolve/sample/evolve/WebPage.java</code>).

<p>The two versions of <code>WebPage.class</code> are used<br>
for changing the contents of <code>WebPage.class</code> during
the demo.

<p>3. Run the server on the local host (where your web browser is running):

Expand Down
21 changes: 20 additions & 1 deletion tutorial/tutorial.html
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,8 @@ <h3>3.2 Class loading in Java</h3>
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,
Expand Down Expand Up @@ -999,6 +1000,24 @@ <h3>3.5 Modifying a system class</h3>

<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>
Expand Down

0 comments on commit 9b1411e

Please sign in to comment.