JVM Agent Bootstrap Class Bytecode Transformation

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Current bytecode transformation techniques for JVM are limited in achieving full bytecode coverage, as they exclude special bootstrap classes and require static transformations before execution, imposing restrictive limitations on class redefinition and altering standard usage patterns.

Innovation Solution

A JVM Agent performs transparent on-line bytecode transformations of already loaded bootstrap classes, allowing user-defined customizations without the need for off-line tools, by intercepting class-loading events, modifying the startup method, and spawning a new JVM instance with modified classes.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If static bytecode transformation is used before JVM startup, then bootstrap classes can be modified, but the transformation must be performed offline and requires special tools, altering standard usage patterns

Engineering Contradiction:
Improvebytecode coverageVSAvoidusage pattern
Core Design Contradiction:
ReliabilityVSEase of operation

Solution Approach 1:

The patent transforms the static offline bytecode transformation process into a dynamic online process. The JVM agent performs bytecode transformation of bootstrap classes at runtime, allowing modifications to be applied dynamically without requiring special offline tools or altering standard JVM startup procedures. This resolves the contradiction by making the transformation process adaptive and integrated into the normal JVM operation.

Inventive Principle:
Principle #15Dynamics

Solution Approach 2:

The patent introduces a JVM agent as an intermediary component that bridges the gap between the need for bootstrap class modification and the standard JVM operation. The agent intercepts class loading events and performs transformation on-the-fly, acting as a mediator that enables full bytecode coverage without requiring users to adopt special offline transformation workflows.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Ease of operation

If Java language instrumentation agents are used to transform classes during loading, then classes can be modified online, but bootstrap classes are excluded because they are loaded before agents are executed

Engineering Contradiction:
Improveonline transformationVSAvoidbytecode coverage
Core Design Contradiction:
Ease of operationVSReliability

Solution Approach 1:

The patent applies preliminary action by having the JVM agent perform bytecode transformation of bootstrap classes before these classes are actually executed or used by the application. The agent intercepts the class loading process and completes the transformation in advance, ensuring that even though bootstrap classes are loaded early, they are transformed online before any bytecode execution occurs.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent inverts the traditional approach by having the JVM agent execute and perform transformations during the bootstrap phase itself, rather than expecting agents to be loaded after bootstrapping. This reversal of the normal loading sequence allows the agent to intercept and transform bootstrap classes that would otherwise be excluded from online transformation.

Inventive Principle:
Principle #13The other way round (Inversion)

3Ease of operation

If redefinition mechanism is used to modify pre-loaded classes, then online transformation is possible, but strong limitations are imposed on class redefinition

Engineering Contradiction:
Improveonline transformationVSAvoidmodification capability
Core Design Contradiction:
Ease of operationVSAdaptability or versatility

Solution Approach 1:

The patent extracts the transformation logic from the constrained redefinition mechanism into a separate bytecode transformation process. Instead of being limited by the redefinition API's restrictions on method signatures and inheritance, the JVM agent performs full bytecode transformation by rewriting the bytecode directly, thereby extracting the transformation capability from the limiting redefinition framework.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The patent changes the fundamental parameter of how transformation is performed - moving from the redefinition mechanism (which has strict parameters about what can be changed) to direct bytecode manipulation (which allows any modification). This parameter change enables full adaptability in modifying bootstrap classes online, including adding methods, changing signatures, and modifying inheritance, without being constrained by the redefinition API's limitations.

Inventive Principle:
Principle #35Parameter changes

Data Source

PatentUS9141415B2Method for dynamically transforming the bytecode of Java virtual machine bootstrap classes
Publication Date: 2015.09.22 ZEROTURNAROUND
  • US9141415B2 patent drawing
  • US9141415B2 patent drawing
  • US9141415B2 patent drawing

AI summary

A method for dynamically transforming bytecode of Java Virtual Machine (JVM) bootstrap classes during program startup uses a JVM agent to intercept startup of a JVM compliant computer program to transform the bytecode of already loaded JVM bootstrap classes and store the resulting set of modified bootstrap classes. Subsequently, the JVM Agent intercepts all class loading events to transform the bytecode of classes declaring special program startup method “<clinit>”, by inserting bytecode at the beginning of the method to invoke a callback method declared within the JVM Agent and passing the arguments passed to the JVM upon program startup as callback method parameters. Subsequently, when the callback method intercepts the execution flow of the computer program, the callback method starts a second JVM instance, passing parameters including the obtained input parameters, the main method arguments, and a JVM input argument for accessing the stored set of modified bootstrap classes.