Dynamic Dead Code Analysis via Aspect-Oriented Runtime Weaving

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Conventional static and dynamic code analysis tools fail to accurately identify unused code, particularly unreachable code that is never invoked, and require significant changes to the codebase for dynamic tools to function effectively.

Innovation Solution

A language-agnostic dynamic dead code analysis module that creates a list of method names before application launch, stores them in a hash set, and implements a pointcut process around method execution to identify and remove unused methods, using aspect-oriented programming and load-time weaving for dynamic code analysis with minimal code changes.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If static analysis tools are used to identify dead code, then code can be analyzed during compile time, but these tools fail to accurately identify unreachable code that is never actually invoked

Engineering Contradiction:
Improvedead code identification accuracyVSAvoidruntime overhead
Core Design Contradiction:
Measurement precisionVSLoss of time

Solution Approach 1:

The patent creates a comprehensive list of all method names in the codebase before runtime analysis begins. This preliminary action establishes a baseline inventory of all available methods, which is then used to compare against actually invoked methods during runtime, enabling accurate identification of dead code without missing unreachable methods

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The system implements continuous feedback by monitoring method invocations during runtime and dynamically updating the dead code identification. The pointcut process captures actual method calls and feeds this information back to the analysis module, which compares invoked methods against the preliminary list to accurately identify which methods were never called

Inventive Principle:
Principle #23Feedback

2Measurement precision

If dynamic analysis tools are used to identify dead code, then unreachable code can be identified at runtime, but these tools require significant changes to the codebase to function effectively

Engineering Contradiction:
Improvedead code identification accuracyVSAvoidcodebase modification complexity
Core Design Contradiction:
Measurement precisionVSDevice complexity

Solution Approach 1:

The patent introduces an intermediary analysis module that sits between the application code and the runtime execution. This module uses aspect-oriented programming to intercept method invocations without requiring changes to the original business logic. The intermediary captures invocation data and passes it to the dead code identification logic, enabling dynamic analysis while preserving code integrity

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The pointcut process implemented through aspect-oriented programming serves multiple functions: it monitors method invocations, captures invocation data, updates the analysis state, and identifies dead code. This universal mechanism handles all method call tracking across the entire codebase through a single reusable framework, reducing overall system complexity

Inventive Principle:
Principle #6Universality (Multi-functionality)

3Ease of manufacture

If comprehensive code analysis is performed to identify all dead code, then code maintainability improves, but build time and team productivity decrease due to slowed builds

Engineering Contradiction:
Improvecode maintainabilityVSAvoidbuild speed
Core Design Contradiction:
Ease of manufactureVSProductivity

Solution Approach 1:

The system performs dead code analysis periodically based on trigger events such as build completion or deployment milestones rather than continuously during every compilation step. This periodic execution reduces the frequency of analysis operations, maintaining code quality insights while minimizing the impact on build throughput and developer productivity

Inventive Principle:
Principle #19Periodic action

Data Source

PatentUS11868747B2System and method for dynamic dead code analysis
Publication Date: 2024.01.09 JPMORGAN CHASE BANK NA
  • US11868747B2 patent drawing
  • US11868747B2 patent drawing
  • US11868747B2 patent drawing

AI summary

Various methods, apparatuses/systems, and media for dynamic code analysis using aspect oriented programming (AOP) are disclosed. A processor (i) creates a list of all method names associated with an application before launching the application and writes into a file; (ii) at runtime, reads the method names from the file into a hash set and using AOP load time weaving, each time a method is invoked, pointcut around the execution of the method to remove method name from the hash set in memory; (iii) periodically overwrites the file with a dump of current entries in the hash set for fault tolerance; (iv) for every subsequent restart of the application, the processor repeats from processes (ii) and (iii). After running processes (i)-(iv) for a predetermined time period (a month, a quarter etc.), the processor creates a final with methods that have not been invoked for potential deletion.