swarm-support
[Top][All Lists]
Advanced

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

RE: null objects don't yell


From: Tee Toth-Fejel
Subject: RE: null objects don't yell
Date: Tue, 9 Jan 2001 17:56:25 -0500

Glen McCluskey's JDC Tech Tips  January 9, 2001 just came in today via email
(available on the web at
http://java.sun.com/jdc/JDCTechTips/2001/tt0109.html) and (possibly)
answered my question.  It said:

"Before examining some techniques for handling uncaught exceptions, 
let's look at the rules for how the Java(tm) Virtual Machine* 
terminates a program. The first rule is that an uncaught
exception terminates the thread in which it occurs. The second 
rule is that a program terminates when there are no more user 
threads available."

Apparently, when the swarm Schedule runs an action, it does it in a separate
thread.
I never knew that, and with the swarm site down, its difficult to check the
docs (I only have the reference guide locally, along with the brief
overview).  Didn't find anything in swarm-2000-10-01\src\activity\Schedule.m
either, but I wouldn't expect to find java-specific stuff in Objective C
source code anyway...

Tihamer "Tee" Toth-Fejel                    Member of Technical Staff
(734) 623-2544   address@hidden      http://www.erim.org/ 
Center for Electronic Commerce, Environmental Research Institute of Michigan




> -----Original Message-----
> From: Tee Toth-Fejel [mailto:address@hidden
> Sent: Tuesday, January 09, 2001 4:51 PM
> To: 'address@hidden'
> Subject: RE: null objects don't yell
> 
> 
> > -----Original Message-----
> > From: Paul E Johnson [mailto:address@hidden
> > Sent: Monday, January 08, 2001 4:53 PM
> > To: Swarm-support
> > Subject: null objects don't yell; JAVASWARMGDB
> > 
> > I've had this error come up a couple of times, and it is really
> > frustrating. ...
> > 
> > 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.  
> 
> Yes, I've had something similar happen to me three different 
> ways in the
> last two days (fortunately, I'm past the frustration stage 
> and have reached
> utter despair).
> Apparently, if you have a method that is in a schedule (loops 
> don't seem to
> be necessary), and you try to call a method on a null object, 
> Swarm cleverly
> hides the expected NullPointerException and goes merrily on 
> it's way (it
> doesn't terminate for me).  I'm guessing that this feature 
> exists because of
> the Objective C/Java interface.  Or perhaps my class (in this 
> case Heatbug)
> just doesn't know what to do with unexpected exceptions, but 
> I've never seen
> that elsewhere in Java.
> 
> Fortunately, as Joshua Madden address@hidden suggested, this
> "invisible" error can be caught.  e.g. (when I don't set the 
> public member
> of heat, heat.heatbugModelSwarm, then switchHeatbugList(bug) breaks
> visibly):
> 
>               try {
>                  heat.heatbugModelSwarm.switchHeatbugList(this);
>                  }
>              catch (NullPointerException ex)
>                  {
>                  ex.printStackTrace();
>                  System.out.println("Heatbug.Step: caught invisible
> exception!");
>                  }
> results in:
> java.lang.NullPointerException
>       at Heatbug.heatbugStep(Heatbug.java:358)
>       at swarm.simtoolsgui.GUISwarmImpl.go(Native Method)
>       at StartHeatbugs.main(StartHeatbugs.java:31)
>       at intuitive.audit.Main.runProgramWithClass(Native Method)
>       at intuitive.audit.Audit.main(Audit.java)
> Heatbug.Step: caught invisible exception!
> 
> In case you're wondering, I'm splitting jheatbugs into two 
> pieces for a
> distributed jheatbugs demo.
> 
> Tihamer "Tee" Toth-Fejel                    Member of Technical Staff
> (734) 623-2544   address@hidden      http://www.erim.org/ 
> Center for Electronic Commerce, Environmental Research 
> Institute of Michigan
> 
>  
> 
>                   ==================================
>    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.
> 

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