[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re-reading an edited class definition

On Wed, Jan 26, 2000 at 07:54:38PM -0600, Chuck Irvine wrote:
> Say I have a class, Foo, that I am working on and I am ready to test it
> using bsh. So I do something like:
> Bsh % Foo f = new Foo();   // create an object
> Bsh % f.test(); // test the function test
> Now I find a problem in test() and recode it. In this case, I have not
> discovered how to get bsh to re-read in the new definition of Foo. What I
> have to do is exit and re-start bsh. Is there a way to re “source” class,
> and, if so, how? Actually, I see that there is a “source” built in function,
> but it doesn’t seem to have the hoped for function.

To have the capability of reloading classes we'll need to use an explicit
classloader.  In JDK1.2+ there is the java.net.URLClassLoader which is quite
easy to use.  It should be possible to simply load your classes through it 
and then throw it away and reload them.

I'd like to add some built in support for this in BeanShell in an upcoming
release.  I just haven't determined all of the ramifications.  It is a pretty
high priority desired feature.