Search Books

JDK 1.4 Tutorial, eDoc 5 : Inspecting and Creating Stack Traces

Author Gregory Travis
Publisher Manning Publications
📄 Viewing lite version Full site ›
🌎 Shop on Amazon — choose country
9.95 USD
🛒 Buy New on Amazon 🇺🇸

✓ Available for download now

Share:
Book Details
ISBN / ASINB00006928S
ISBN-13978B000069283
AvailabilityAvailable for download now
Sales Rank11,516,661
MarketplaceUnited States 🇺🇸

Description

JDK 1.4 provides a couple of powerful new Exceptions features -- chained exceptions and StackTraceElements.

Chained exceptions formalize the idea that one exception can trigger another. In this e-doc, you'll learn how they work, what they replace, and how to traverse a chain of exceptions.

StackTraceElements provide programmatic interface to stack traces, which are generated as part of an exception. This is a good deal more convenient than generating a stack trace dump and parsing the output. In this e-doc, you'll learn how to access and use StackTraceElements. You'll also learn how to create a StackTraceElement, and you'll learn when this is appropriate to do.

This e-doc will show you how to:

  • Interpret chained exceptions
  • Traverse an exception chain
  • Create an exception chain
  • Access and view StackTraceElements
  • Synthesize StackTraceElements

Sample programs included in this chapter:

  • A custom stack-trace dumper that shows the source code context for each line of the exception
  • A task system which executes tasks in a thread pool and synthesizes correct exceptions for exceptions within the pool