Dynamic Class Reloading for Anonymous Classes
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Current dynamic class reloading mechanisms, such as JRebel and DCEVM, fail to adequately handle changes to anonymous classes and other name synthesized classes, leading to unexpected behavior and errors during runtime updates, especially when changes involve anonymous classes or modifications to their ordered set or superclass hierarchy.
Innovation Solution
A method and system that transform name synthesized classes by comparing unique identifiers during dynamic class updates, replacing synthetic names in the bytecode, and using a class interceptor to intercept and manage class loading, ensuring correct runtime behavior by maintaining metadata and unique identifiers for name synthesized classes.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If dynamic class reloading mechanisms are used to update classes at runtime, then productivity and development efficiency are improved, but reliability and correctness of runtime behavior deteriorate when anonymous classes are involved
Solution Approach 1:
The system performs preliminary actions by computing and storing unique identifiers (fingerprints) for anonymous classes during the initial class loading phase. This allows the reloading mechanism to later match reloaded classes with their original definitions by comparing these pre-computed identifiers, ensuring correctness without disrupting runtime productivity.
Solution Approach 2:
The patent introduces a class interceptor as an intermediary component that sits between the class loader and the JVM. This interceptor captures class loading events, computes unique identifiers, and manages the mapping between original and reloaded anonymous classes, thereby mediating the reloading process to maintain behavioral correctness.
2Ease of manufacture
If synthetic names are used for anonymous classes to enable compilation, then ease of manufacture and compilation simplicity are improved, but measurement precision and unique identification capability worsen
Solution Approach 1:
The system creates a copy or representation of the anonymous class's unique characteristics by computing a fingerprint (unique identifier) from the class bytecode. This fingerprint serves as a precise identifier that preserves the identity information lost in synthetic naming, enabling accurate matching during reloading while maintaining compilation simplicity.
3Device complexity
If the compiler generates unique synthetic names for anonymous classes, then device complexity and naming uniqueness are improved, but loss of information about original class identity occurs
Solution Approach 1:
The system implements a feedback mechanism where the unique identifier computed from the class bytecode is stored and later used to verify and match reloaded classes. This feedback loop preserves the original class identity information that would otherwise be lost in synthetic naming, enabling the system to track and correctly reload anonymous classes across rebuilds.
Data Source
AI summary
A system and method for transforming name synthesized classes in response to dynamic class updates to existing classes, featuring the ability to provide replacement synthetic names for reloaded name synthesized classes. According to a preferred embodiment, the name synthesized classes are anonymous classes. The method stores and tracks the synthetic names for each name synthesized class as they are loaded or reloaded, intercepting the loading of the classes before being defined in a virtual machine. Then, the method maps the synthetic name of the name synthesized classes for each dynamic class update to replacement synthetic names of previously loaded name synthesized classes. In addition, the concepts of the invention are applicable to other types of name synthesized classes, such as local classes, bridge methods and lambda expressions.


