GeeCON Prague 2014*
The moose likes Java in General and the fly likes List.add() operation terminating program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "List.add() operation terminating program" Watch "List.add() operation terminating program" New topic
Author

List.add() operation terminating program

B West
Greenhorn

Joined: Oct 10, 2008
Posts: 29
Hello all,

I've got a weird issue. I have a List, and anytime I try to add something to it. The program is terminated. No exceptions no errors, nothing. The program just quits.

Here's my code:


I've never seen happen before, where something just terminates with any kind of warning or error.

Has anybody seen anything like this before?

Any help is appreciated!
Thanks
bw
[ November 24, 2008: Message edited by: Martijn Verburg ]
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3602
    
  15
pkgList doesn't reference any object. I imagine you're getting a NullPointerException that is being swallowed somewhere.


Joanne
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Hi,

Most of the time silent termination is due to an unexpected exception coupled with an empty catch block -- i.e.,

} catch (Exception ex) { /* CAN'T HAPPEN */ }

The add could throw a NullPointerException if the list variable is null. Otherwise, a non-standard list implementation might call some method of your PackageType class which then throws an exception. You haven't really shown us the real code (the above wouldn't actually compile if taken literally, since the list variable is not initialized) so all we can really do is guess. If you show us some real code I might have other ideas.


[Jess in Action][AskingGoodQuestions]
B West
Greenhorn

Joined: Oct 10, 2008
Posts: 29
Thank you for your reply,

Sorry for not being more clear....

Here is the full class.

*NOTE: The PackageType class does not throw any exceptions. (It's a xjc generated class. )




The code in the middle is what is failing. As you can see i'am catching NullPointerExceptions. But it doesn't seem to be hitting it.

Any ideas?
Thanks Again!!
BW
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3602
    
  15
You're still not initialising pkgList. Try doing that and see if the problem disappears. If it does then we can try and find out waht is happening to the exception.
B West
Greenhorn

Joined: Oct 10, 2008
Posts: 29
I found my problem. The NullException was getting hit. I wasn't checking it downstream. Thanks for you help and time.


bw
 
Consider Paul's rocket mass heater.
 
subject: List.add() operation terminating program