This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: Problem with 'require' in servlet
- From: Per Bothner <per at bothner dot com>
- To: Dominique Boucher <dboucher at nuecho dot com>
- Cc: "'Kawa List'" <kawa at sources dot redhat dot com>
- Date: Wed, 01 Oct 2003 12:21:14 -0700
- Subject: Re: Problem with 'require' in servlet
- References: <000f01c38849$0210c730$6400a8c0@Forman>
Dominique Boucher wrote:
Maybe I was not clear enough.
No - I mis-remembered how my own code works...
When you compile the following code:
(require <foo>)
you get something like the following in the .class file:
Method void apply(gnu.mapping.CallContext)
0 aload_1
1 getfield #12 <Field gnu.lists.Consumer consumer>
4 astore_2
5 ldc #14 <String "foo">
7 invokestatic #20 <Method java.lang.Object find(java.lang.String)>
10 pop
I.e., the class is loaded explicitely by the Kawa runtime
(require.java:84) using the Class.forName() method, not automatically by
the class loader of the servlet container when the servlet is loaded.
This makes a HUGE difference, as you'll see.
The reason for calling "find" is to ensure that that any "module-level"
expressions get evaluated the first time the module is required, but
only the first time. However, this should not be be needed for a
static module, since the class initialization takes care of that.
The compiles only generates the call to 'find' if the required class
implements Runnable. Unfortunately it does, because it extends
ModuleBody.
I think the thing to do is remove "implements Runnable" from ModuleBody,
but have non-static modules explicitly implement Runnable. (That's
probably how it used to be, but things got shuffled around - in 2001,
it looks like.)
--
--Per Bothner
per@bothner.com http://per.bothner.com/