Andres_D is right, we can do this very well using custom class loading, here is a detailed guide on how to do this: http://www.javaworld.com/javaworld/jw-06-2006/jw-0612-dynamic.html ? page = 1
This article explains how to write dynamic Java code. It discusses compiling source execution code, reloading classes, and using a proxy design pattern to make changes to a dynamic class that is transparent to its caller.
In fact, a researcher in Austria wrote a JVM that even allows you to reload classes with different type hierarchies. They accomplished this by using the existing stream persistence points to generate the full “lateral universe” of the object and all the links and link content associated with it, and then after dragging and dropping with all the necessary changes, they simply replace all the changed classes. [1] Here is a link to their project http://ssw.jku.at/dcevm/ Oracle sponsorship certainly provokes interesting thoughts about future plans.
Less intrusive changes to the bodies and fields of methods are already possible in a standard virtual Java environment using the JPDA hot-swap capabilities, as presented in Java 1.4:
docs.oracle.com/javase/1.4.2/docs/guide/jpda/enhancements.html#hotswap
I'm not sure if he was the first, but this 2001 Sun employee document seems to be one of the earliest suggestions that mention HotSpot's hot-swap capabilities. [2]
LINK
[1] T. Würthinger, C. Wimmer, and L. Stadler, “Dynamic Code Evolution for Java,” presented at the 8th International Conference on Java Programming Principles and Practices, Vienna, 2010
[2] M. Dmitriev, "Towards Flexible and Secure Technologies for Developing Java Application Runtime Applications," in the OOPSLA Workshop on Engineering-Complex Object-Oriented Systems for Evolution, 2001
DrGranit Sep 14 '12 at 23:26 2012-09-14 23:26
source share