This is the mail archive of the
kawa@sourceware.cygnus.com
mailing list for the Kawa project.
Re: Changing classpath whilst Kawa runs
- To: "Nic Ferrier" <nferrier at tapsellferrier dot co dot uk>
- Subject: Re: Changing classpath whilst Kawa runs
- From: Per Bothner <per at bothner dot com>
- Date: 29 Feb 2000 11:52:25 -0800
- Cc: kawa at sourceware dot cygnus dot com
- References: <s8bbf052.099@tapsellferrier.co.uk>
"Nic Ferrier" <nferrier@tapsellferrier.co.uk> writes:
> I think this would be quite a nice tool to have with Kawa - does
> anyone else think so?
>
> Does Per think so?
I'm not sure. There may be some security implications to keep in
mind, which relate exactly *what* functionality you want.
Specifically, do you want a single ClassLoader where you can change
the class-path at any time, or do you just want to be able to create
a new ClassLoader that uses a class-path specified when the ClassLoader
is created? The former is more flexible, but may be more suspectible
to version inconsistencies and security problems. I don't know to
what extent there is a real problem.
First, I would explore whether the existing ZipLoader does what you need.
That allows you to load an arbitrary .zip / .jar (I haven't tried it
with .jar, but I'm assuming it would work) into its own ClassLoader.
> If so I'm quite happy to add it - should be quite easy to add a new
> ClassLoader to do this and have Kawa use that ClassLoader instead of
> the default.
I don't think I want thatas the default. At least in JDK1.1 using a
ClassLoader is slightly slower, since it forces the verifier to be
run. Worse, it coule lead to hard-to-debug problems.
Supposed we write a DynamicClassLoader, for which you can specify (and
possibly change) the class-path. Then we can have a wrapper class:
package kawa;
public class dynamic_repl
{
public static void main(Object[] args)
{
DynamicClassLoader loader = new DynamicClassLoader();
Class repl = loader.loadClass("kawa.repl");
Object[] xargs = { args };
repl.getMethod("main", ...).invoke(null, xargs);
}
}
This is just one approach. It may be better to use an option
passed to the standard kawa.repl, but you have to make sure all
the other classes are loaded by DynamicClassLoader. One option
is to invoke kawa.repl's main recursive using the DynamicClassLoader,
as shown above. I.e. merge dynamic_repl into repl.
> But if people aren't interested then I won't bother doing it (don't
> want to maintain a fork).
As long as it's an optional feature I don't mind including it.
--
--Per Bothner
per@bothner.com http://www.bothner.com/~per/