| 1 | <H2>Class Evolution</H2> |
| 2 | |
| 3 | <P>This is a demonstration of the class evolution mechanism |
| 4 | implemented with Javassist. This mechanism enables a Java program to |
| 5 | reload an existing class file. Although the reloaded class file is |
| 6 | not applied to exiting objects (the old class file is used for those |
| 7 | objects), it is effective in newly created objects. |
| 8 | |
| 9 | <P>Since the reloading is transparently executed, no programming |
| 10 | convention is needed. However, there are some limitations on possible |
| 11 | changes of the class definition. For example, the new class definition |
| 12 | must have the same set of methods as the old one. These limitations are |
| 13 | necessary 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 |
| 19 | calls <code>show()</code> on that object. This method works as |
| 20 | if it is a CGI script or a servlet and you will see the html file |
| 21 | produced 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> |
| 26 | on the local disk. Then it signals that <code>WebPage.class</code> |
| 27 | must be reloaded into the JVM. If you run <code>WebPage.show()</code> |
| 28 | again, 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 |
| 35 | another <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>. |