JNI Java Exception Handling for Accurate Crash Classification

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing systems inaccurately identify Java exceptions as native crashes when native code invokes Java code via JNI, leading to incorrect aggregation analysis results.

Innovation Solution

An exception handling method that acquires a Java exception object, deletes the exception identifier, and invokes a pre-configured Java exception handler to report the event as a Java crash, using the JNI.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If the system returns to native code when a Java exception occurs during JNI invocation, then the system does not crash and can continue executing, but the exception is incorrectly identified as a native crash leading to inaccurate aggregation analysis

Engineering Contradiction:
Improvesystem stabilityVSAvoidexception identification accuracy
Core Design Contradiction:
ReliabilityVSMeasurement precision

Solution Approach 1:

The patent introduces a Java exception handler as an intermediary component between the JNI invocation and the exception handling process. This handler intercepts Java exceptions before they can be misidentified as native crashes, allowing for accurate differentiation and proper aggregation analysis while maintaining system stability.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The patent implements a feedback mechanism where the system monitors and identifies the type of exception occurring during JNI invocation. By providing feedback about whether the exception is Java-based or native, the system can accurately categorize crashes and improve aggregation analysis precision while maintaining reliable operation.

Inventive Principle:
Principle #23Feedback

2Device complexity

If the system treats all exceptions as native crashes for simplicity, then the handling process is simplified, but the aggregation analysis results become inaccurate

Engineering Contradiction:
Improveexception handling complexityVSAvoidcrash type identification accuracy
Core Design Contradiction:
Device complexityVSMeasurement precision

Solution Approach 1:

The patent segments the exception handling process into distinct paths: one for Java exceptions and another for native crashes. By segmenting the handling logic based on exception type detection, the system maintains simplicity in the overall architecture while achieving precise identification and analysis of different crash types.

Inventive Principle:
Principle #1Segmentation

Data Source

PatentUS12405879B2Exception handling method and apparatus, device, and storage medium
Publication Date: 2025.09.02 DOUYIN VISION CO LTD
  • US12405879B2 patent drawing
  • US12405879B2 patent drawing

AI summary

The present disclosure provides an exception handling method and apparatus, a device, and a storage medium. The method comprises: acquiring, when it is determined that an exception event occurs for Java code invoked based on a JNI, a Java exception object corresponding to the exception event. Then an exception identifier corresponding to the exception event is deleted. Finally, a pre-configured Java exception handler is invoked based on the JNI, and exception handling is performed on the Java exception object using the Java exception handler, the Java exception handler being configured to report the exception event corresponding to the exception object as a Java crash event.