JNI Java Exception Handling for Accurate Crash Classification
Find Innovative SolutionsGenerate 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
Engineering 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
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.
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.
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
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.
Data Source
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.

