|
From: Updike, C. <Cla...@jh...> - 2002-01-28 15:17:38
|
regarding http://www.jython.org/docs/jreload.html and the statement: "Why there is no support for reloading a single class? Java classes are loaded through class-loaders, actually there is no support in java to redefine an already loaded class through its class-loader." I don't mean to split hairs here, but it IS actually possible to redefine an already-loaded class in the same classloader as long as you use Class methods to load it. i.e. use: Class redefineable = Class.forName("MyRedefinealbeClass"); redefineable.newInstance(); // Assume the previous version of MyRedefineableClass.class was modified // Reload the new one... redefineable = null; System.gc(); Class redefineable = Class.forName("MyRedefineableClass"); redefineable.newInstance(); Instead of: MyUNRedefinableClass unRedefineable = new MyUNRedefineableClass(); murdc = null; // does NOT pick up any changes to MyRedefineableClass.class unRedefineable = new MyUNRedefineableClass(); This functionality is described in the following article, http://www.sys-con.com/java/articleprint.cfm?id=307 I don't know if this adds any new possibilities for jreload or not (or if I'm wrong), but thought it worth pointing out anyway. Note that the article makes a call to System.gc() to "force" the classloader to dump the current version but I don't believe System.gc() guarantees that this will happen. -Clark |