Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / January 2010

Tip: Looking for answers? Try searching our database.

Null Stack Traces

Thread view: 
Mark Smith - 29 Jan 2010 15:22 GMT
I just spend ages tracking down a null pointer exception that was
being thrown and not caught until somewhere near the top of the
application.

These types of errors do not have stack traces unfortunately.

To find it I had to hack my code to manually print out messages as it
entered and exited methods.

Are there any development tools for java that I can attach to my
process to get this kind of tracing without having to manually write
debugging info from code?

Thanks for any suggestions.
Eric Sosman - 29 Jan 2010 15:52 GMT
> I just spend ages tracking down a null pointer exception that was
> being thrown and not caught until somewhere near the top of the
> application.
>
> These types of errors do not have stack traces unfortunately.

    That seems odd.  Uncaught exceptions in finalizers are
discarded, and maybe there are one or two other such corner
cases, but in the ordinary course of events an uncaught
exception eventually makes its way back to the ultimate
catcher, which dumps whatever stack information is available.
This doesn't depend (as far as I know) on the nature of the
Throwable -- in particular, NullPointerException's stack
trace is not suppressed.

    It sounds like there was a catch-and-ignore somewhere
along the line, in your application or in some framework it
was built around.  That's one reason catch-and-ignore is a
Very Bad Idea.

> To find it I had to hack my code to manually print out messages as it
> entered and exited methods.
>
> Are there any development tools for java that I can attach to my
> process to get this kind of tracing without having to manually write
> debugging info from code?

    You might take a look at the java.lang.instrument package.
I haven't, not seriously, but it seems capable of this sort of
thing.  (It also seems, at a cursory glance, to be considerably
more difficult than inserting println() calls.)  Also, see if
your platform has a DTrace that can see inside Java code -- I
know the Solaris version does, but I'm not sure whether the
other DTrace platforms are as far along.

Signature

Eric Sosman
esosman@ieee-dot-org.invalid

Daniel Pitts - 30 Jan 2010 01:20 GMT
> I just spend ages tracking down a null pointer exception that was
> being thrown and not caught until somewhere near the top of the
[quoted text clipped - 10 lines]
>
> Thanks for any suggestions.
Many IDE's and debuggers will let you set exception break-points.  They
are much like regular break-points, but pause upon throw of the
particular exception type, rather than on a particular line.

Signature

Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>

Roedy Green - 30 Jan 2010 09:55 GMT
On Fri, 29 Jan 2010 07:22:56 -0800 (PST), Mark Smith
<marksmith5555@jungle-monkey.com> wrote, quoted or indirectly quoted
someone who said :

>I just spend ages tracking down a null pointer exception that was
>being thrown and not caught until somewhere near the top of the
>application.

Problems with stack traces I have include:

1. static init code.  When debugging you can temporarily make it into
instance init code invoked in the constructor.

2. using Jet.  For speed it turns off stack tracing.  You can manually
turn it back on, but it is better just to use HotSpot which is better
suited to debugging.

Perhaps you are not dumping the stack traces properly. See
http://mindprod.com/jgloss/stacktrace.html

e.g. perhaps they are stuck in an unflushed buffer.

Signature

Roedy Green Canadian Mind Products
http://mindprod.com
Computers are useless. They can only give you answers.
~ Pablo Picasso (born: 1881-10-25 died: 1973-04-08 at age: 91)



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.