This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problem with 'require' in servlet


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/



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]