swarm-support
[Top][All Lists]
Advanced

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

Re: null objects don't yell; JAVASWARMGDB


From: Nick Collier
Subject: Re: null objects don't yell; JAVASWARMGDB
Date: Mon, 8 Jan 2001 16:15:55 -0600

This is odd, and its not a Java thing, unless I'm misunderstanding your 
problem. If you try to reference a null object, a NullPointerException is 
thrown. You should see something like:

java.lang.NullPointerException
        at uchicago.padgett.repub.Priorate.makePolicy(Priorate.java:54)
        at uchicago.padgett.repub.Priorate.test(Priorate.java:68)
        at uchicago.padgett.repub.Priorate.main(Priorate.java:83)   

printed to the console. The stack trace should tell you the line where the 
problem occured.

Nick

On Monday 08 January 2001 15:53, you wrote:
> 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.

-- 
Nick Collier
Social Science Research Computing
University of Chicago
http://repast.sourceforge.net

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