Class Loading via Binary Hash Lookup
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
The existing class loading mechanism in JVM frameworks, particularly in Android's Art running mode, is inefficient as it involves searching for a class definition based on a class name followed by dynamic data loading, resulting in prolonged class loading times.
Innovation Solution
A method and apparatus that accelerate class loading by maintaining a target binary file with a correspondence between class names and full information, allowing direct retrieval of class information based on class names, utilizing hash values and buckets to quickly locate class addresses and information, thereby reducing the duration required for class loading.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If class definition is searched based on class name followed by dynamic data loading, then class loading mechanism is implemented, but class loading time is prolonged
Solution Approach 1:
The patent pre-establishes a correspondence relationship between class names and full class information (including class attributes, methods, and data) in a binary file before the application runs. This preliminary preparation eliminates the need for dynamic searching and data loading during execution, directly resolving the contradiction by making class information available immediately without time loss.
Solution Approach 2:
The patent creates a complete copy of class information (class definition, attributes, methods, and data) in the binary file rather than storing only class definitions. This copying approach allows direct retrieval of full class information without sequential loading steps, significantly reducing class loading time while maintaining reliability.
2Adaptability or versatility
If class information is dynamically loaded after class definition search, then memory allocation and data loading are performed, but class loading efficiency is reduced
Solution Approach 1:
The patent performs preliminary action by pre-loading and storing complete class information in the binary file during the build process. This eliminates the need for dynamic memory allocation and sequential data loading during runtime, directly improving productivity while maintaining adaptability through the structured storage format.
Solution Approach 2:
The patent merges class definition, class attributes, methods, and data into a single integrated storage structure in the binary file. This combining approach allows all class information to be retrieved together in one operation, eliminating the inefficiency of sequential dynamic loading and significantly improving class loading efficiency.
3Adaptability or versatility
If conventional class loading mechanism is used, then standard JVM compatibility is maintained, but class loading duration is extended
Solution Approach 1:
The patent creates a complete copy of all class information in a binary file format that is compatible with standard JVM requirements. This copying approach maintains JVM compatibility while enabling direct retrieval of class information, thereby reducing class loading duration without sacrificing adaptability to the JVM environment.
Solution Approach 2:
The patent performs preliminary compilation and storage of class information in the binary file during the build process. This preliminary action ensures that when the application runs, class information can be directly accessed without the standard sequential loading process, reducing duration while maintaining compatibility through proper binary file formatting.
Data Source
AI summary
This application discloses a class loading method and apparatus. The method is applied to a computer device, the computer device includes a target binary file, the target binary file includes a correspondence between class names of a plurality of classes and full information of the plurality of classes, and the class names are in a one-to-one correspondence with the full information of the classes. The method includes: determining a class name of a to-be-loaded class required for running an application program in the computer device; obtaining full information corresponding to the class name of the to-be-loaded class based on the class name of the to-be-loaded class and the correspondence between the class names of the plurality of classes and the full information of the plurality of classes; and running the application program based on the full information corresponding to the class name of the to-be-loaded class.


