Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

List.add() operation terminating program

 
B West
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pkgList doesn't reference any object. I imagine you're getting a NullPointerException that is being swallowed somewhere.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
B West
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found my problem. The NullException was getting hit. I wasn't checking it downstream. Thanks for you help and time.


bw
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic