US 11,755,341 B2
Class loading method and apparatus
Xinjian Wang, Hangzhou (CN); Qinghua Zhang, Shenzhen (CN); Yongyong Yang, Beijing (CN); Bin Zhang, Hangzhou (CN); and Wei Liu, Shanghai (CN)
Assigned to HUAWEI TECHNOLOGIES CO., LTD., Shenzhen (CN)
Filed by HUAWEI TECHNOLOGIES CO., LTD., Shenzhen (CN)
Filed on Sep. 24, 2021, as Appl. No. 17/484,137.
Application 17/484,137 is a continuation of application No. PCT/CN2020/081220, filed on Mar. 25, 2020.
Claims priority of application No. 201910229643.6 (CN), filed on Mar. 25, 2019.
Prior Publication US 2022/0012067 A1, Jan. 13, 2022
Int. Cl. G06F 8/41 (2018.01); G06F 9/445 (2018.01)
CPC G06F 9/44521 (2013.01) [G06F 8/41 (2013.01)] 17 Claims
OG exemplary drawing
 
1. A class loading method, applied to a computer device, wherein the method comprises:
obtaining a class name of a to-be-loaded class required for running an application program by 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 a correspondence between class names of a plurality of classes and full information of the plurality of classes, wherein the class names of the plurality of classes are in a one-to-one correspondence with the full information of the plurality of classes and the correspondence is stored in a target binary file; and
running the application program based on the full information corresponding to the class name of the to-be-loaded class;
wherein the target binary file further comprises class addresses of the plurality of classes and a correspondence between the class addresses of the plurality of classes and hash values of the class names of the plurality of classes, storage space indicated by a class address of a class is used to store full information of the class, and the method further comprises:
obtaining a class address corresponding to a target hash value based on the target hash value and the correspondence between the class addresses of the plurality of classes and the hash values of the class names of the plurality of classes, wherein the target hash value is a hash value of the class name of the to-be-loaded class; and
the obtaining of the class address corresponding to the target hash value comprises:
searching, for the class name of the to-be-loaded class, storage space indicated by the class address corresponding to the target hash value, wherein the class name of the to-be-loaded class is a part of the full information of the to-be-loaded class; and using, as the full information of the to-be-loaded class, full information in the storage space indicated by the class address corresponding to the target hash value.