JVM Code Replacement via Call Stack Analysis

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Current code replacement methods in Java Virtual Machines (JVMs) can result in a mixture of old and new code being executed simultaneously, leading to potential conflicts and issues with data access due to changes in variable definitions, and new variables being uninitialized, which is not ideal for application semantics.

Innovation Solution

A method that examines each thread's call stack to determine if any methods will be made obsolete by a proposed code replacement, allowing only safe state code replacements and initializing new variables to values consistent with application semantics, ensuring consistent execution and minimizing thread suspension.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If code replacement is performed in a running JVM without thread suspension, then productivity is improved, but reliability deteriorates due to mixture of old and new code execution

Engineering Contradiction:
Improvecode replacement speedVSAvoidcode execution consistency
Core Design Contradiction:
ProductivityVSReliability

Solution Approach 1:

The patent applies preliminary action by checking each thread's call stack before performing code replacement to determine if any thread is currently executing or has pending calls to the method being replaced. This advance verification ensures that code replacement only proceeds when it is safe to do so, preventing the mixture of old and new code execution while allowing continuous operation without full thread suspension.

Inventive Principle:
Principle #10Preliminary action

2Reliability

If thread suspension is used to ensure safe code replacement, then reliability is improved, but productivity deteriorates due to program suspension

Engineering Contradiction:
Improvecode execution consistencyVSAvoidprogram execution continuity
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The patent applies local quality by differentiating between threads based on their call stack contents. Instead of suspending all threads uniformly, the system identifies only those threads that have the obsolete method in their call stacks and suspends only those specific threads. This localized approach maintains reliability by ensuring no thread executes obsolete code while minimizing productivity impact by allowing other threads to continue execution.

Inventive Principle:
Principle #3Local quality

3Ease of operation

If code replacement is performed without call stack checking, then ease of operation is improved, but harmful factors increase due to uninitialized variables and data access conflicts

Engineering Contradiction:
Improvecode replacement simplicityVSAvoiddata access conflicts
Core Design Contradiction:
Ease of operationVSObject-generated harmful factors

Solution Approach 1:

The patent applies preliminary action by performing call stack checking before code replacement to identify threads that would be affected. This advance detection allows the system to prepare appropriate handling for those threads, preventing data access conflicts and uninitialized variable issues that would otherwise occur with simple code replacement. The checking step adds minimal complexity while eliminating significant harmful effects.

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS8166470B2Method for replacing code in a running object oriented program
Publication Date: 2012.04.24 INTERNATIONAL BUSINESS MACHINE CORPORATION
  • US8166470B2 patent drawing
  • US8166470B2 patent drawing
  • US8166470B2 patent drawing

AI summary

The invention is directed to a method of replacing code in an object oriented application program running on a Virtual Machine (VM). The method comprises the steps of receiving at the virtual machine a request to replace code; in response to receipt of said request, examining each thread's call stack to determine if any thread includes a method that will be made obsolete by a proposed code replacement; and, if it is determined that there are no threads that include such a method in their call stacks, performing the code replacement. However, for a thread whose call stack is determined to include a method that will be made obsolete by the proposed code replacement, the method includes the step of allowing the thread to continue running until the thread unwinds past that method in its call stack and then suspending said thread. This comprises a part of a process of determining a safe state for code replacement. The invention is also directed to a method of initializing new variables in such replacement code. The variable initialization method comprises the steps of identifying the replaced code and prior to resuming threads containing the replacement code, initializing new variables in the replacement code to values consistent with the application semantics.