Re: Realtime class update
Lew wrote:
Not that I know of, but happy to be surpised.
Then be happy. It's possible using the debugger hooks. There was an
article by Daniel Savarese in JavaPro about it, probably still findable.
I didn't found it. But now (since 1.5) the instrumentation allows it also:
<http://java.sun.com/javase/6/docs/api/java/lang/instrument/Instrumentation.html#redefineClasses(java.lang.instrument.ClassDefinition...)>
The only JVM I know, which fully supports it (including "schema change"
HotSwap) is the J9VM (from IBM).
Fortunately, most of major JVMs allows for redefining executable code of
a class, which usually is enough. If not enough...
You can also play ClassLoader games to load the new version, letting the
old one die and get garbage collected, but getting client classes to
recognize the switch is hard, from what I hear. I tend to avoid such
complications.
It depends on what is expected. Sometimes it's also desired to have the
old clients still using old versions of the classes, and a new classes
available for the new clients only (see "Hot Code Changes" section at
Java Glossary page linked by Roedy). Otherwise, you may reference all
objects non-directly, e.g. via the map (or cache). But, of course,
using instrumentation (or JPDA) is easier in such a case.
piotr