Java Class Live Patching via Non-Blocking Patcher Thread

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing Java applications require live patching solutions that minimize downtime and interference while ensuring secure, single initialization of agents, and efficient resource management during runtime updates.

Innovation Solution

A method involving a patcher thread and singleton pattern to instantiate a patcher class, using a shutdown hook for resource release, and system properties for notification, with periodic scanning for class updates and synchronization to manage access, ensuring secure and efficient class updates in a running Java application.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If a Java agent is loaded through the attach mechanism to enable live patching, then the application can be patched at runtime without restart, but the attach mechanism stalls the recipient JVM instance during agent initialization

Engineering Contradiction:
Improvelive patching capabilityVSAvoidJVM attach mechanism stall time
Core Design Contradiction:
ProductivityVSLoss of time

Solution Approach 1:

The patent segments the agent loading process by creating a dedicated patcher thread that operates independently from the listener thread. This separation allows the agent to be instantiated and initialized in the patcher thread without blocking the listener thread, which continues to accept attach requests. The segmentation of threading responsibilities resolves the contradiction by enabling live patching while preventing JVM stall.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patcher thread acts as an intermediary between the attach mechanism and the agent initialization process. It receives the agent loading request from the listener thread and handles the instantiation and initialization in the background, allowing the listener thread to remain responsive. This intermediary approach enables continuous operation of the attach mechanism while performing patching operations.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Productivity

If multiple instances of the patcher class are instantiated to handle multiple patching tasks, then more patches can be processed concurrently, but resources are wasted and initialization may occur multiple times

Engineering Contradiction:
Improvepatch processing concurrencyVSAvoidrepeated initialization overhead
Core Design Contradiction:
ProductivityVSLoss of energy

Solution Approach 1:

The patcher class implements a singleton pattern with self-service initialization. The first instance that is created automatically initializes the patching infrastructure, and subsequent instances detect that initialization has already occurred and reuse the existing instance. This self-service approach prevents repeated initialization overhead while maintaining the ability to handle multiple patching tasks through the single initialized instance.

Inventive Principle:
Principle #25Self-service

Solution Approach 2:

The patent merges multiple potential patcher instances into a single singleton instance. Instead of creating separate patcher objects for each patching task, all patching operations share the same initialized patcher instance. This merging eliminates redundant initialization while still allowing concurrent patch processing through the shared instance's methods.

Inventive Principle:
Principle #5Merging (Combining)

3Reliability

If the patcher thread is set as a non-daemon thread to ensure complete execution of patching tasks, then patching operations finish reliably, but the application cannot terminate until the patcher thread completes

Engineering Contradiction:
Improvepatching task completionVSAvoidapplication termination
Core Design Contradiction:
ReliabilityVSEase of operation

Solution Approach 1:

The patent makes the patcher thread dynamic by allowing its daemon status to be configured based on operational context. The thread can be created as a daemon thread for normal operation, allowing clean application termination when patching is complete. Alternatively, it can be configured as a non-daemon thread when reliable completion is critical. This dynamic configurability resolves the contradiction by adapting the thread's termination behavior to the specific operational requirements.

Inventive Principle:
Principle #15Dynamics

4Reliability

If the agent initialization routine executes completely before the attach mechanism resumes, then the agent is fully ready to service requests, but the recipient JVM instance remains stalled during the entire initialization process

Engineering Contradiction:
Improveagent readinessVSAvoidJVM instance stall duration
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The patent performs preliminary agent initialization in the patcher thread before the agent needs to service requests. The singleton patcher class prepares the initialization infrastructure in advance, and subsequent patching operations can proceed without repeating this setup. This preliminary action ensures agent readiness while preventing prolonged JVM stalls, as the heavy initialization work occurs in the background patcher thread rather than blocking the listener thread.

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS20250265074A1Systems and methods for loading modified classes into a running application
Publication Date: 2025.08.21 CLOUD LINUX SOFTWARE INC
  • US20250265074A1 patent drawing
  • US20250265074A1 patent drawing
  • US20250265074A1 patent drawing

AI summary

Disclosed herein are systems and method for dynamically updating classes in a running application. In one aspect, a method may include identifying an application running within a virtual machine (VM); generating, within the application, a patcher thread for processing patches; instantiating, within the application, a patcher class using a singleton pattern; installing a shutdown hook in the VM to signal the patcher thread to stop operation and release resources during termination of the application; generating a notification that a live patching facility is set up using a system property in the VM; detecting and executing, via the patcher thread, a task to replace an existing version of a class with an updated version of the class at runtime by scanning, using a polling technique, a tasks directory for new class files and finding the updated version of the class.