A processing method, device, and equipment of an application program and a medium

By performing multi-dimensional optimization on the application's bytecode files, the problem of difficulty in controlling the size of the installation package in existing technologies has been solved. This enables targeted compression and compatibility improvement of the installation package, thereby increasing download conversion rates and promotion capabilities.

CN113961177BActive Publication Date: 2025-11-07TENCENT TECH WUHAN
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202010704842.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-07-21
Publication Date
2025-11-07
Estimated Expiration
2040-07-21

AI Technical Summary

Technical Problem

Existing technologies lack specificity in obfuscating and compressing application installation packages, and have many compatibility issues, making it difficult to control the size of the installation package, which affects download conversion rates and promotion.

Method used

By obtaining the bytecode file to be processed from the archive file of the target application, traversing and collecting the bytecode corresponding to multiple optimization tasks, performing optimization processing, including optimization tasks such as system annotations, source file format, debugging information, global variables and access methods, deleting or replacing unnecessary bytecode, and building the optimized bytecode file.

Benefits of technology

It enables targeted compression of application installation packages, reducing package size, ensuring compatibility and stability, supporting the expansion of optimization tasks, and improving download conversion rates and promotion capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113961177B_ABST
    Figure CN113961177B_ABST
Patent Text Reader

Abstract

The embodiment of the application provides a kind of application processing method of application program.Therein method includes: obtaining the bytecode file to be processed from the archive file of target application program, collecting the bytecode corresponding to N optimization tasks respectively in the bytecode file to be processed, N is positive integer, the bytecode corresponding to each optimization task collected is executed optimization processing, and the bytecode file after optimization is obtained.It can be seen that the application processing method of application program provided in the embodiment of the application can be targeted, extremely optimized processing to the bytecode file in the archive file contained in the installation package of target application program, reduce the size of bytecode file, so as to be beneficial to reduce the size of installation package after target application program is updated or built, and have good compatibility and stability.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to a processing method of application program, a processing device of application program, a processing equipment of application program and computer readable storage medium. BACKGROUND

[0002] With the progress of computer technology, a large number of application programs emerge on various application platforms. With the iterative development of application programs, the size of the installation package of the application program is growing. On the one hand, the size of the installation package is closely related to the download conversion rate, the larger the size of the installation package of the application program, the lower the download conversion rate of the application program. On the other hand, the size of the installation package of the application program will also have a great impact on the promotion of the application program, for example: a certain Android (a kind of mobile operating system) application platform stipulates that the application program whose installation package size exceeds 100 megabytes can only be uploaded in the form of an extended file, which is not conducive to the promotion of the application program. As can be seen, when constructing or iterating the installation package of the application program, it is necessary to strictly control the size of the installation package. At present, the size of the installation package is mainly controlled by obfuscating and compressing the installation package of the application program. However, it is found in practice that this obfuscating and compressing method lacks pertinence and has many compatibility problems. SUMMARY

[0003] The embodiments of the present application provide a processing method, device and equipment of application program and computer readable storage medium, which can realize extremely targeted compression and ensure compatibility and stability.

[0004] In one aspect, the present application provides a processing method of application program, which comprises:

[0005] obtaining a to-be-processed bytecode file from an archive file of a target application program;

[0006] traversing the to-be-processed bytecode file to collect bytecodes corresponding to N optimization tasks respectively, N being a positive integer;

[0007] performing optimization processing on the collected bytecodes corresponding to the optimization tasks to obtain an optimized bytecode file.

[0008] In one aspect, the present application provides a processing device of application program, which comprises:

[0009] an obtaining unit, configured to obtain a to-be-processed bytecode file from an archive file of a target application program;

[0010] The processing unit is configured to traverse the bytecode file to be processed to collect bytecode corresponding to N optimization tasks respectively, N being a positive integer, and perform optimization processing on the collected bytecode corresponding to the optimization tasks to obtain an optimized bytecode file.

[0011] In an embodiment, the processing unit is further configured to obtain the bytecode file to be processed from an archive file of the target application, and specifically configured to:

[0012] decode the archive file of the target application to obtain a class file of the target application;

[0013] perform first encoding conversion processing on the class file to obtain the bytecode file to be processed;

[0014] The processing unit is further configured to:

[0015] traverse the bytecode file to be processed and construct a data structure of the target application, the data structure containing inheritance relationships of each class in the target application.

[0016] In an embodiment, the optimization tasks include a system annotation optimization task, and the processing unit is further configured to traverse the bytecode file to be processed to collect bytecode corresponding to N optimization tasks, and specifically configured to:

[0017] traverse the bytecode file to be processed to obtain a first bytecode set, the first bytecode set containing at least one first bytecode, the first bytecode being bytecode used to represent a system annotation;

[0018] add the first bytecode in the first bytecode set that meets a protection condition to a whitelist;

[0019] wherein the collected bytecode corresponding to the system annotation optimization task refers to the first bytecode in the first bytecode set that does not belong to the whitelist.

[0020] In an embodiment, assuming that the target bytecode is any one of the first bytecode set, the processing unit is further configured to determine whether the target bytecode meets the protection condition, and specifically configured to:

[0021] determine whether the class to which the target bytecode belongs calls a system annotation method;

[0022] if the class to which the target bytecode belongs calls the system annotation method, determine whether the class to which the target bytecode belongs is an interface implementation class, or determine whether the class to which the target bytecode belongs has a parent class according to the inheritance relationships in the data structure;

[0023] if the class to which the target bytecode belongs is the interface implementation class, or the class to which the target bytecode belongs has the parent class, it is determined that the target bytecode meets the protection condition.

[0024] In an implementation, the processing unit is further configured to perform optimization processing on the collected bytecode corresponding to the optimization task to obtain an optimized bytecode file, and specifically configured to:

[0025] delete the first bytecode in the bytecode file to be processed that belongs to the first bytecode set and does not belong to the white list, to obtain the optimized bytecode file.

[0026] In an implementation, the optimization task includes a source file format optimization task; the collected bytecode corresponding to the source file format optimization task is a second bytecode in the bytecode file to be processed, and the second bytecode is a bytecode used to represent a source file format; the processing unit is further configured to perform optimization processing on the collected bytecode corresponding to the optimization task to obtain an optimized bytecode file, and specifically configured to:

[0027] construct an encoding tree of the second bytecode according to a frequency of occurrence of the second bytecode in the bytecode file to be processed;

[0028] encode the second bytecode according to an encoding rule of the encoding tree to obtain a simplified bytecode and a mapping file;

[0029] replace the second bytecode in the bytecode file to be processed with the simplified bytecode to obtain the optimized bytecode file;

[0030] wherein the mapping file can restore the simplified bytecode to the second bytecode.

[0031] In an implementation, the optimization task includes a debugging information optimization task; the processing unit is further configured to traverse the bytecode file to be processed to collect bytecode corresponding to N optimization tasks respectively, and specifically configured to:

[0032] obtain optimization configuration information, the optimization configuration information including an identifier of debugging information to be optimized;

[0033] determine a third bytecode in the bytecode file to be processed according to the identifier of the debugging information to be optimized, the third bytecode being a bytecode used to represent the debugging information to be optimized;

[0034] the processing unit is further configured to perform optimization processing on the collected bytecode corresponding to the optimization task to obtain an optimized bytecode file, and specifically configured to:

[0035] delete the third bytecode to obtain the optimized bytecode file.

[0036] In an implementation, the optimization task includes a global variable optimization task; the processing unit is further configured to traverse the bytecode file to be processed to collect bytecode corresponding to N optimization tasks respectively, and specifically configured to:

[0037] Filtering a fourth bytecode from the bytecode file to be processed, the fourth bytecode being bytecode used to represent an initial value of a global variable with an initial value of a preset value.

[0038] In an embodiment, the processing unit is further configured to perform optimization processing on the collected bytecode corresponding to the optimization task, to obtain an optimized bytecode file, and specifically configured to:

[0039] Delete the fourth bytecode to obtain the optimized bytecode file.

[0040] In an embodiment, the optimization task includes an access method optimization task; the processing unit is further configured to traverse the bytecode file to be processed to collect bytecode corresponding to the N optimization tasks respectively, and specifically configured to:

[0041] Read a fifth bytecode in the bytecode file to be processed, the fifth bytecode being bytecode used to represent a target access method, the target access method being any access method in a target application program;

[0042] Determine the to-be-optimized information according to the target access method and the inheritance relationship of each class in the data structure, the to-be-optimized information including an access member corresponding to the target access method and a calling method of the access member.

[0043] In an embodiment, the processing unit is further configured to perform optimization processing on the collected bytecode corresponding to the optimization task, to obtain an optimized bytecode file, and specifically configured to:

[0044] Modify the visibility of the access member and the calling method of the access member;

[0045] Update the bytecode corresponding to the calling method of the access member in the bytecode file to be processed, and delete the fifth bytecode to obtain the optimized bytecode file.

[0046] In an embodiment, the processing unit is further configured to:

[0047] If the optimized bytecode file meets the coding specification, perform second coding conversion processing on the optimized bytecode file to obtain an updated class file;

[0048] Perform coding processing on the updated class file to obtain an updated archive file.

[0049] In one aspect, the present application provides a processing device of an application program, the device comprising:

[0050] a processor adapted to execute a computer program;

[0051] a computer readable storage medium, the computer readable storage medium storing a computer program, the computer program being executed by the processor to implement the processing method of the application program.

[0052] In one aspect, the present application provides a computer readable storage medium, which stores a computer program, the computer program being adapted to be loaded by a processor and execute the processing method of the above application program.

[0053] In one aspect, the present application provides a computer program product or computer program, which comprises computer instructions stored in a computer readable storage medium. The processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device executes the processing method of the above application program.

[0054] In the embodiments of the present application, the archive file refers to a file for updating and replacing the installation package of the target application program, or a file for building the installation package of the target application program. The embodiments of the present application focus on multi-dimensional optimization of the bytecode file corresponding to the archive file of the target application program. First, the bytecode file to be processed is obtained from the archive file of the target application program, and N optimization tasks are set as needed. Then, the bytecode corresponding to the N optimization tasks in the bytecode file to be processed is collected, and the bytecode corresponding to each optimization task is executed for optimization processing to obtain the optimized bytecode file. Through the above process, the bytecode file in the archive file included in the installation package of the target application program can be processed for targeted and extreme optimization, the size of the bytecode file is reduced, thereby facilitating the reduction of the size of the installation package after the target application program is updated or built, and good compatibility and stability are achieved. In addition, the number of optimization tasks can be set as needed, supporting the extension of the optimization tasks, continuously increasing the compression optimization capability of the bytecode file, and further controlling the size of the installation package after the target application program is updated or built. BRIEF DESCRIPTION OF DRAWINGS

[0055] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed in the embodiments or prior art description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0056] Figure 1a A file diagram required for building an installation package of an application program provided by one exemplary embodiment of the present application is shown;

[0057] Figure 1b A file diagram required for updating an installation package of an application program provided by one exemplary embodiment of the present application is shown;

[0058] Figure 1c A process diagram of an installation package construction of an application program is shown according to an example embodiment of the present application;

[0059] Figure 2 A flow chart of a processing method of an application program is shown according to an example embodiment of the present application;

[0060] Figure 3 A flow chart of another processing method of an application program is shown according to an example embodiment of the present application;

[0061] Figure 4a A flow chart of a system annotation optimization task is shown according to an example embodiment of the present application;

[0062] Figure 4b A flow chart of a source file format optimization task is shown according to an example embodiment of the present application;

[0063] Figure 4c A flow chart of a bytecode of a source file format restoration task is shown according to an example embodiment of the present application;

[0064] Figure 4d A schematic diagram of an encoding tree is shown according to an example embodiment of the present application;

[0065] Figure 4e A flow chart of a global variable optimization task is shown according to an example embodiment of the present application;

[0066] Figure 4f A flow chart of an access method optimization task is shown according to an example embodiment of the present application;

[0067] Figure 5 A structural schematic diagram of a processing device of an application program is shown according to an example embodiment of the present application;

[0068] Figure 6 A structural schematic diagram of a processing device of an application program is shown according to an example embodiment of the present application. DETAILED DESCRIPTION

[0069] The technical solutions in the embodiments of the present application will be described below with reference to the accompanying drawings.

[0070] The installation package of the application program is a collection of self-decompressible files, which contains all the files of the application program installation. Running the installation package of the application program can release all the files of the application program to the hard disk of the computer device, complete the modification of the registry, the modification of the system settings, the creation of the shortcut, and the like, so that the computer device can use the functions of the application program. The installation package of the application program has different formats due to different installation environments of the application program, where the installation environment refers to the operating system environment of the computer device, for example, the installation package of the application program in the Android (a kind of mobile operating system) environment is in the APK (Android application package) format; the installation package of the application program in the IOS (a kind of mobile operating system) environment is in the IPA (iPhone application) format. The APK installation package is taken as an example for description in the subsequent embodiments of the present application.

[0071] The archive file of the application program is a file used for aggregating the Class files, metadata (i.e. data used for describing attributes), and resources (such as texts, pictures, and the like) of the application program; it can be used to build the installation package of the application program, and can also be used to update the installation package of the application program. Figure 1a A schematic diagram of files required for building the installation package of the application program is shown in an example embodiment of the present application; Figure 1a The installation package of the application program shown is an APK, and the archive file of the APK is a Jar package. As shown in Figure 1a As shown, the APK is obtained by jointly packing M archive files (Jar packages) and other files (such as an entry file), where M is a positive integer. Figure 1b A schematic diagram of files required for updating the installation package of the application program is shown in an example embodiment of the present application; Figure 1b In the above, the updated APK is obtained by replacing the old archive file in the original APK with a new archive file, or adding the new archive file as a new file to the original APK. As can be seen, whether the installation package of the application program is built or updated, the archive file is required. The archive file of the application program contains the Class file, which is a binary file with the suffix “.class” generated by the compiler after compiling the source file of the application program. The Class file can be converted into a bytecode file, which is a binary file containing an execution program, composed of a sequence of operation code / data pairs, and is a file preprocessed by the compiler, which is an existing form of the execution file of the application program.

[0072] Since the size of the installation package of an application program is closely related to the download conversion rate and has a great influence on the promotion of the application program, the size of the installation package needs to be strictly controlled when the installation package of the application program is constructed or iterated. Based on this, an embodiment of the present application proposes a processing scheme of an application program, which can effectively compress the size of the installation package of the application program, and has the following characteristics: (1) The design goal of the scheme is to give priority to generality, expansibility and high performance. The generality refers to: supporting all application programs to quickly and simply access the scheme to achieve the goal of compressing the size of the installation package; the expansibility refers to: supporting the extension and quick access of new optimization forms to the scheme, and continuously enhancing the bytecode compression capability by continuously expanding the optimization forms; the high performance refers to: the scheme will intervene in the construction process of the installation package of the application program, and after the construction process of the installation package of the application program accesses the scheme, the incremental compilation time caused by the access can be reduced as much as possible. (2) The scheme supports the plug-in form to access the construction process of the installation package of the application program, hooks the obfuscation task or JarMerge (Jar file merging) task of the installation package of the application program in the construction process, collects the archive files output by the obfuscation task or JarMerge task, and performs targeted and extreme optimization processing on the bytecode files in the archive files, so as to reduce the size of the bytecode files, thereby being conducive to reducing the size of the installation package of the target application program after updating or construction, and having good compatibility and stability; the application program can optimize the bytecode files by using the plug-in in the construction script, so as to ensure the generality of the optimization scheme. (3) The number of optimization tasks for the bytecode files can be set as needed, supports the extension of the optimization tasks, can continuously increase the compression optimization capability of the bytecode files, and further controls the size of the installation package of the target application program after updating or construction.

[0073] Figure 1c A construction process diagram of an application installation package provided by an example embodiment of the present application is shown. As shown in FIG. 1, the construction process of the application installation package includes the following steps: Figure 1cAs shown, the embodiment of the present application designs an application processing method in the construction process of the application package, which mainly collects the to-be-optimized bytecode from the bytecode file of the application, and then optimizes (such as deletes or replaces) the bytecode, so as to achieve the purpose of compressing the application package. Similarly, in the updating process of the application package, the bytecode in the archive file included in the application package can also be optimized by using the application processing method provided by the present application, so as to achieve the purpose of compressing the application package. The application processing method can be applied to a terminal device or a server, and the terminal device can include but is not limited to a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a portable personal computer, a mobile Internet device (Mobile Internet Devices, MID) and the like, and the server can include but is not limited to a cluster server, and the embodiment of the present application is not limited thereto.

[0074] In Figure 1c In the Android package construction process, the application processing flow mainly includes: ①obtaining the to-be-processed bytecode file from the archive file (jar package) of the target application; ②traversing the to-be-processed bytecode file to collect the bytecode corresponding to N optimization tasks (such as annotation optimization task, debugging information optimization task, global variable optimization task, etc.), N being a positive integer; the value of N can be set according to actual needs, for example, N is 3, 5, etc. The larger the value of N is, the more comprehensive the optimization task is, and the better the compression effect of the bytecode file is; at the same time, the complexity of optimization execution is also relatively high, and the time and resources consumed are also relatively more. ③performing optimization processing on the collected bytecode corresponding to the optimization task (such as re-encoding the bytecode indicating the source file format to obtain simplified bytecode; deleting the debugging information indicated in the optimization configuration information), to obtain the optimized bytecode file (i.e. the compressed bytecode file).

[0075] It can be seen that the embodiment of the application focuses on multi-dimensional optimization of the bytecode file corresponding to the archive file. First, the bytecode file to be processed is obtained from the archive file of the target application program, and N optimization tasks are set as needed. Then, the bytecode corresponding to the N optimization tasks in the bytecode file to be processed is collected, and the bytecode corresponding to each optimization task is optimized to obtain the optimized bytecode file. Through the above process, the bytecode file in the archive file included in the installation package of the target application program can be optimized in a targeted and extreme manner, and the size of the bytecode file is reduced. Since the update process and the construction process of the target application program involve the archive file, multi-dimensional optimization of the bytecode file corresponding to the archive file is beneficial to reducing the size of the installation package after the target application program is updated or constructed, and has good compatibility and stability. In addition, the number of optimization tasks can be set as needed, supporting the expansion of optimization tasks, which can continuously increase the compression optimization capability of the bytecode file, and further control the size of the installation package after the target application program is updated or constructed.

[0076] Figure 2 A flowchart of a processing method of an application program provided by an example embodiment of the application is shown. As shown in Figure 2 The processing method of the application program includes but is not limited to the following steps 201-203. The processing method of the application program provided by the embodiment of the application will be described in detail below:

[0077] 201. Obtain the bytecode file to be processed from the archive file of the target application program.

[0078] The target application program can be a browser application program, a shopping application program, a game application program, etc. In an embodiment, the processing device of the application program decodes the archive file of the target application program to obtain the class file of the target application program, and then encodes the class file to obtain the bytecode file to be processed of the target application program.

[0079] 202. Traverse the bytecode file to be processed to collect bytecode corresponding to N optimization tasks, N being a positive integer.

[0080] One optimization task can be used to optimize one type of bytecode; for example, optimization task 1 can be used to optimize bytecode representing system annotations, optimization task 2 can be used to optimize bytecode representing source program format, and so on. The value of N can be set as needed; for example, considering the balance between the compression effect of the bytecode file and the resource consumption, the value of N is set to 5. For another example, if it is required to optimize 3 types of bytecode in the bytecode file of the application program 1, the value of N is 3. As can be seen, the application processing method provided by the embodiment of the application can be compatible with multiple optimization tasks and can optimize multiple types of bytecode, thereby ensuring compatibility and scalability.

[0081] 203. Perform optimization processing on the collected bytecode corresponding to the optimization task to obtain an optimized bytecode file.

[0082] The optimization processing includes but is not limited to modification processing and deletion processing; for example, the application processing device performs deletion processing on the bytecode corresponding to the optimization task 1 and modifies the bytecode "cafe 01" corresponding to the optimization task 2 to "ba".

[0083] The embodiment of the application focuses on multi-dimensional optimization of the bytecode file corresponding to the archive file. First, the bytecode file to be processed is obtained from the archive file of the target application program, and N optimization tasks are set as needed. Then, the bytecode corresponding to the N optimization tasks in the bytecode file to be processed is collected, and optimization processing is performed on the bytecode corresponding to each optimization task to obtain an optimized bytecode file. Through the above process, the bytecode file in the archive file included in the installation package of the target application program can be optimized in a targeted and extreme manner, and the size of the bytecode file can be reduced. Since the update process and the construction process of the target application program involve the archive file, multi-dimensional optimization of the bytecode file corresponding to the archive file is beneficial to reducing the size of the installation package after the target application program is updated or constructed, and has good compatibility and stability. In addition, the number of optimization tasks can be set as needed, supporting the extension of the optimization tasks, and the compression optimization capability of the bytecode file can be continuously increased, further controlling the size of the installation package after the target application program is updated or constructed.

[0084] Figure 3 A flowchart of another application processing method provided by an example embodiment of the application is shown. As shown in Figure 3 The application processing method includes but is not limited to the following steps 301-322. The application processing method provided by the embodiment of the application is described in detail as follows:

[0085] 301. Decode the target application's archive file to obtain the target application's class file. The target application contains multiple classes, which are cohesive packages composed of specific metadata. Classes include interfaces and structs. One or more classes are aggregated into a single class file, which is a binary file with the ".class" extension generated by the compiler after compiling the classes in the application's source files.

[0086] 302. Perform a first encoding conversion process on the class file to obtain a bytecode file to be processed. The first encoding conversion process here refers to the process of converting the class file into a bytecode file that the computer can recognize through the compiler; the bytecode file to be processed is stored in the memory of the application's processing device in byte form.

[0087] 303. Traverse the bytecode file to be processed and construct the data structure of the target application.

[0088] In one implementation, the application's processing device traverses the bytecode file to be processed at least once, parsing the classes and elements contained in each class to obtain the inheritance relationships between them. Inheritance is the process of deriving a new class from an existing class. The new class can absorb the data attributes and behaviors of the existing class and extend new capabilities. The existing class is called the parent class, and the new class is called the child class. The inheritance relationship refers to the parent-child relationship between the parent class and the child class. This inheritance relationship includes: the child class inheriting the characteristics and behaviors of the parent class, so that the child class object (instance) has the attributes and methods of the parent class; or the child class inheriting methods from the parent class, so that the child class has the same behavior as the parent class. The data structure of the target application is constructed based on the inheritance relationships of the classes. This data structure contains the inheritance relationships of the classes in the target application; the data structure may include, but is not limited to, array structures, tree structures, etc. Taking a tree structure as an example, this application can construct an inheritance tree containing all classes based on the inheritance relationships of the classes in the target application.

[0089] 304. Traverse the bytecode file to be processed to obtain the first bytecode set.

[0090] The first bytecode refers to the bytecode in the bytecode file to be processed that represents system annotations; system annotations are used to represent various reflection information about classes (as well as methods and fields), and specific system annotations may include, but are not limited to: getEnclosingMethod, getSimpleName, isLocalOrAnonymousClass, getGenericSuperclass, and getTypeParameters.

[0091] 305. Add the first bytecode in the first bytecode set that meets the protection conditions to the whitelist.

[0092] Figure 4a A flowchart illustrating a system annotation optimization task provided in an exemplary embodiment of this application is shown. Figure 4a As shown, the system annotation optimization task includes two phases: "information collection" and "optimization execution." Let the target bytecode be any first bytecode in the first bytecode set. In the information collection phase, the application's processing device first determines whether the system annotation represented by the target bytecode is used, i.e., whether the class to which the target bytecode belongs calls a system annotation method. If the system annotation represented by the target bytecode is used, it further determines whether the class to which the system annotation belongs is an interface implementation class, or, based on the inheritance relationship in the data structure, whether the class to which the system annotation belongs has a parent class. If the class to which the system annotation belongs is an interface implementation class, or the class to which the system annotation belongs has a parent class, then the target bytecode is deemed to meet the protection conditions, and the target bytecode is added to the whitelist. It can be seen that the first bytecode in the whitelist satisfies the following conditions: (1) the system annotation represented by the first bytecode in the whitelist has been used; (2) the class to which the system annotation represented by the first bytecode in the whitelist belongs has a parent class, or the class to which the system annotation represented by the first bytecode in the whitelist belongs is an interface implementation class.

[0093] 306. Delete the first bytecode in the bytecode file that belongs to the first bytecode set but is not in the whitelist, and obtain the optimized bytecode file.

[0094] During the optimization execution phase, the application's processing device deletes the first bytecode in the bytecode file that belongs to the first bytecode set but is not in the whitelist, resulting in the optimized bytecode file. It is understood that the system annotation represented by the deleted first bytecode meets the following conditions: the system annotation represented by the deleted first bytecode is not used, the class to which the system annotation represents has no parent class, and the class to which the system annotation represents is not an interface implementation class.

[0095] As can be seen, by executing the system annotation optimization task, the application's processing device can adaptively filter and delete bytecode representing system annotations in the bytecode file to be processed, based on protection conditions, thereby obtaining an optimized bytecode file. Through this dynamic deletion method, the bytecode file to be processed can be compressed while ensuring the availability and stability of the application.

[0096] 307. Traverse the bytecode file to be processed to obtain the second bytecode.

[0097] Figure 4b A flow chart of a source file format optimization task is shown. As shown in Figure 4b the processing device of the application program first collects all the bytecodes of the source file format, i.e. traverses the bytecode file to be processed to obtain second bytecodes, wherein the second bytecodes refer to bytecodes in the bytecode file to be processed for indicating the source file (sourceFile) format, and the source file format is the file name for marking the code file (e.g. java file).

[0098] 308. According to the frequency of the second bytecodes in the bytecode file to be processed, an encoding tree of the second bytecodes is constructed.

[0099] The processing device of the application program re-encodes the bytecodes of the source file format to obtain simplified bytecodes. In an embodiment, the processing device of the application program constructs a Huffman tree according to the frequency (number of times) of the second bytecodes in the bytecode file to be processed.

[0100] 309. The second bytecodes are encoded according to the encoding rule of the encoding tree to obtain simplified bytecodes and a mapping file.

[0101] The mapping file is used to restore the simplified bytecodes to the second bytecodes. Figure 4c A flow chart of restoring the bytecodes of the source file format is shown. As shown in Figure 4c the processing device of the application program imports a mapping file, and then restores the simplified bytecodes of the source file format to the original bytecodes of the source file format according to the mapping file.

[0102] 310. The second bytecodes in the bytecode file to be processed are replaced by the simplified bytecodes to obtain an optimized bytecode file.

[0103] The source file format optimization task is described below by a complete example. It is assumed that bytecode 1 is "XXXXXXXX", bytecode 2 is "YYYYYYYY", and bytecode 3 is "ZZZZZZZZ", i.e. the length of bytecode 1-codebook 3 is 8, the number of times of bytecode 1 in the bytecode file to be processed is 5, the number of times of bytecode 2 in the bytecode file to be processed is 7, and the number of times of bytecode 3 in the bytecode file to be processed is 13. The Huffman tree constructed according to the number of times of bytecode 1-codebook 3 in the bytecode file to be processed is shown in Figure 4d Figure 4d ​The encoding rule of the encoding tree encodes the bytecode 1-bytecode 3 to obtain the simplified bytecode "00" of the bytecode 1, the simplified bytecode "01" of the bytecode 2, and the simplified bytecode "1" of the bytecode 3. The mapping file of the bytecode 1-bytecode 3 is shown in Table 1.

[0104] Table 1

[0105] Bytecode Simplified bytecode XXXXXXXX 00 YYYYYYYY 01 ZZZZZZZZZ 1

[0106] As described above, before simplification, the total length of the bytecode 1-bytecode 3 in the to-be-processed bytecode file is 8*(5+7+13)=200; and after simplification, the total length of the bytecode 1-bytecode 3 in the optimized bytecode file is 2*5+2*7+1*13=37.

[0107] It can be seen that by executing the source file format optimization task, the processing device of the application program can compress the bytecode for representing the source file format by using the encoding tree, and then obtain the optimized bytecode file; in addition, the compressed bytecode can be restored by using the mapping file.

[0108] 311. Obtain optimization configuration information.

[0109] The optimization configuration information includes an identifier of to-be-optimized debugging information (such as a package name of the debugging information or a regular expression of the package name of the debugging information); wherein the debugging information contains a line number and a local variable table, and retaining the debugging information in the to-be-processed bytecode file will cause a security risk of the target application program. In an implementation manner, the optimization configuration information of the debugging information optimization task can be preconfigured, or can be configured according to actual needs when a user compresses an installation package of the target application program.

[0110] 312. Determine a third bytecode in the to-be-processed bytecode file according to the identifier of the to-be-optimized debugging information. The third bytecode refers to a bytecode for representing the to-be-optimized debugging information.

[0111] 313. Delete the third bytecode to obtain an optimized bytecode file.

[0112] It can be seen that by executing the debugging information optimization task, the processing device of the application program can dynamically delete the bytecode for representing the debugging information in the to-be-processed bytecode file according to the optimization configuration information, and then obtain the optimized bytecode file.

[0113] 314. Screen a fourth bytecode from the to-be-processed bytecode file.

[0114] Figure 4e A flowchart of a global variable optimization task provided by an example embodiment of the present application is shown. As shown in FIG. 4, the global variable optimization task includes the following steps.Figure 4e As shown, the processing device of the application program first collects the bytecode corresponding to the initial value of the global variable in the bytecode file to be processed, obtains the bytecode set for representing the initial value of the global variable, and determines the initial value corresponding to each global variable according to the bytecode set. Then, it is judged in the constructor whether the initialized value of each global variable is the preset value, that is, the fourth bytecode is screened out from the bytecode file to be processed; wherein the constructor is mainly used to initialize the object when the object is created, that is, to assign the initial value to the object member variable, and the fourth bytecode refers to the bytecode for representing the initial value of the global variable with the initial value being the preset value. In an embodiment, the fourth bytecode refers to the bytecode for representing the initial value of the global variable with the initial value being 0 (that is, the fourth bytecode refers to the bytecode for representing the initial value 0).

[0115] Table 2 is an invalid variable initialization table provided by the embodiment of the present application to support automatic deletion.

[0116] Table 2

[0117]

[0118] Table 2 shows the invalid initial value corresponding to the global variable under each data type. When the initial value of the global variable is the same as the initial value corresponding to each data type in Table 2, the processing device of the application program determines the bytecode corresponding to the initial value of the global variable as the fourth bytecode; for example, assuming that there is a global variable a in the application program 1, and "int a = 0", the processing device of the application program determines the bytecode corresponding to "0" in "int a = 0" as the fourth bytecode.

[0119] 315, deleting the fourth bytecode to obtain the optimized bytecode file.

[0120] As can be seen, by executing the global variable optimization task, the processing device of the application program can delete the bytecode corresponding to the invalid initialization value in the bytecode file to be processed, and further obtain the optimized bytecode file.

[0121] 316, traversing the bytecode file to be processed, and constructing the data structure of the target application program.

[0122] The specific implementation of step 316 can refer to the specific implementation of step 303, which will not be described here. It should be noted that if the optimization task includes the system annotation optimization task, and the processing device of the application program has already constructed the data structure of the target application program when executing the system annotation optimization task, this step will not be executed; similarly, if the optimization task includes the global variable optimization task, and the processing device of the application program has already constructed the data structure of the target application program when executing the global variable optimization task, step 303 will not be executed when executing the system annotation optimization task.

[0123] 317. Read the fifth byte code from the byte code file to be processed.

[0124] Figure 4f A flowchart illustrating an access method optimization task provided in an exemplary embodiment of this application is shown. Figure 4f As shown, the access method optimization task includes two phases: "information gathering" and "optimization execution." In the information gathering phase, the application's processing device filters the fifth bytecode in the bytecode file to be processed. The fifth bytecode refers to the bytecode representing the target access method, which can be any access method in the target application. In one implementation, the access method refers to the Access method, which is used to bridge nested classes and private members, allowing them to access each other. Here, a nested class refers to another class defined within a class; for example, if class 1 is a class defined within class 2, then class 1 is a nested class of class 2. Private members refer to private data and functions within a class.

[0125] 318. Determine the information to be optimized based on the target access method and the inheritance relationship of each class in the data structure.

[0126] The application's processing device extracts information to be optimized, including the access member corresponding to the target access method and the calling method of that access member. In one implementation, the application's processing device analyzes the target access method to determine the access member, and determines the calling method of the access member based on the inheritance relationship of each class in the data structure.

[0127] 319. Modify the visibility of access members and the method for accessing members.

[0128] During the optimization execution phase, the application's processing device modifies the visibility of access members. In one implementation, the application's processing device changes the visibility of access members from private to package visible, that is, it changes private members to package visible members, and correspondingly modifies the calling method of the access member, that is, it changes the original access via the Access method to direct access.

[0129] 320. In the bytecode file to be processed, update the bytecode corresponding to the calling method of the access member according to the modification, and delete the fifth bytecode to obtain the optimized bytecode file.

[0130] In an implementation, the processing device of the application updates the corresponding bytecode in the bytecode file to be processed according to the modification in step 319; for example, the bytecode for indicating the private member corresponding to the access method is modified to the bytecode of the corresponding package-visible member. Then the fifth bytecode in the bytecode file to be processed is deleted to obtain the optimized bytecode file.

[0131] As can be seen, by executing the access method optimization task, the processing device of the application can modify the access member corresponding to the access method and the calling method of the member according to the inheritance relationship of each class in the access method and the data structure, and delete the access method, thereby obtaining the optimized bytecode file.

[0132] According to the description of the above embodiments, considering the compression effect of the bytecode file, the resource consumption degree and the actual optimization requirement, the value of N in the implementation is 5, and the N optimization tasks include: the system annotation optimization task corresponding to steps 303-306, the source file format optimization task corresponding to steps 307-310, the debugging information optimization task corresponding to steps 311-313, the global variable optimization task corresponding to steps 314 and 315, and the access method optimization task corresponding to steps 316-320. When actually compressing the installation package of the target application, the processing device of the application can execute one or more of the above optimization tasks according to the actual requirement, each optimization task can be executed in parallel or in a specified order, and the embodiments of the application do not limit this; for example, the processing device of the application can only execute the global variable optimization task and the access method optimization task, and the global variable optimization task and the access method optimization task can be executed in parallel or the access method optimization task can be executed first and then the global variable optimization task. In addition to the above five optimization tasks, the processing method of the application provided by the application can also add other optimization tasks when used; for example, an R file optimization task can also be added, wherein the R file is a file for declaring static variables.

[0133] 321、If the optimized bytecode file meets the coding specification, the optimized bytecode file is subjected to a second coding conversion process to obtain an updated class file.

[0134] In an embodiment, the processing device of the application program detects whether the optimized bytecode file meets the coding specification after each optimization task is completed; for example, the processing device of the application program detects whether the members corresponding to each bytecode in the optimized bytecode file can be normally accessed, if the optimized bytecode file does not meet the coding specification, the optimization task is abandoned, and other optimization tasks are continued to be executed, if the optimized bytecode file meets the coding specification, the processing device of the application program detects whether the N optimization tasks have been completed, if the N optimization tasks have been completed, the optimized bytecode file is subjected to a second encoding conversion processing to obtain an updated class file; correspondingly, if there are unfinished optimization tasks, the unfinished optimization tasks are continued to be executed until the N optimization tasks are completed. The second encoding conversion processing refers to a process of converting the optimized bytecode file into the updated class file by using a compiler, the optimized bytecode file is stored in the memory of the processing device of the application program in byte form, and the updated class file is stored in the hard disk of the processing device of the application program.

[0135] 322, the updated class file is subjected to an encoding processing to obtain an updated archive file.

[0136] In an embodiment, the processing device of the application program subjects the updated class file to an encoding processing to obtain an updated archive file, and uses the updated archive file to build an installation package of the target application program, or uses the updated archive file to update the installation package of the target application program (for example, uses the updated archive file to replace the corresponding original archive file in the installation package of the target application program).

[0137] Optionally, in actual application, the processing method of the application program provided in the embodiments of the present application can be combined with an existing application program installation package compression scheme (for example, a proguard scheme). Experimental data shows that, after the target application program is processed by using the proguard scheme, the bytecode of the target application program processed by the proguard scheme is compressed by using the processing method of the application program provided in the embodiments of the present application, the size of the bytecode can be compressed by 12%; if the processing method of the application program provided in the embodiments of the present application is used alone to compress the bytecode of the target application program, the size of the bytecode can be compressed by 25%.

[0138] The embodiment of the application focuses on multi-dimensional optimization of bytecode files corresponding to archive files of a target application program, obtains a bytecode file to be processed from the archive files of the target application program, and respectively performs targeted optimization on the bytecode file to be processed through five optimization tasks. Through the above process, the bytecode files in the archive files contained in the installation package of the target application program can be processed in a targeted and extreme manner, the size of the bytecode files is reduced, thereby facilitating reduction of the size of the installation package after the target application program is updated or built, and good compatibility and stability are achieved. In addition, the number of optimization tasks can be set as needed, supporting extension of the optimization tasks, continuously increasing the compression optimization capability of the bytecode files, and further controlling the size of the installation package after the target application program is updated or built.

[0139] The above describes the method of the embodiment of the application in detail. In order to better implement the above scheme of the embodiment of the application, the device of the embodiment of the application is provided as follows.

[0140] Please refer to Figure 5 , Figure 5 Fig. 1 shows a structural schematic diagram of an application program processing device provided by an example embodiment of the application. The application program processing device can be carried on the application program processing device in the method embodiment described above. The application program processing device can be a plug-in, for example, a compression plug-in. When it is necessary to update or build the installation package of the application program, the compression plug-in can be called to compress the installation package of the application program. Therefore, the application program processing device provided by the embodiment of the application has strong versatility. Figure 5 The application program processing device shown in Fig. 1 can be used to perform part or all of the functions of the method embodiments described above and Figure 2 and Figure 3 The detailed description of each unit is as follows.

[0141] The obtaining unit 501 is configured to obtain a bytecode file to be processed from the archive files of the target application program.

[0142] The processing unit 502 is configured to traverse the bytecode file to be processed to collect bytecode corresponding to N optimization tasks, N being a positive integer, and perform optimization processing on the collected bytecode corresponding to the optimization tasks to obtain an optimized bytecode file.

[0143] In an implementation manner, the processing unit 502 is further configured to obtain the bytecode file to be processed from the archive files of the target application program, and specifically configured to:

[0144] decode the archive files of the target application program to obtain class files of the target application program;

[0145] performing a first encoding conversion processing on the class file to obtain a bytecode file to be processed;

[0146] The processing unit 502 is further configured to:

[0147] traverse the bytecode file to be processed and construct a data structure of the target application, the data structure containing inheritance relationships of each class in the target application.

[0148] In an embodiment, the optimization task includes a system annotation optimization task, and the processing unit 502 is further configured to traverse the bytecode file to be processed to collect bytecode corresponding to the N optimization tasks, specifically configured to:

[0149] traverse the bytecode file to be processed to obtain a first bytecode set, the first bytecode set containing at least one first bytecode, the first bytecode being bytecode used to represent a system annotation;

[0150] add the first bytecode in the first bytecode set that meets the protection condition to a whitelist;

[0151] The collected bytecode corresponding to the system annotation optimization task is the first bytecode located in the first bytecode set and not belonging to the whitelist.

[0152] In an embodiment, the target bytecode is any one of the first bytecode set, and the processing unit 502 is further configured to determine whether the target bytecode meets the protection condition, specifically configured to:

[0153] determine whether the class to which the target bytecode belongs calls a system annotation method;

[0154] If the class to which the target bytecode belongs calls the system annotation method, determine whether the class to which the target bytecode belongs is an interface implementation class, or determine whether the class to which the target bytecode belongs has a parent class according to the inheritance relationship in the data structure;

[0155] If the class to which the target bytecode belongs is an interface implementation class, or the class to which the target bytecode belongs has a parent class, it is determined that the target bytecode meets the protection condition.

[0156] In an embodiment, the processing unit 502 is further configured to perform optimization processing on the collected bytecode corresponding to the optimization task to obtain an optimized bytecode file, specifically configured to:

[0157] delete the first bytecode in the bytecode file to be processed that belongs to the first bytecode set and does not belong to the whitelist to obtain the optimized bytecode file.

[0158] In an implementation, the optimization task includes a source file format optimization task; the collected bytecode corresponding to the source file format optimization task is a second bytecode in the bytecode file to be processed, and the second bytecode is a bytecode used to represent a source file format; the processing unit 502 is further configured to perform optimization processing on the collected bytecode corresponding to the optimization task, to obtain an optimized bytecode file, and specifically configured to:

[0159] construct an encoding tree of the second bytecode according to a frequency of occurrence of the second bytecode in the bytecode file to be processed;

[0160] encode the second bytecode according to an encoding rule of the encoding tree, to obtain a simplified bytecode and a mapping file;

[0161] replace the second bytecode in the bytecode file to be processed with the simplified bytecode, to obtain the optimized bytecode file;

[0162] The mapping file can be used to restore the simplified bytecode to the second bytecode.

[0163] In an implementation, the optimization task includes a debugging information optimization task; the processing unit 502 is further configured to traverse the bytecode file to be processed to collect bytecodes corresponding to N optimization tasks respectively, and specifically configured to:

[0164] obtain optimization configuration information, the optimization configuration information including an identifier of debugging information to be optimized;

[0165] determine a third bytecode in the bytecode file to be processed according to the identifier of the debugging information to be optimized, the third bytecode being a bytecode used to represent the debugging information to be optimized;

[0166] The processing unit 502 is further configured to perform optimization processing on the collected bytecode corresponding to the optimization task, to obtain an optimized bytecode file, and specifically configured to:

[0167] delete the third bytecode, to obtain the optimized bytecode file.

[0168] In an implementation, the optimization task includes a global variable optimization task; the processing unit 502 is further configured to traverse the bytecode file to be processed to collect bytecodes corresponding to N optimization tasks respectively, and specifically configured to:

[0169] filter a fourth bytecode from the bytecode file to be processed, the fourth bytecode being a bytecode used to represent an initial value of a global variable with a preset initial value.

[0170] In an implementation, the processing unit 502 is further configured to perform optimization processing on the collected bytecode corresponding to the optimization task, to obtain an optimized bytecode file, and specifically configured to:

[0171] The fourth bytecode is deleted, and an optimized bytecode file is obtained.

[0172] In an embodiment, the optimization task includes an access method optimization task, and the processing unit 502 is further configured to traverse the bytecode file to be processed to collect bytecode corresponding to the N optimization tasks respectively, and specifically configured to:

[0173] read a fifth bytecode in the bytecode file to be processed, the fifth bytecode being bytecode used to represent a target access method, the target access method being any access method in the target application program;

[0174] determine the information to be optimized according to the target access method and the inheritance relationship of each class in the data structure, the information to be optimized including an access member corresponding to the target access method and a calling method of the access member.

[0175] In an embodiment, the processing unit 502 is further configured to perform optimization processing on the bytecode corresponding to the collected optimization tasks to obtain an optimized bytecode file, and specifically configured to:

[0176] modify the visibility of the access member and the calling method of the access member;

[0177] update the bytecode corresponding to the calling method of the access member in the bytecode file to be processed, and delete the fifth bytecode, to obtain an optimized bytecode file.

[0178] In an embodiment, the processing unit 502 is further configured to:

[0179] if the optimized bytecode file meets the coding specification, perform second coding conversion processing on the optimized bytecode file to obtain an updated class file;

[0180] perform coding processing on the updated class file to obtain an updated archive file.

[0181] According to an embodiment of the present application, Figure 2 and Figure 3 part of the steps involved in the processing method of the application program shown in Figure 5 may be executed by each unit in the processing device of the application program shown in. For example, Figure 2 the step 201 shown in Figure 5 may be executed by the acquisition unit 501, and the steps 202 and 203 may be executed by the processing unit 502. Figure 5 Figure 3 the steps 304, 307 and 311 shown in Figure 5 may be executed by the acquisition unit 501, and the steps 301-303, 305, 306, 308-310 and 312-322 may be executed by the processing unit 502.​Figure 5 The processing unit 502 shown performs. Figure 5 The various units in the processing device of the application program shown can be respectively or all combined into one or several other units to constitute, or some of the units can also be further split into a plurality of units with smaller functions to constitute, which can achieve the same operation without affecting the implementation of the technical effects of the embodiments of the present application. The above-mentioned units are divided based on logical functions, and in actual application, the functions of one unit can also be implemented by multiple units, or the functions of multiple units are implemented by one unit. In other embodiments of the present application, the processing device of the application program can also include other units, and in actual application, these functions can also be assisted by other units, and can be implemented by multiple units.

[0182] According to another embodiment of the present application, the processing device of the application program shown in Figure 2 and Figure 3 The computer program (including program code) involved in the respective methods shown in Figure 5 The processing device of the application program shown in

[0183] Based on the same inventive concept, the processing device of the application program provided in the embodiments of the present application has similar principles and beneficial effects for solving problems as the processing method of the application program in the method embodiments of the present application, and the principles and beneficial effects of the method implementation can be referred to. For brevity of description, it will not be described here.

[0184] Please refer to Figure 6 , Figure 6A structural schematic diagram of a processing device of an application program is shown, which can be a terminal device or a server; the processing device of the application program at least includes a processor 601, a communication interface 602 and a memory 603. The processor 601, the communication interface 602 and the memory 603 can be connected through a bus or other manners, and the embodiment of the application takes the connection through the bus as an example. The processor 601 (or called central processing unit (CPU)) is the calculation core and control core of the processing device of the application program, which can parse various instructions in the terminal device and process various data of the terminal device, for example: the CPU can be used to parse the on-off instruction sent by the user to the terminal device, and control the terminal device to perform the on-off operation; for another example: the CPU can transmit various interactive data between the internal structures of the terminal device, and the like. The communication interface 602 can optionally include a standard wired interface, a wireless interface (such as WI-FI, a mobile communication interface, etc.), and can be used for transmitting and receiving data under the control of the processor 601; the communication interface 602 can also be used for transmitting and interacting the internal data of the terminal device. The memory 603 is a memory device in the terminal device, which is used to store programs and data. It can be understood that the memory 603 here can include the built-in memory of the terminal device, and of course can also include the expansion memory supported by the terminal device. The memory 603 provides a storage space, which stores the operating system of the terminal device, which can include but is not limited to: Android system, iOS system, Windows Phone system, etc., and the application does not limit this.

[0185] In one embodiment, the processing device of the application program can refer to a terminal device or a server. In this case, the processor 601 executes the following operations by running the executable program code in the memory 603:

[0186] Obtain the to-be-processed bytecode file from the archive file of the target application program through the communication interface 602;

[0187] Traverse the to-be-processed bytecode file to collect bytecode corresponding to N optimization tasks respectively, N is a positive integer; and perform optimization processing on the collected bytecode corresponding to the optimization tasks to obtain an optimized bytecode file.

[0188] As an optional implementation manner, the specific implementation manner of the processor 601 obtaining the to-be-processed bytecode file from the archive file of the target application program is:

[0189] Decode the archive file of the target application program to obtain the class file of the target application program;

[0190] performing first encoding conversion processing on the class files to obtain a bytecode file to be processed;

[0191] The processor 601 also performs the following operations by running the executable program code in the memory 603:

[0192] traversing the bytecode file to be processed and constructing a data structure of the target application, the data structure containing inheritance relationships of each class in the target application.

[0193] As an optional implementation, the optimization task includes a system annotation optimization task, and the processor 601 traverses the bytecode file to be processed to collect the bytecode corresponding to the N optimization tasks, and the specific implementation is as follows:

[0194] traversing the bytecode file to be processed to obtain a first bytecode set, the first bytecode set containing at least one first bytecode, the first bytecode being bytecode used to represent a system annotation;

[0195] adding the first bytecode in the first bytecode set that meets the protection condition to a whitelist;

[0196] The bytecode corresponding to the collected system annotation optimization task refers to the first bytecode in the first bytecode set that does not belong to the whitelist.

[0197] As an optional implementation, the target bytecode is any one of the first bytecode set, and the specific implementation in which the processor 601 judges whether the target bytecode meets the protection condition is as follows:

[0198] judging whether the class to which the target bytecode belongs calls a system annotation method;

[0199] If the class to which the target bytecode belongs calls a system annotation method, judging whether the class to which the target bytecode belongs is an interface implementation class, or judging whether the class to which the target bytecode belongs has a parent class according to the inheritance relationship in the data structure;

[0200] If the class to which the target bytecode belongs is an interface implementation class, or the class to which the target bytecode belongs has a parent class, it is determined that the target bytecode meets the protection condition.

[0201] As an optional implementation, the specific implementation in which the processor 601 performs optimization processing on the bytecode corresponding to the collected optimization task to obtain an optimized bytecode file is as follows:

[0202] deleting the first bytecode in the bytecode file to be processed that belongs to the first bytecode set and does not belong to the whitelist to obtain an optimized bytecode file.

[0203] As an optional implementation, the optimization task includes a source file format optimization task; the collected bytecode corresponding to the source file format optimization task is a second bytecode in the bytecode file to be processed, and the second bytecode is a bytecode for representing a source file format; and the processor 601 performs optimization processing on the collected bytecode corresponding to the optimization task to obtain the bytecode file after optimization.

[0204] According to the frequency of the second bytecode in the bytecode file to be processed, an encoding tree of the second bytecode is constructed.

[0205] The second bytecode is encoded according to the encoding rule of the encoding tree to obtain a simplified bytecode and a mapping file.

[0206] The second bytecode in the bytecode file to be processed is replaced by the simplified bytecode to obtain the bytecode file after optimization.

[0207] The mapping file can be used to restore the simplified bytecode to the second bytecode.

[0208] As an optional implementation, the optimization task includes a debugging information optimization task; and the processor 601 traverses the bytecode file to be processed to collect the bytecode corresponding to the N optimization tasks in the following specific implementation.

[0209] Obtain optimization configuration information, which includes the identifier of the debugging information to be optimized.

[0210] According to the identifier of the debugging information to be optimized, a third bytecode in the bytecode file to be processed is determined, and the third bytecode is a bytecode for representing the debugging information to be optimized.

[0211] The processor 601 performs optimization processing on the collected bytecode corresponding to the optimization task to obtain the bytecode file after optimization in the following specific implementation.

[0212] The third bytecode is deleted to obtain the bytecode file after optimization.

[0213] As an optional implementation, the optimization task includes a global variable optimization task; and the processor 601 traverses the bytecode file to be processed to collect the bytecode corresponding to the N optimization tasks in the following specific implementation.

[0214] The fourth bytecode is filtered from the bytecode file to be processed, and the fourth bytecode is a bytecode for representing the initial value of the global variable with a preset initial value.

[0215] As an optional implementation, the processor 601 performs optimization processing on the collected bytecode corresponding to the optimization task to obtain the bytecode file after optimization in the following specific implementation.

[0216] The fourth bytecode is deleted to obtain the optimized bytecode file.

[0217] As an optional implementation, the optimization task includes an access method optimization task; the processor 601 traverses the bytecode file to be processed to collect the bytecode corresponding to the N optimization tasks, and the specific implementation is as follows:

[0218] The fifth bytecode in the bytecode file to be processed is read, the fifth bytecode is a bytecode used to represent a target access method, and the target access method is any access method in the target application program;

[0219] The to-be-optimized information is determined according to the target access method and the inheritance relationship of each class in the data structure, and the to-be-optimized information includes an access member corresponding to the target access method and a calling method of the access member.

[0220] As an optional implementation, the processor 601 performs optimization processing on the bytecode corresponding to the collected optimization tasks to obtain the optimized bytecode file, and the specific implementation is as follows:

[0221] The visibility of the access member and the calling method of the access member are modified.

[0222] The bytecode corresponding to the calling method of the access member is updated in the bytecode file to be processed, and the fifth bytecode is deleted to obtain the optimized bytecode file.

[0223] As an optional implementation, the processor 601 further performs the following operations by running the executable program code in the storage 603:

[0224] If the optimized bytecode file meets the coding specification, the optimized bytecode file is subjected to second coding conversion processing to obtain an updated class file.

[0225] The updated class file is subjected to coding processing to obtain an updated archive file.

[0226] Based on the same inventive concept, the application processing device provided in the embodiments of the present application has similar principles and beneficial effects to those of the application processing method provided in the method embodiments of the present application for solving problems, and the principles and beneficial effects of the method embodiments can be referred to. For brevity, the description is not repeated here.

[0227] The embodiments of the present application further provide a computer-readable storage medium, which stores a computer program adapted to be loaded and executed by a processor to perform the application processing method of the above-mentioned method embodiments.

[0228] The embodiment of the present application further provides a computer program product or computer program, which comprises computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method of the processing of the application.

[0229] It should be noted that, for each of the above method embodiments, in order to simply describe, each is expressed as a series of action combinations, but those skilled in the art should know that the present application is not limited by the action sequence described, because according to the present application, some steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification all belong to preferred embodiments, and the actions and modules involved are not necessarily necessary for the present application.

[0230] The steps in the method of the embodiment of the present application can be adjusted in sequence, combined and deleted according to actual needs.

[0231] The modules in the device of the embodiment of the present application can be combined, divided and deleted according to actual needs.

[0232] Those of ordinary skill in the art can understand that all or part of the steps of the various methods of the above embodiments can be completed by a program instructing related hardware, and the program can be stored in a computer readable storage medium, which can include a flash disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0233] The above only discloses a preferred embodiment of the present application, and of course cannot limit the scope of the rights of the present application. Those of ordinary skill in the art can understand that the implementation of all or part of the above embodiments is within the scope of the present application.

Claims

1. A processing method of an application program, characterized by, The method comprises the following steps: A construction process of a plug-in accessing to an installation package of the application program, the method comprising: Obtaining a bytecode file to be processed from an archive file of a target application program; Traversing the bytecode file to be processed to collect bytecode corresponding to N optimization tasks, N being a positive integer; wherein one optimization task is used for optimizing one type of bytecode; the optimization tasks comprise a system annotation optimization task, a source file format optimization task, a debugging information optimization task, a global variable optimization task and an access method optimization task; the value of N is determined according to the balance between compression effect and resource consumption of the bytecode file, or according to the number of types of bytecode in the bytecode file of the target application program; 2. The method of claim 1, wherein, Parallelly performing optimization processing on the collected bytecode corresponding to the optimization tasks to obtain an optimized bytecode file, comprising: performing the system annotation optimization task to filter and delete bytecode for indicating system annotations in the bytecode file to be processed according to a protection condition; performing the source file format optimization task to compress bytecode for indicating source file format through an encoding tree; performing the debugging information optimization task to dynamically delete bytecode for indicating debugging information in the bytecode file to be processed according to optimization configuration information; performing the global variable optimization task to delete bytecode corresponding to invalid initialization values in the bytecode file to be processed; and performing the access method optimization task to modify and delete an access member corresponding to the access method and a calling method of the access member according to the inheritance relationship of each class in the access method and the data structure. The method further comprises: Traversing the bytecode file to be processed and constructing a data structure of the target application program, the data structure containing the inheritance relationship of each class in the target application program. The optimization tasks comprise a system annotation optimization task; The traversing of the bytecode file to be processed to collect bytecode corresponding to N optimization tasks comprises:

3. The method of claim 2, wherein, Traversing the bytecode file to be processed to obtain a first bytecode set, the first bytecode set containing at least one first bytecode, the first bytecode being bytecode for indicating system annotations; Adding first bytecodes in the first bytecode set satisfying a protection condition to a whitelist; The collected bytecode corresponding to the system annotation optimization task is first bytecode located in the first bytecode set and not belonging to the whitelist. Suppose The target bytecode is any one of the first bytecodes in the first bytecode set; the method of judging whether the target bytecode satisfies the protection condition comprises:

4. The method of claim 3, wherein, Judging whether the class to which the target bytecode belongs calls a system annotation method; ​ ​ If the class to which the target bytecode belongs calls a system annotation method, it is determined whether the class to which the target bytecode belongs is an interface implementation class, or whether the class to which the target bytecode belongs has a parent class according to the inheritance relationship in the data structure; If the class to which the target bytecode belongs is an interface implementation class, or the class to which the target bytecode belongs has a parent class, it is determined that the target bytecode satisfies a protection condition.

5. The method of claim 3, wherein, The optimization processing on the collected bytecode corresponding to the optimization task comprises: The first bytecode in the to-be-processed bytecode file that belongs to the first bytecode set and does not belong to the white list is deleted to obtain an optimized bytecode file.

6. The method of claim 1, wherein, The optimization task includes a source file format optimization task; the collected bytecode corresponding to the source file format optimization task is second bytecode in the to-be-processed bytecode file, and the second bytecode is bytecode for indicating a source file format; The optimization processing on the collected bytecode corresponding to the optimization task comprises: An encoding tree of the second bytecode is constructed according to a frequency of occurrence of the second bytecode in the to-be-processed bytecode file; The second bytecode is encoded according to an encoding rule of the encoding tree to obtain simplified bytecode and a mapping file; The second bytecode in the to-be-processed bytecode file is replaced by the simplified bytecode to obtain an optimized bytecode file; The mapping file can be used to restore the simplified bytecode to the second bytecode.

7. The method of claim 1, wherein, The optimization task includes a debugging information optimization task; The traversal of the to-be-processed bytecode file to collect bytecode corresponding to N optimization tasks comprises: Obtaining optimization configuration information, the optimization configuration information including an identifier of to-be-optimized debugging information; Determining third bytecode in the to-be-processed bytecode file according to the identifier of the to-be-optimized debugging information, the third bytecode being bytecode for indicating to-be-optimized debugging information; The optimization processing on the collected bytecode corresponding to the optimization task comprises: The third bytecode is deleted to obtain an optimized bytecode file.

8. The method of claim 1, wherein, The optimization task includes a global variable optimization task; The traversal of the to-be-processed bytecode file to collect bytecode corresponding to N optimization tasks comprises: Filtering fourth bytecode from the to-be-processed bytecode file, the fourth bytecode being bytecode for indicating an initial value of a global variable with a preset initial value.

9. The method of claim 8, wherein, The optimization processing on the collected bytecode corresponding to the optimization task comprises: The fourth bytecode is deleted to obtain an optimized bytecode file.

10. The method of claim 2, wherein, The optimization task includes an access method optimization task; the traversal of the to-be-processed bytecode file to collect bytecode corresponding to N optimization tasks comprises: read a fifth bytecode in the bytecode file to be processed, the fifth bytecode being a bytecode for representing a target access method, the target access method being any access method in the target application program; determine to-be-optimized information according to the target access method and inheritance relationships of classes in the data structure, the to-be-optimized information including an access member corresponding to the target access method and a calling method of the access member.

11. The method of claim 10, wherein, The optimization processing on the collected bytecode corresponding to the optimization task includes: modifying the visibility of the access member and the calling method of the access member; updating the bytecode corresponding to the calling method of the access member in the bytecode file to be processed according to the modification, and deleting the fifth bytecode, to obtain an optimized bytecode file.

12. The method of any one of claims 2-11, wherein, The method further includes: if the optimized bytecode file meets a coding specification, performing second coding conversion processing on the optimized bytecode file to obtain an updated class file; performing coding processing on the updated class file to obtain an updated archive file.

13. A processing device of an application program, characterized by, The plug-in accesses a construction process of the installation package of the application program, including: an acquisition unit, configured to acquire a bytecode file to be processed from an archive file of a target application program; a processing unit, configured to traverse the bytecode file to be processed to collect bytecode corresponding to N optimization tasks respectively, N being a positive integer; one optimization task is used to optimize one type of bytecode; the optimization tasks include a system annotation optimization task, a source file format optimization task, a debugging information optimization task, a global variable optimization task, and an access method optimization task; the value of N is determined according to a balance between compression effect and resource consumption degree of the bytecode file, or according to a type number of bytecode in the bytecode file of the target application program; the processing unit is configured to perform optimization processing on the collected bytecode corresponding to the optimization tasks in parallel to obtain an optimized bytecode file; the optimization processing includes: through execution of the system annotation optimization task, filtering and deleting bytecode for representing system annotations in the bytecode file to be processed according to a protection condition; through execution of the source file format optimization task, compressing bytecode for representing source file formats through an encoding tree; through execution of the debugging information optimization task, dynamically deleting bytecode for representing debugging information in the bytecode file to be processed according to optimization configuration information; through execution of the global variable optimization task, deleting bytecode corresponding to invalid initialization values in the bytecode file to be processed; and through execution of the access method optimization task, modifying and deleting the access method according to an access member corresponding to the access method and a calling method of the access member, and the inheritance relationships of classes in a data structure.

14. A processing device of an application program, characterized by, include: a processor adapted to execute a computer program; a computer readable storage medium having a computer program stored therein, the computer program being executed by the processor to implement the processing method of the application program according to any one of claims 1-12.

15. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program which is adapted to be loaded and executed by the processor to perform the processing method of the application according to any one of claims 1-12.

Citation Information

Patent Citations

  • Data acquisition method and device, electronic equipment and computer readable storage medium

    CN110134400A

  • Compiling method and device, electronic equipment and storage medium

    CN110609687A

  • Method and device for generating installation package and electronic equipment

    CN111176717A