swarm-support
[Top][All Lists]
Advanced

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

null objects don't yell; JAVASWARMGDB


From: Paul E Johnson
Subject: null objects don't yell; JAVASWARMGDB
Date: Mon, 08 Jan 2001 15:53:18 -0600

I've had this error come up a couple of times, and it is really
frustrating. I obviously don't understand the way java deals with
errors.

Suppose model swarm loops over agents, telling them what to do.  Suppose
there is some mistake inside the method the agent is carrying out, so
that it tries to send a message to a null object.  Java makes no error
message, but instead it terminates the action for the whole loop right
at that spot.  

I have two examples.  Example 1: suppose you have an agent's step method
in an agent like this:

public Rule getBestRule () {
        Rule bestRule
----some commands in here find elements of an array "equalGood[]", but
due to my mistake, sometimes equalGood[] was uninitialized. ---
        bestRule = equalGood[0];
        return bestRule;
}

This caused the loop to terminate because equalGood[0] was null.  No
error, just termination.  I get the same nonerror whether I step over
the agents with a plain old while() loop or use the
createAction$ForEach$
setup.

 
Example 2. In a step method, I had the same kind of error.  The object
"renewalRecord" was null.

System.out.println("This offer is from Recruiter " +
renewalRecord.getRecruiter().getGrpNumber());


Both of these caused the same thing, that the program didn't do what I
want and produced no error message.  Is this a thing Java programs in
general do, or just Java embedded in swarm?  Aside from not making
mistakes, is there anything to be done?

Now, about JAVASWARMGDB.  I can't seem to make it tell me anything I
want to know. When there is a crash, the backtrace never points to a
line in my code, it always just refers to the Swarm library.  

Also, in gdb for javaswarm, how do you set breakpoints for line numbers
in source files or method names?  It says methods don't exist and
filenames don't exist either. 

-- 
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]