Java Shutdown Hook for Execution State Capture

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Conventional approaches fail to capture the execution state of a failing program when it is terminated by the user, leading to lost diagnostic information and difficulties in resolving intermittent program errors.

Innovation Solution

A mechanism that detects user-initiated abnormal terminations, collects and stores the execution state information, and allows for its transmission to a third party, enabling the retrieval of diagnostic data even after program termination.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If the user terminates the program due to an error, then the program stops running, but the execution state information is lost

Engineering Contradiction:
Improveprogram stabilityVSAvoidexecution state information
Core Design Contradiction:
ReliabilityVSLoss of information

Solution Approach 1:

The patent applies preliminary action by registering a shutdown hook that executes before the program actually terminates. This hook captures the execution state (call stack, thread information, heap dump) at the moment of abnormal termination, preserving diagnostic information that would otherwise be lost when the program ends unexpectedly.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent creates a copy of the execution state information by generating a heap dump and saving call stack traces to files. These copies preserve the program's state at termination without requiring the original program to continue running, allowing later analysis of the captured data.

Inventive Principle:
Principle #26Copying

2Loss of information

If a monitoring process is used to watch over the program, then post-failure information collection is possible, but additional delay is incurred and certain errors cannot be detected

Engineering Contradiction:
Improvediagnostic information recoveryVSAvoidtime to resolve error
Core Design Contradiction:
Loss of informationVSLoss of time

Solution Approach 1:

The patent implements self-service by having the Java Virtual Machine automatically capture its own execution state when an error occurs. The shutdown hook mechanism is built into the JVM, eliminating the need for external monitoring processes. This self-capture approach reduces time loss because the information is collected immediately at termination rather than requiring post-mortem analysis by separate monitoring systems.

Inventive Principle:
Principle #25Self-service

3Reliability

If conventional monitoring approaches are used, then post-failure state detection is possible, but the machine is in an ambiguous state and certain errors remain undetected

Engineering Contradiction:
Improveerror detection capabilityVSAvoidprogram state ambiguity
Core Design Contradiction:
ReliabilityVSDifficulty of detecting and measuring

Solution Approach 1:

The shutdown hook captures the execution state before the program fully terminates and the state becomes ambiguous. By executing the capture routine during the shutdown process itself, the patent obtains accurate call stack information, thread states, and heap memory contents while the program is still in a definable state, enabling reliable detection of errors including deadlocks and waiting threads.

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS7627785B1Capturing machine state of unstable Java program
Publication Date: 2009.12.01 ORACLE AMERICAN INC
  • US7627785B1 patent drawing
  • US7627785B1 patent drawing
  • US7627785B1 patent drawing

AI summary

Mechanisms and methods for capturing an execution state of a failing program in a computing environment are disclosed. Embodiments can enable detection of user initiated program terminations and error information capture without incurring the overhead of a separate monitoring process. It is possible to obtain an execution trace and related state information in the event that a program has incurred a program error causing the user to terminate the program.