swarm-support
[Top][All Lists]
Advanced

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

Re: How to eat, how communicate.


From: Paul E Johnson
Subject: Re: How to eat, how communicate.
Date: Sun, 04 Mar 2001 08:18:48 -0600

I put this example code in the repository,
http://lark.cc.ukans.edu/~pauljohn/SwarmFaq/WorkingExampleCode/java/RuntimeBinding.txt.

There are some things I don't understand about it though. May I inquire?

1. It takes the selector from the frob method of insider, and sends that
selector to both the insider and the outsider:

try {
      sel = new Selector (insider.getClass (), "frob", false);
    } catch (Exception e) {
      e.printStackTrace (System.err);
      System.exit (1);
    }
}
    insider.perform (sel);
    outsider.perform (sel);

Suppose the outsider did have a "frob" method.  Would this program call
it?  I tested it, and it seems the answer is "yes."  The frob method of
the outsider does get used, even though the selector is built from the
method of the insider class.  What the heck is going on? Is this Swarm
runtime "magic" the sort of which "createActionForEachHomogeneous"
circumvents?  If the runtime can go shopping for methods, why do we have
to use the selector approach at all? 



2. I am curious to know about how this method gets called:

> class Outsider extends Agent {
>   public void doesNotRecognize (Selector sel) {
>     System.out.println ("ouch! " + sel);
>   }
> }

It there something in the Swarm system that is supposed to catch a
runtime Obj-C "no such method" error and sent it back to that object's 
"doesNotRecognize" if one exists? 

Maybe I can't understand because my system gives a different piece of
output than yours, which seems to say "doesNotRecognize" is not called.

 $ javaswarm NoSelector
frob
*** event raised for error: SourceMessage
*** function: _i_FCall_c__createEnd(), file:
/home/pauljohn/LinuxDownloads/redhat/BUILD/swarm-2.1.41.20010214/src/defobj/FCall.m,
line: 472
Could not find Java method: `frob' `()Ljava/lang/Object;'
*** execution terminating due to error
/home/pauljohn/LinuxDownloads/redhat/BUILD/swarm-2.1.41.20010214/src/defobj/Symbol.m:173
-[Error(c) _raiseEvent:]
/usr/bin/javaswarm: line 1: 11379 Aborted                
APPHOME=/usr/local/jdk1.3
LD_LIBRARY_PATH=/usr/local/jdk1.3/jre/lib/i386/native_threads:/usr/local/jdk1.3/jre/lib/i386:/usr/local/jdk1.3/jre/lib/i386/hotspot::/usr/lib:/usr/lib/swarm:/usr/X11R6/lib:
CLASSPATH='.:/usr/share/swarm/swarm.jar:/usr/share/swarm/kawa.jar:/usr/local/jdk1.3/jre/lib/rt.jar:'
/usr/local/jdk1.3/jre/bin/i386/native_threads/java 'NoSelector'


3. Can you tell me how to write code to create Selectors when an
argument is needed for the java method? Or two arguments? Etc.

-- 
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ukans.edu/~pauljohn
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66045                FAX: (785) 864-5700

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]