• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<H2>Class Evolution</H2>
2
3<P>This is a demonstration of the class evolution mechanism
4implemented with Javassist.  This mechanism enables a Java program to
5reload an existing class file.  Although the reloaded class file is
6not applied to exiting objects (the old class file is used for those
7objects), it is effective in newly created objects.
8
9<P>Since the reloading is transparently executed, no programming
10convention is needed.  However, there are some limitations on possible
11changes of the class definition.  For example, the new class definition
12must have the same set of methods as the old one.  These limitations are
13necessary for keeping the type system consistent.
14
15
16<H3><a href="java.html">Run WebPage.show()</a></H3>
17
18<P>The web server creates a new <code>WebPage</code> object and
19calls <code>show()</code> on that object.  This method works as
20if it is a CGI script or a servlet and you will see the html file
21produced by this method on your browser.
22
23<H3><a href="update.html">Change WebPage.class</a></H3>
24
25<P>The web server overwrites class file <code>WebPage.class</code>
26on the local disk.  Then it signals that <code>WebPage.class</code>
27must be reloaded into the JVM.  If you run <code>WebPage.show()</code>
28again, you will see a different page on your browser.
29
30<H3>Source files</H3>
31
32<P>Web server: <A HREF="DemoServer.java"><code>DemoServer.java</code></A>
33
34<P>WebPage: <A HREF="WebPage.java"><code>WebPage.java</code></A> and
35another  <A HREF="sample/evolve/WebPage.java"><code>WebPage.java</code></A>
36
37<P>Class loader: <A HREF="DemoLoader.java"><code>DemoLoader.java</code></A>,
38	<A HREF="Evolution.java"><code>Evolution.java</code></A>, and
39	<A HREF="VersionManager.java"><code>VersionManager.java</code></A>.
40