[DGD] Java or LPC (DGD)?

Felix A. Croes felix at dworkin.nl
Sun Aug 10 23:58:47 CEST 2003


I've looked further into the issue of class reloading for Java.

The only way to accomplish this is to split each class in two: a
wrapper class which contains the values, and a wrapped class for
the program code which may be updated.  The wrapper class must create
the wrapped class using a private ClassLoader instance.  To upgrade
the wrapped class, a new ClassLoader instance must also be created.

The wrapper class must forward method invocations to the wrapped class
using the reflection API, passing an array of Object arguments and an
array of Object field values, returning an Object value.  Done in this
way, you can't have typechecking for method arguments and return values
at compile time.  However, you can still have them at runtime with the
appropriate casts.  The alternative would be to let the wrapper and
wrapped class both implement the same interface.  This would allow for
compile-time typechecking, but then the interface is fixed and cannot
be changed.

Furthermore, since each ClassLoader defines its own class namespace,
a simulated global object namespace will have to be created which the
ClassLoaders can use to find wrapped classes to inherit from.

You could create a Java preprocessor which properly translates method
invocations and field access in normal Java source code, allowing the
wrapper/wrapped pairs to simulate ordinary Java classes.

What I previously referred to as "the problem of dependencies" is not
generally solvable.  Old instances referred to by the thread of
execution will continue to exist side by side with new ones, resulting
in possible problems until the old instances are no longer used.

Regards,
Dworkin
_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list