Hot Fix Method, Device, Equipment and Storage Medium
By identifying and deleting the redundant parameters of anonymous internal classes in the patch package, and generating patch packages without redundant parameters, it solves the problem of abnormal operation during the hot repair process and improves the success rate of hot repair.
Patent Information
- Application Number
- CN202210271169.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-18
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2042-03-18
AI Technical Summary
During the application hot repair process, adding new parameters to the constructor of the anonymous internal class in the patch package causes an exception to run, resulting in a hot repair failure.
By obtaining the modified bytecode file of the anonymous internal class, identifying and deleting redundant parameters, a patch package with no redundant parameters is generated, and using this patch package for hot repair.
Improves the success rate of application hot fixes and ensures that the patch package is running normally on the user side.
Smart Images

Figure CN114625403B_ABST
Abstract
Description
Technical Field
[0001] This document relates to the field of application development, and in particular to an application hotfix method, device, equipment, and storage medium. Background Art
[0002] The hotfix of an application is also called patch. Without releasing a new version, the application publisher can fix some problems existing in the released version by releasing a patch package, thereby achieving a lower resource consumption and less time-consuming repair effect.
[0003] During the process of developers writing a patch package, if the anonymous inner class in the source code of the application is modified, for example, a new parameter is added to the constructor of the anonymous inner class, when the patch package runs on the user side, based on its running principle - reflecting and calling the constructor of the anonymous inner class in the original APK file, since the constructor of the anonymous inner class in the original APK file does not have this new parameter, it will inevitably cause the patch package to run abnormally. Therefore, in the existing technology, when hotfixing an application, the patch package may run abnormally, resulting in the failure of the hotfix. Summary of the Invention
[0004] The embodiments of this specification provide an application hotfix method, device, equipment, and storage medium, which are used to solve the problem that adding a new parameter to the constructor of an anonymous inner class in the patch package causes the patch package to run abnormally on the application side, and improve the success rate of the application hotfix.
[0005] In a first aspect, the embodiments of this specification provide an application hotfix method, including: after the anonymous inner class segment in the application source code is modified, obtaining the bytecode file of the outer class where the modified anonymous inner class is located; wherein, the constructor of the modified anonymous inner class has redundant parameters to be deleted; obtaining the parameter loading instruction of the constructor and the local variable table of the enclosing method of the modified anonymous inner class from the bytecode file; according to the parameter value of the parameter loading instruction, looking up the parameter names of each parameter of the constructor in the local variable table; wherein, the parameter value is used to represent the position of the parameter name of the constructor in the local variable table; positioning and deleting the redundant parameter in the parameter array of the constructor according to the parameter name of the redundant parameter and the parameter names of each parameter of the constructor; generating a patch package of the application based on the constructor after deletion, and using the patch package to perform hotfix on the application.
[0006] Second aspect, an embodiment of this specification provides an application hotfix device, the device comprising: a bytecode acquisition unit, configured to acquire a bytecode file of an outer class where a modified anonymous inner class is located after modification of an anonymous inner class fragment in an application program source code; wherein, the constructor of the modified anonymous inner class has redundant parameters to be deleted; a variable table acquisition unit, configured to acquire parameter loading instructions of the constructor and a local variable table of an enclosing method of the modified anonymous inner class from the bytecode file; a parameter name lookup unit, configured to look up parameter names of respective parameters of the constructor in the local variable table according to parameter values of the parameter loading instructions; wherein, the parameter values are used to represent positions of the parameter names of the constructor in the local variable table; a parameter deletion unit, configured to locate and delete the redundant parameters in a parameter array of the constructor according to the parameter names of the redundant parameters and the parameter names of the respective parameters of the constructor; an application repair unit, configured to generate a patch package of the application program based on the constructor after deletion, and perform hotfix on the application program by using the patch package.
[0007] Third aspect, an embodiment of this specification provides an application hotfix device, comprising: a processor; and a memory configured to store computer-executable instructions, the computer-executable instructions, when executed, causing the processor to implement steps of the application hotfix method described in the first aspect above.
[0008] Fourth aspect, an embodiment of this specification provides a computer-readable storage medium, the computer-readable storage medium being used to store computer-executable instructions, the computer-executable instructions, when executed by a processor, implementing steps of the application hotfix method described in the first aspect above.
[0009] In this embodiment, during the process of generating a patch package of an application program, if the constructor of a modified anonymous inner class has redundant parameters to be deleted, then a bytecode file of an outer class where the modified anonymous inner class is located can be acquired, parameter loading instructions of the constructor and a local variable table of an enclosing method of the modified anonymous inner class can be acquired from the bytecode file, parameter names of respective parameters of the constructor can be looked up in the local variable table according to parameter values of the parameter loading instructions, then the redundant parameters can be located and deleted in a parameter array of the constructor according to the parameter names of the redundant parameters and the parameter names of the respective parameters of the constructor, and a patch package of the application program can be generated based on the constructor after deletion, so as to perform hotfix on the application program by using the patch package without redundant parameters, solve the problem that new parameters are added to the constructor of the anonymous inner class in the patch package, resulting in abnormal operation of the patch package at the application end, and improve the success rate of application program hotfix. Description of the Drawings
[0010] To more clearly illustrate the technical solutions in one or more embodiments of this specification or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments recorded in this specification. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings;
[0011] Figure 1 It is a schematic flowchart of an application hot fix method provided by an embodiment of this specification;
[0012] Figure 2 It is a schematic structural diagram of an application hot fix device provided by an embodiment of this specification;
[0013] Figure 3 It is a schematic structural diagram of an application hot fix device provided by an embodiment of this specification. Detailed implementation manners
[0014] In order to enable those skilled in the art to better understand the technical solutions in one or more embodiments of this specification, the following will clearly and completely describe the technical solutions in one or more embodiments of this specification in conjunction with the drawings in one or more embodiments of this specification. Obviously, the described embodiments are only some embodiments of this specification, rather than all embodiments. Based on one or more embodiments of this specification, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of this document.
[0015] The idea of this embodiment is that during the process of generating a patch package for an application program, if an anonymous inner class fragment in the application program source code is modified, and the constructor of the modified anonymous inner class has redundant parameters to be deleted, then locate and delete the redundant parameter in the parameter array of the constructor, and generate a patch package for the application program based on the constructor after deletion, so as to perform hot fix on the application program using the patch package without redundant parameters, solve the problem that new parameters are added to the constructor of the anonymous inner class in the patch package, resulting in abnormal operation of the patch package at the application end, and improve the success rate of application program hot fix.
[0016] Glossary involved in this embodiment:
[0017] class file: The compilation product of the Java language, the bytecode generated by the Java compiler by compiling the.java file, which can be loaded and executed by the JVM virtual machine.
[0018] Anonymous inner class: An inner class in the Java language that has no name and is used to simplify writing. It only exists inside the method body and is generally created directly in the code using the 'new' keyword. It also needs to override the methods of an interface or a superclass.
[0019] Constructor: A special function in Java that is executed when an object of a class is created and is generally used to perform object initialization operations.
[0020] Local variable table: A storage space for a set of variable values in the method stack frame in the Java runtime memory, used to store method parameters and local variables defined within the method.
[0021] ASM: A Java bytecode manipulation framework that can be used to directly generate class files or to access and dynamically modify the content of class files.
[0022] APK: Android application package, the package for Android applications.
[0023] Figure 1 The following is a schematic flowchart of the application hotfix method provided in an embodiment of this specification. This method can be executed by a background server, as Figure 1 shown. This method includes the following steps:
[0024] Step S102: After modifying the anonymous inner class fragment in the application source code, obtain the bytecode file of the outer class where the modified anonymous inner class is located. Among them, the constructor of the modified anonymous inner class has redundant parameters to be deleted.
[0025] Step S104: Obtain the parameter loading instructions of the constructor and the local variable table of the enclosing method of the modified anonymous inner class from the bytecode file.
[0026] Step S106: According to the parameter values of the parameter loading instructions, search for the parameter names of each parameter of the constructor in the local variable table. Among them, the parameter values are used to represent the positions of the parameter names of the constructor in the local variable table.
[0027] Step S108: Based on the parameter names of the redundant parameters and the parameter names of each parameter of the constructor, locate and delete the redundant parameters in the parameter array of the constructor.
[0028] Step S110: Generate a patch package for the application based on the deleted constructor, and use the patch package to perform hotfix on the application.
[0029] In this embodiment, during the process of generating a patch package for an application, if the constructor of the modified anonymous inner class has redundant parameters to be deleted, the bytecode file of the outer class where the modified anonymous inner class is located can be obtained. The parameter loading instructions of the constructor and the local variable table of the enclosing method of the modified anonymous inner class are obtained from this bytecode file. According to the parameter values of the parameter loading instructions, the parameter names of each parameter of the constructor are found in the local variable table. Then, based on the parameter names of the redundant parameters and the parameter names of each parameter of the constructor, the redundant parameters are located and deleted in the parameter array of the constructor, and a patch package for the application is generated based on the constructor after deletion. Thus, the application is hot-fixed using the patch package without redundant parameters, solving the problem that adding new parameters to the constructor of the anonymous inner class in the patch package causes the patch package to run abnormally at the application side and improving the success rate of the application hot-fix.
[0030] When developers repair an application, they can modify the anonymous inner class fragment in the application source code. If new external variables are accessed in the modified code, then in the bytecode file corresponding to the modified source code, the constructor of the modified anonymous inner class will have new parameters. When generating a patch package based on the bytecode file corresponding to the modified source code and the patch package runs on the user side, based on its operating principle - reflecting and calling the constructor of the anonymous inner class in the original APK file, since the constructor of the anonymous inner class in the original APK file does not have this new parameter, it will cause the patch package to run abnormally. In this case, this new parameter is the redundant parameter to be deleted in the constructor of the modified anonymous inner class. By deleting the redundant parameter in the parameter array of the constructor of the modified anonymous inner class, the patch package can run normally.
[0031] In one embodiment, after the anonymous inner class fragment in the application source code is modified, the attributes of the bytecode file of the modified anonymous inner class are compared with the attributes of the bytecode file of the anonymous inner class before modification to determine the redundant attributes of the bytecode file of the modified anonymous inner class, and the parameters corresponding to these redundant attributes are determined as the redundant parameters of the constructor of the modified anonymous inner class.
[0032] For example, the attributes of the bytecode file of the modified anonymous inner class include a, b, c, and the attributes of the bytecode file of the anonymous inner class before modification include a, b. Then, by comparison, the redundant attribute c is obtained, and the parameter corresponding to the redundant attribute c is the redundant parameter of the constructor of the modified anonymous inner class. Usually, the name of the redundant attribute is the same as the name of its corresponding parameter. If the redundant attribute is c, then the redundant parameter is also c.
[0033] To delete redundant parameters in the parameter array of the constructor of the modified anonymous inner class, in step S102 above, after modifying the anonymous inner class fragment in the application source code, when the constructor of the modified anonymous inner class has redundant parameters to be deleted, obtain the bytecode file of the outer class where the modified anonymous inner class is located.
[0034] In step S104 above, obtain the parameter loading instructions of the constructor and the local variable table of the enclosing method of the modified anonymous inner class from the obtained bytecode file. In one embodiment, this step specifically includes:
[0035] (1) Obtain the bytecode fragment of the enclosing method of the modified anonymous inner class from the obtained bytecode file;
[0036] (2) In the bytecode fragment of the enclosing method, obtain the parameter loading instructions of the constructor and the local variable table of the enclosing method of the modified anonymous inner class.
[0037] Specifically, obtain the bytecode fragment of the enclosing method of the modified anonymous inner class from the bytecode file of the outer class where the modified anonymous inner class is located. The source code of the application can be compiled to obtain multiple bytecode files, also known as class files. The bytecode file of the outer class where the modified anonymous inner class is located refers to the bytecode file containing the compilation result of the outer class where the modified anonymous inner class is located. The enclosing method of the modified anonymous inner class is also the outer method that creates the modified anonymous inner class.
[0038] In one embodiment, to obtain the bytecode fragment of the enclosing method of the modified anonymous inner class from the bytecode file of the outer class where the modified anonymous inner class is located, specifically:
[0039] (11) Obtain the class information of the modified anonymous inner class, and based on the class information of the modified anonymous inner class, obtain the class information of the outer class where the modified anonymous inner class is located and the method information of the enclosing method of the modified anonymous inner class;
[0040] (12) Based on the class information of the outer class and the method information of the enclosing method, search for the bytecode fragment of the enclosing method in the bytecode file of the outer class where the modified anonymous inner class is located.
[0041] First, obtain the class information of the modified anonymous inner class. Then, using the class information of the modified anonymous inner class as an input parameter, through the getEnclosingMethod method provided by Javassist, obtain the method information of the enclosing method of the modified anonymous inner class. Also, using the method information of the enclosing method of the modified anonymous inner class as an input parameter, through the getDeclaringClass method provided by Javassist, obtain the class information of the outer class where the modified anonymous inner class is located. Among them, the class information includes but is not limited to information such as class attributes, methods, constant pools, and qualifiers. The method information includes but is not limited to information such as method qualifiers, names, parameter types, return value types, and method signatures.
[0042] Then, using the class information of the above-mentioned outer class and the method information of the enclosing method as input parameters, through the ClassReader method provided by ASM, access the bytecode file of the outer class where the modified anonymous inner class is located, and in this bytecode file, search for the bytecode fragment of the enclosing method. Here, the method information of the enclosing method includes the method name and method description information of the enclosing method. By using the method name and method description information of the enclosing method, with the help of the visitMethod method of ClassVisitor, in the bytecode file of the outer class where the modified anonymous inner class is located, search for the bytecode fragment of the method whose name and description information are both the same as those of the enclosing method as the bytecode fragment of the above-mentioned enclosing method.
[0043] When the name and description information of a certain method are both the same as those of the enclosing method, determine that this method is the above-mentioned enclosing method. In the bytecode file of the outer class where the modified anonymous inner class is located, find out the bytecode fragment of this method as the bytecode fragment of the above-mentioned enclosing method, which can avoid the missearch caused by only judging the method name. For example, in the case of method overloading, the method names are the same but the parameters or types are different. If only the method name is judged, it will cause an incorrect search result.
[0044] In one embodiment, in the bytecode fragment of the enclosing method, obtain the parameter loading instructions of the constructor and the local variable table of the enclosing method of the modified anonymous inner class, specifically including:
[0045] (21) In the bytecode fragment of the enclosing method, locate the creation process of the modified anonymous inner class;
[0046] (22) During the creation process, identify the parameter loading instructions of the constructor of the modified anonymous inner class.
[0047] First, in the bytecode fragment of the enclosing method, locate the creation process of the modified anonymous inner class. Specifically, this action is as follows:
[0048] (211) If an anonymous inner class creation instruction for creating the above-mentioned modified anonymous inner class is recognized in the bytecode fragment of the enclosing method, it is determined that the creation of the modified anonymous inner class begins;
[0049] (212) If a constructor call instruction for the above-mentioned modified anonymous inner class is recognized in the bytecode fragment of the enclosing method, it is determined that the creation of the modified anonymous inner class ends;
[0050] (213) The part between the anonymous inner class creation instruction and the constructor call instruction in the bytecode fragment of the enclosing method is determined as the creation process of the modified anonymous inner class.
[0051] In action (211), the instructions in the bytecode fragment of the enclosing method are recognized. If the anonymous inner class creation instruction NEW instruction is recognized, and the creation target type of this anonymous inner class creation instruction is the above-mentioned modified anonymous inner class, that is, type is equal to the class name of the above-mentioned modified anonymous inner class, it is determined that the anonymous inner class creation instruction for creating the above-mentioned modified anonymous inner class is recognized, and it is determined that the anonymous inner class creation begins. This action can be implemented through the visitTypeInsn method in ASM.
[0052] In action (212), the instructions in the bytecode fragment of the enclosing method are recognized. If the constructor call instruction INVOKESPECIAL instruction is recognized, and the owner of this constructor call instruction is the above-mentioned modified anonymous inner class, that is, the owner name owner is equal to the class name of the above-mentioned modified anonymous inner class, and the name of this constructor is a preset name such as " <init>", it is determined that a constructor call instruction for the modified anonymous inner class is recognized, and it is determined that the creation of the modified anonymous inner class is completed. This action can be implemented through the visitMethodInsn method in ASM.
[0053] In action (213), in the bytecode fragment of the enclosing method, the part between the recognized anonymous inner class creation instruction and the recognized constructor call instruction is determined as the creation process of the modified anonymous inner class.
[0054] In this embodiment, by determining the start and end of the creation of the modified anonymous inner class and locating the creation process of the modified anonymous inner class, the time range of the construction of the modified anonymous inner class is limited, and the efficiency of recognizing the parameter loading instructions of the constructor of the modified anonymous inner class is improved.
[0055] In the above action (22), during the creation process, the parameter loading instructions of the constructor of the modified anonymous inner class are recognized. This action is specifically:
[0056] (221) Traverse the instructions in the creation process. If the traversed instruction is at a preset position interval in a specific instruction list, it is determined that the instruction is the parameter loading instruction of the constructor of the modified anonymous inner class; wherein, the specific instruction list is an instruction list for loading local variables of the enclosing method, and the specific instruction list is located in the JAVA virtual machine.
[0057] In one embodiment, if the instruction traversed during the creation process is between ILOAD (inclusive) and ALOAD (inclusive) in the specific instruction list, it is determined that the instruction is the parameter loading instruction of the constructor of the modified anonymous inner class, and the parameter value of the instruction is obtained. This action can be implemented through the visitVarInsn method in ASM.
[0058] In a specific embodiment, for the instructions in the bytecode fragment of the closing method, they are identified one by one in the order from front to back. After identifying the anonymous inner class creation instruction for creating the modified anonymous inner class, a tag is generated, and the tag status is set to indicate that it is in the creation of the modified anonymous inner class. An empty array is generated to store the parameter values of the parameter loading instructions of the constructor of the anonymous inner class obtained subsequently. Then, the subsequent instructions of the anonymous inner class creation instruction are traversed. If the traversed instruction is between ILOAD (inclusive) and ALOAD (inclusive) in a specific instruction list, it is determined that the instruction is the parameter loading instruction of the constructor of the modified anonymous inner class, and the parameter value of the instruction is obtained and stored in the generated empty array. The instructions are traversed one by one. After identifying the constructor call instruction for the modified anonymous inner class, the above tag status is modified to indicate the end of the anonymous inner class creation, and the identification of the parameter loading instructions ends.
[0059] In the above action (2), the local variable table of the closing method is also obtained. In this embodiment, the parameter value of the parameter loading instruction is also obtained, and the parameter value represents the position of the parameter name of the constructor in the local variable table. Referring to the above introduction, the parameter values of the parameter loading instructions can be recorded in the empty array in the order of their recording in the bytecode fragment, and the parameter value represents the position of the parameter name of the constructor in the local variable table.
[0060] The following uses a specific example to illustrate the specific process of obtaining the parameter loading instructions of the constructor and the local variable table of the closing method of the modified anonymous inner class in the bytecode fragment of the closing method. The bytecode fragment of the closing method of the anonymous inner class involved in this example is as follows:
[0061]
[0062]
[0063] In this example, each instruction in the bytecode fragment is traversed one by one. The NEW instruction is identified through the visitTypeInsn method. If the type of the NEW instruction is equal to the class name of the modified anonymous inner class, it is determined that the anonymous inner class creation instruction for creating the modified anonymous inner class is identified, the anonymous inner class creation starts, a tag is generated, and the tag status is set to indicate that it is in the anonymous inner class creation. An empty array is generated to store the parameter values of the parameter loading instructions of the modified anonymous inner class obtained subsequently.
[0064] Then traverse the subsequent instructions of the NEW instruction. If it is determined by the visitVarInsn method that the instruction traversed is between ILOAD (inclusive) and ALOAD (inclusive) in a specific instruction list, then it is determined that the instruction is the parameter loading instruction of the constructor of the above-mentioned modified anonymous inner class, and the parameter value of the instruction is obtained and stored in the above-generated empty array. In the order of instruction traversal, the parameter values 0, 2, and 1 are stored in the empty array in sequence.
[0065] Then traverse the instructions backward. By the visitMethodInsn method, an INVOKESPECIAL instruction, which is a constructor call instruction, is recognized. Moreover, the owner name owner of the constructor call instruction is equal to the class name of the above-mentioned modified anonymous inner class, and the name name of the constructor is a preset name such as " <init>", it is determined that a constructor call instruction for the modified anonymous inner class is recognized, it is determined that the creation of the modified anonymous inner class is completed, the above-mentioned flag state is modified to indicate the completion of the creation of the anonymous inner class, and the recognition of the parameter loading instruction is ended.
[0066] Moreover, in this example, the local variable table of the enclosing method is also obtained in the bytecode fragment, specifically:
[0067]
[0068] Among them, slot represents the position, and name represents the parameter name stored at the corresponding position. In this example, the obtained parameter values are 0, 2, and 1 in sequence.
[0069] In the above step S106, according to the parameter values of the parameter loading instruction, the parameter names of each parameter of the constructor are searched in the local variable table. The parameter value is used to represent the position of the parameter name of the constructor in the local variable table. In one embodiment, this step is specifically: locate the position represented by the parameter value in the local variable table, and take the parameter name recorded at the located position as the parameter names of each parameter of the constructor. This step can be implemented by the visitLocalVariable method in ASM.
[0070] As in the previous example, the positions 0, 2, and 1 are located in sequence, and the obtained parameter names are: this, version, tag. Therefore, it can be determined that there are three parameters in the constructor of the modified anonymous inner class in this example. According to the order of appearance of the parameters in the bytecode fragment, the parameter names are this, version, and tag respectively. In this embodiment, an ordinal number starting from 0 can also be generated for each parameter name in sequence. This ordinal number represents the order of appearance of the parameter corresponding to the parameter name in the bytecode fragment. After finding the first parameter name this, the corresponding ordinal number 0 is generated for it. After finding the second parameter name version, the corresponding ordinal number 1 is generated for it. After finding the third parameter name tag, the corresponding ordinal number 2 is generated for it.
[0071] In the above step S108, according to the parameter name of the redundant parameter and the parameter names of each parameter of the constructor found, the redundant parameter is located and deleted in the parameter array of the constructor. In one embodiment, this step is specifically:
[0072] (1) Search for the parameter name of the redundant parameter among the parameter names of each parameter of the constructor in the local variable table;
[0073] (2) After a successful search, determine the position of the parameter name of the redundant parameter in the local variable table. According to this position, in each parameter loading instruction of the constructor, determine the target parameter loading instruction corresponding to the redundant parameter;
[0074] (3) According to the execution order of the target parameter loading instruction in the bytecode fragment of the enclosing method, determine the position of the redundant parameter in the parameter array of the constructor, and locate and delete the redundant parameter in the parameter array of the constructor.
[0075] First, the parameter names of each parameter of the constructor are recorded in the local variable table. Therefore, in the parameter names of each parameter of the constructor in the local variable table, search for the parameter name of the redundant parameter. After finding it, determine the position of the parameter name of the redundant parameter in the local variable table. For example, combining the previous example, the redundant parameter is version, and the position is "2". Since the parameter value of the parameter loading instruction of the constructor is used to represent this position, according to this position, in each parameter loading instruction of the constructor, determine the target parameter loading instruction corresponding to the redundant parameter. For example, determine the parameter loading instruction with a parameter value of "2" or representing the position "2" as the target parameter loading instruction corresponding to the redundant parameter. The target parameter loading instruction is used to load the redundant parameter. Combining the previous example, the redundant parameter is version, and the target parameter loading instruction is "iload_2".
[0076] According to the previous introduction, in the bytecode fragment of the enclosing method, each parameter loading instruction has a recorded order, and this recorded order is the execution order of each parameter loading instruction. Therefore, after determining the target parameter loading instruction, in the bytecode fragment of the enclosing method, determine the execution order of the target parameter loading instruction among each parameter loading instruction. For example, the execution order of "iload_2" is the second execution. Determine this execution order as the position of the redundant parameter in the parameter array of the constructor. Combining the previous example, the redundant parameter is version, and its execution order is the second execution, so its position in the parameter array of the constructor is also the second. Finally, according to the position of the redundant parameter in the parameter array of the constructor, locate the redundant parameter in the parameter array of the constructor and delete the redundant parameter.
[0077] According to this method, combining the previous example, if the redundant parameter is "tag", then its target parameter loading instruction is "aload_1", its execution order is the third execution, and its position in the parameter array of the constructor is also the third.
[0078] In this embodiment, after obtaining the parameter names of the various parameters of the constructor, the parameter name of the redundant parameter is located in reverse, and the target parameter loading instruction corresponding to the redundant parameter is located. The execution order of the target parameter loading instruction in the bytecode fragment of the enclosing method is determined as the position of the redundant parameter in the parameter array of the constructor. Accordingly, the redundant parameter is located and deleted in the parameter array of the constructor, achieving the effect of deleting the redundant parameter.
[0079] In the above step S110, a patch package of the application is also generated based on the constructor after deletion, that is, based on the modified application source code after deleting the redundant parameter, and the application is hot-fixed using the patch package.
[0080] The method in this embodiment can be applied in the scenario of application hot-fix. After modifying the application source code and before the patch package is released online, it can automatically delete the redundant parameters in the patch package, ensure the normal operation of the patch package after it is released online, and save the manual operation of patch package testing.
[0081] Figure 2 The following is a schematic structural diagram of an application hot-fix device provided in an embodiment of this specification. As Figure 2 shown, the device includes:
[0082] A bytecode acquisition unit 21, configured to obtain the bytecode file of the outer class where the modified anonymous inner class is located after the anonymous inner class fragment in the application source code is modified; wherein, the constructor of the modified anonymous inner class has redundant parameters to be deleted;
[0083] A variable table acquisition unit 22, configured to obtain the parameter loading instruction of the constructor and the local variable table of the enclosing method of the modified anonymous inner class from the bytecode file;
[0084] A parameter name search unit 23, configured to search for the parameter names of the various parameters of the constructor in the local variable table according to the parameter values of the parameter loading instruction; wherein, the parameter values are used to represent the positions of the parameter names of the constructor in the local variable table;
[0085] A parameter deletion unit 24, configured to locate and delete the redundant parameter in the parameter array of the constructor according to the parameter name of the redundant parameter and the parameter names of the various parameters of the constructor;
[0086] An application repair unit 25, configured to generate a patch package of the application based on the constructor after deletion, and perform hot-fix on the application using the patch package.
[0087] Optionally, it further includes a comparison unit, configured to:
[0088] After modifying the anonymous inner class fragment in the application source code, compare the attributes of the bytecode file of the modified anonymous inner class with those of the bytecode file of the anonymous inner class before modification to determine the redundant attributes of the bytecode file of the modified anonymous inner class;
[0089] Determine the redundant parameters of the constructor of the modified anonymous inner class as the parameters corresponding to the redundant attributes.
[0090] Optionally, the variable table acquisition unit 22 is specifically configured to:
[0091] Obtain the bytecode fragment of the enclosing method of the modified anonymous inner class from the bytecode file;
[0092] In the bytecode fragment of the enclosing method, obtain the parameter loading instruction of the constructor and the local variable table of the enclosing method of the modified anonymous inner class.
[0093] Optionally, the variable table acquisition unit 22 is further specifically configured to:
[0094] Obtain the class information of the modified anonymous inner class, and according to the class information of the modified anonymous inner class, obtain the class information of the outer class where the modified anonymous inner class is located and the method information of the enclosing method of the modified anonymous inner class;
[0095] According to the class information of the outer class and the method information of the enclosing method, search for the bytecode fragment of the enclosing method in the bytecode file.
[0096] Optionally, the variable table acquisition unit 22 is further specifically configured to:
[0097] Locate the creation process of the modified anonymous inner class in the bytecode fragment of the enclosing method;
[0098] In the creation process, identify the parameter loading instruction of the constructor of the modified anonymous inner class.
[0099] Optionally, the variable table acquisition unit 22 is further specifically configured to:
[0100] If an anonymous inner class creation instruction for creating the modified anonymous inner class is identified in the bytecode fragment of the enclosing method, determine the start of the creation of the modified anonymous inner class;
[0101] If a constructor call instruction for the modified anonymous inner class is identified in the bytecode fragment of the enclosing method, determine the end of the creation of the modified anonymous inner class;
[0102] Determine the part between the anonymous inner class creation instruction and the constructor call instruction in the bytecode fragment of the closed method as the creation process of the modified anonymous inner class.
[0103] Optionally, the variable table acquisition unit 22 is further specifically configured to:
[0104] Traverse the instructions in the creation process. If the traversed instruction is at a preset position interval in a specific instruction list, determine that the instruction is a parameter loading instruction for the constructor of the modified anonymous inner class;
[0105] Wherein, the specific instruction list is an instruction list for loading local variables of the closed method.
[0106] Optionally, the parameter name lookup unit 23 is specifically configured to:
[0107] Locate the position represented by the parameter value in the local variable table, and find out the parameter name recorded at the position as the parameter name of each parameter of the constructor.
[0108] Optionally, the parameter deletion unit 24 is specifically configured to:
[0109] In the parameter names of each parameter of the constructor in the local variable table, find the parameter name of the redundant parameter;
[0110] After successful lookup, determine the position of the parameter name of the redundant parameter in the local variable table, and according to the position, in the parameter loading instructions of each parameter of the constructor, determine the target parameter loading instruction corresponding to the redundant parameter;
[0111] According to the execution order of the target parameter loading instruction in the bytecode fragment of the closed method, determine the position of the redundant parameter in the parameter array of the constructor, and locate and delete the redundant parameter in the parameter array of the constructor.
[0112] The application hotfix device in this embodiment can implement each process of the foregoing application hotfix method embodiment and achieve the same effects and functions, which will not be repeated here.
[0113] An embodiment of this specification also provides an application hotfix device, Figure 3 For the structural schematic diagram of the application hotfix device provided by an embodiment of this specification, as Figure 3 As shown, the application hotfix device may vary significantly due to different configurations or performances, and may include one or more processors 1301 and a memory 1302. One or more application programs or data may be stored in the memory 1302. Among them, the memory 1302 may be transient storage or persistent storage. The application programs stored in the memory 1302 may include one or more modules (not shown in the figure), and each module may include a series of computer-executable instructions in the application hotfix device. Further, the processor 1301 may be configured to communicate with the memory 1302 and execute a series of computer-executable instructions in the memory 1302 on the application hotfix device. The application hotfix device may also include one or more power supplies 1303, one or more wired or wireless network interfaces 1304, one or more input or output interfaces 1305, one or more keyboards 1306, etc.
[0114] In a specific embodiment, the application hotfix device is specifically a background server, and the device includes a processor; and a memory configured to store computer-executable instructions, and the computer-executable instructions, when executed, cause the processor to implement the following processes:
[0115] After modifying the anonymous inner class fragment in the application program source code, obtain the bytecode file of the outer class where the modified anonymous inner class is located; wherein, the constructor of the modified anonymous inner class has redundant parameters to be deleted;
[0116] Obtain the parameter loading instruction of the constructor and the local variable table of the enclosing method of the modified anonymous inner class from the bytecode file;
[0117] According to the parameter values of the parameter loading instruction, look up the parameter names of each parameter of the constructor in the local variable table; wherein, the parameter values are used to represent the positions of the parameter names of the constructor in the local variable table;
[0118] According to the parameter name of the redundant parameter and the parameter names of each parameter of the constructor, locate and delete the redundant parameter in the parameter array of the constructor;
[0119] Based on the constructor after deletion, generate a patch package for the application program, and use the patch package to perform hotfix on the application program.
[0120] Optionally, when the computer-executable instructions are executed, the process further includes:
[0121] After modifying an anonymous inner class fragment in the application source code, compare the attributes of the bytecode file of the modified anonymous inner class with those of the bytecode file of the anonymous inner class before modification to determine the redundant attributes of the bytecode file of the modified anonymous inner class;
[0122] Determine the redundant parameters of the constructor of the modified anonymous inner class as the parameters corresponding to the redundant attributes.
[0123] Optionally, when the computer-executable instructions are executed, obtain the parameter loading instruction of the constructor and the local variable table of the enclosing method of the modified anonymous inner class from the bytecode file, including:
[0124] Obtain the bytecode fragment of the enclosing method of the modified anonymous inner class from the bytecode file;
[0125] In the bytecode fragment of the enclosing method, obtain the parameter loading instruction of the constructor and the local variable table of the enclosing method of the modified anonymous inner class.
[0126] Optionally, when the computer-executable instructions are executed, obtain the bytecode fragment of the enclosing method of the modified anonymous inner class from the bytecode file, including:
[0127] Obtain the class information of the modified anonymous inner class, and according to the class information of the modified anonymous inner class, obtain the class information of the outer class where the modified anonymous inner class is located and the method information of the enclosing method of the modified anonymous inner class;
[0128] According to the class information of the outer class and the method information of the enclosing method, search for the bytecode fragment of the enclosing method in the bytecode file.
[0129] Optionally, when the computer-executable instructions are executed, obtain the parameter loading instruction of the constructor in the bytecode fragment of the enclosing method, including:
[0130] Locate the creation process of the modified anonymous inner class in the bytecode fragment of the enclosing method;
[0131] In the creation process, identify the parameter loading instruction of the constructor of the modified anonymous inner class.
[0132] Optionally, when the computer-executable instructions are executed, locate the creation process of the modified anonymous inner class in the bytecode fragment of the enclosing method, including:
[0133] If an anonymous inner class creation instruction for creating the modified anonymous inner class is recognized in the bytecode fragment of the enclosing method, it is determined that the creation of the modified anonymous inner class begins;
[0134] If a constructor call instruction for the modified anonymous inner class is recognized in the bytecode fragment of the enclosing method, it is determined that the creation of the modified anonymous inner class ends;
[0135] The part between the anonymous inner class creation instruction and the constructor call instruction in the bytecode fragment of the enclosing method is determined as the creation process of the modified anonymous inner class.
[0136] Optionally, when the computer-executable instructions are executed, during the creation process, parameter loading instructions for the constructor of the modified anonymous inner class are recognized, including:
[0137] Traverse the instructions in the creation process. If the traversed instruction is at a preset position interval in a specific instruction list, it is determined that the instruction is a parameter loading instruction for the constructor of the modified anonymous inner class;
[0138] Wherein, the specific instruction list is an instruction list for loading local variables of the enclosing method.
[0139] Optionally, when the computer-executable instructions are executed, according to the parameter values of the parameter loading instructions, the parameter names of each parameter of the constructor are searched in the local variable table, including:
[0140] Locate the position represented by the parameter value in the local variable table, and use the parameter name recorded at that position as the parameter name of each parameter of the constructor to search out.
[0141] Optionally, when the computer-executable instructions are executed, according to the parameter names of the redundant parameters and the parameter names of each parameter of the constructor, the redundant parameters are located and deleted in the parameter array of the constructor, including:
[0142] Search for the parameter names of the redundant parameters among the parameter names of each parameter of the constructor in the local variable table;
[0143] After a successful search, determine the position of the parameter name of the redundant parameter in the local variable table. According to this position, in each parameter loading instruction of the constructor, determine the target parameter loading instruction corresponding to the redundant parameter;
[0144] According to the execution order of the target parameter loading instruction in the bytecode fragment of the closed method, determine the position of the redundant parameter in the parameter array of the constructor, and locate and delete the redundant parameter in the parameter array of the constructor.
[0145] The application hotfix device in this embodiment can implement each process of the foregoing application hotfix method embodiment and achieve the same effects and functions, which will not be repeated here.
[0146] An embodiment of this specification also provides a computer-readable storage medium for storing computer-executable instructions. When the computer-executable instructions are executed by a processor, the following process is implemented:
[0147] After the anonymous inner class fragment in the application program source code is modified, obtain the bytecode file of the outer class where the modified anonymous inner class is located; wherein, the constructor of the modified anonymous inner class has redundant parameters to be deleted.
[0148] Obtain the parameter loading instruction of the constructor and the local variable table of the closed method of the modified anonymous inner class from the bytecode file.
[0149] According to the parameter value of the parameter loading instruction, look up the parameter names of the parameters of the constructor in the local variable table; wherein, the parameter value is used to represent the position of the parameter name of the constructor in the local variable table.
[0150] According to the parameter name of the redundant parameter and the parameter names of the parameters of the constructor, locate and delete the redundant parameter in the parameter array of the constructor.
[0151] Based on the constructor after deletion, generate a patch package for the application program, and use the patch package to perform hotfix on the application program.
[0152] Optionally, when the computer-executable instructions are executed by a processor, the process further includes:
[0153] After the anonymous inner class fragment in the application program source code is modified, compare the attributes of the bytecode file of the modified anonymous inner class with the attributes of the bytecode file of the anonymous inner class before modification to determine the redundant attributes of the bytecode file of the modified anonymous inner class.
[0154] Determine the parameters corresponding to the redundant attributes as the redundant parameters of the constructor of the modified anonymous inner class.
[0155] Optionally, when the computer-executable instructions are executed by a processor, the parameter loading instructions of the constructor and the local variable table of the enclosing method of the modified anonymous inner class are obtained from the bytecode file, including:
[0156] Obtain the bytecode fragment of the enclosing method of the modified anonymous inner class from the bytecode file;
[0157] In the bytecode fragment of the enclosing method, obtain the parameter loading instructions of the constructor and the local variable table of the enclosing method of the modified anonymous inner class.
[0158] Optionally, when the computer-executable instructions are executed by a processor, the bytecode fragment of the enclosing method of the modified anonymous inner class is obtained from the bytecode file, including:
[0159] Obtain the class information of the modified anonymous inner class, and according to the class information of the modified anonymous inner class, obtain the class information of the outer class where the modified anonymous inner class is located and the method information of the enclosing method of the modified anonymous inner class;
[0160] According to the class information of the outer class and the method information of the enclosing method, search for the bytecode fragment of the enclosing method in the bytecode file.
[0161] Optionally, when the computer-executable instructions are executed by a processor, the parameter loading instructions of the constructor are obtained in the bytecode fragment of the enclosing method, including:
[0162] Locate the creation process of the modified anonymous inner class in the bytecode fragment of the enclosing method;
[0163] In the creation process, identify the parameter loading instructions of the constructor of the modified anonymous inner class.
[0164] Optionally, when the computer-executable instructions are executed by a processor, locating the creation process of the modified anonymous inner class in the bytecode fragment of the enclosing method includes:
[0165] If an anonymous inner class creation instruction for creating the modified anonymous inner class is identified in the bytecode fragment of the enclosing method, determine the start of the creation of the modified anonymous inner class;
[0166] If a constructor call instruction for the modified anonymous inner class is identified in the bytecode fragment of the enclosing method, determine the end of the creation of the modified anonymous inner class;
[0167] Determine the part between the anonymous inner class creation instruction and the constructor call instruction in the bytecode fragment of the closed method as the creation process of the modified anonymous inner class.
[0168] Optionally, when the computer-executable instructions are executed by a processor, during the creation process, identify the parameter loading instructions of the constructor of the modified anonymous inner class, including:
[0169] Traverse the instructions in the creation process. If the traversed instruction is at a preset position interval in a specific instruction list, determine that the instruction is the parameter loading instruction of the constructor of the modified anonymous inner class;
[0170] Wherein, the specific instruction list is an instruction list for loading local variables of the closed method.
[0171] Optionally, when the computer-executable instructions are executed by a processor, according to the parameter values of the parameter loading instructions, look up the parameter names of each parameter of the constructor in the local variable table, including:
[0172] Locate the position represented by the parameter value in the local variable table, and take the parameter name recorded at that position as the parameter names of each parameter of the constructor to look up.
[0173] Optionally, when the computer-executable instructions are executed by a processor, according to the parameter names of the redundant parameters and the parameter names of each parameter of the constructor, locate and delete the redundant parameters in the parameter array of the constructor, including:
[0174] In the parameter names of each parameter of the constructor in the local variable table, look up the parameter name of the redundant parameter;
[0175] After successful lookup, determine the position of the parameter name of the redundant parameter in the local variable table. According to this position, in the parameter loading instructions of each parameter of the constructor, determine the target parameter loading instruction corresponding to the redundant parameter;
[0176] According to the execution order of the target parameter loading instruction in the bytecode fragment of the closed method, determine the position of the redundant parameter in the parameter array of the constructor, and locate and delete the redundant parameter in the parameter array of the constructor.
[0177] The storage medium in this embodiment can implement each process of the foregoing application hotfix method embodiment, and achieve the same effects and functions, which will not be repeated here.
[0178] Among the above, the computer-readable storage medium includes a read-only memory (ROM for short), a random access memory (RAM for short), a magnetic disk, an optical disk, etc.
[0179] In the 1990s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to circuit structures such as diodes, transistors, switches, etc.) or software improvements (improvements to method flows). However, with the development of technology, many method flow improvements today can be regarded as direct improvements to hardware circuit structures. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement to a method flow cannot be implemented using a hardware entity module. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is an integrated circuit whose logical function is determined by the user programming the device. Designers can program a digital system "integrated" on a PLD by themselves, without having to ask a chip manufacturer to design and fabricate a dedicated integrated circuit chip. Moreover, nowadays, instead of manually fabricating integrated circuit chips, this programming is mostly implemented using "logic compiler" software, which is similar to the software compiler used in program development and writing. The original code before compilation also has to be written in a specific programming language, which is called a Hardware Description Language (HDL), and there is not just one type of HDL, but many types, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones currently are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also be aware that by simply making a little logical programming of the method flow using the above-mentioned several hardware description languages and programming it into an integrated circuit, it is easy to obtain the hardware circuit that implements the logical method flow.
[0180] The controller can be implemented in any suitable manner. For example, the controller can take the form of, for example, a microprocessor or a processor and a computer-readable medium storing computer-readable program code (such as software or firmware) executable by the (micro)processor, logic gates, switches, an application specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of the controller include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that, in addition to implementing the controller in the form of pure computer-readable program code, it is entirely possible to logically program the method steps to enable the controller to be implemented in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers, etc. to achieve the same function. Therefore, such a controller can be considered a hardware component, and the devices included therein for implementing various functions can also be regarded as the structures within the hardware component. Or even, the devices for implementing various functions can be regarded as either software modules for implementing the method or structures within the hardware component.
[0181] The systems, devices, modules, or units illustrated in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer can be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or any combination of these devices.
[0182] For the convenience of description, when describing the above devices, they are described separately as various units according to their functions. Of course, when implementing the embodiments of this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0183] Those skilled in the art should understand that one or more embodiments of this specification can be provided as a method, a system, or a computer program product. Therefore, one or more embodiments of this specification can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, one or more embodiments of this specification can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memories, CD-ROMs, optical memories, etc.) containing computer-usable program code.
[0184] This specification is described with reference to the flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the specification. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and combinations of flows and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to the processors of general-purpose computers, special-purpose computers, embedded processors, or other programmable data processing devices to produce a machine, such that the instructions executed by the processors of the computer or other programmable data processing devices generate means for implementing the functions specified in one flow Figure 1 one flow or multiple flows and / or blocks Figure 1 or multiple blocks.
[0185] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory produce a manufactured article including instruction means that implement the functions specified in one flow Figure 1 one flow or multiple flows and / or blocks Figure 1 or multiple blocks.
[0186] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one flow Figure 1 one flow or multiple flows and / or blocks Figure 1 or multiple blocks.
[0187] It should also be noted that the term "comprising", "including" or any other variation thereof is intended to cover non-exclusive inclusion, such that a process, method, commodity or device comprising a series of elements not only includes those elements but also other elements not expressly listed, or elements inherent to such process, method, commodity or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the existence of additional identical elements in the process, method, commodity or device comprising the element.
[0188] One or more embodiments of this specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. One or more embodiments of this specification may also be practiced in a distributed computing environment where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including storage devices.
[0189] Each embodiment in this specification is described in a progressive manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for system embodiments, since they are basically similar to method embodiments, the description is relatively simple. For related parts, reference can be made to the description of the method embodiments.
[0190] The above are only embodiments of this document and are not intended to limit this document. For those skilled in the art, this document may have various changes and modifications. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of this document shall be included within the scope of the claims of this document.< / init> < / init>
Claims
1. A hot fix method, characterized in that, Including: After modifying the anonymous inner class fragment in the application source code, obtaining the bytecode file of the outer class where the modified anonymous inner class is located; wherein, the constructor of the modified anonymous inner class has redundant parameters to be deleted; According to the class information of the modified anonymous inner class, obtaining the class information of the outer class where the modified anonymous inner class is located and the method information of the enclosing method of the modified anonymous inner class, and searching for the bytecode fragment of the enclosing method in the bytecode file according to the class information of the outer class and the method information of the enclosing method; In the bytecode fragment of the enclosing method, locating the creation process of the modified anonymous inner class, and in the creation process, identifying the parameter loading instructions of the constructor of the modified anonymous inner class, and obtaining the local variable table of the enclosing method of the modified anonymous inner class in the bytecode fragment of the enclosing method; According to the parameter values of the parameter loading instructions, searching for the parameter names of each parameter of the constructor in the local variable table; wherein, the parameter values are used to represent the positions of the parameter names of the constructor in the local variable table; Locating and deleting the redundant parameters in the parameter array of the constructor according to the parameter names of the redundant parameters and the parameter names of each parameter of the constructor; Generating a patch package for the application based on the deleted constructor, and using the patch package to perform hotfix on the application.
2. The method according to claim 1, wherein The method further includes: After modifying the anonymous inner class fragment in the application source code, comparing the attributes of the bytecode file of the modified anonymous inner class with the attributes of the bytecode file of the anonymous inner class before modification to determine the redundant attributes of the bytecode file of the modified anonymous inner class; Determining the parameters corresponding to the redundant attributes as the redundant parameters of the constructor of the modified anonymous inner class.
3. The method according to claim 1, characterized in that, In the bytecode fragment of the enclosing method, locating the creation process of the modified anonymous inner class, including: If an anonymous inner class creation instruction for creating the modified anonymous inner class is identified in the bytecode fragment of the enclosing method, determining the start of the creation of the modified anonymous inner class; If a constructor call instruction for the modified anonymous inner class is identified in the bytecode fragment of the enclosing method, determining the end of the creation of the modified anonymous inner class; Determining the part between the anonymous inner class creation instruction and the constructor call instruction in the bytecode fragment of the enclosing method as the creation process of the modified anonymous inner class.
4. The method according to claim 1, wherein In the creation process, identifying the parameter loading instructions of the constructor of the modified anonymous inner class, including: Traversing the instructions in the creation process, and if the traversed instruction is at a preset position interval in a specific instruction list, determining the instruction as the parameter loading instruction of the constructor of the modified anonymous inner class; Wherein, the specific instruction list is an instruction list for loading the local variables of the enclosing method.
5. The method according to claim 1, characterized in that, Load the parameter values of the parameter loading instructions, and look up the parameter names of each parameter of the constructor in the local variable table, including: Locate the position represented by the parameter value in the local variable table, and use the parameter name recorded at that position as the parameter name of each parameter of the constructor to look up.
6. The method according to claim 1, characterized in that Locate and delete the redundant parameter in the parameter array of the constructor according to the parameter name of the redundant parameter and the parameter names of each parameter of the constructor, including: Look up the parameter name of the redundant parameter among the parameter names of each parameter of the constructor in the local variable table; After successful lookup, determine the position of the parameter name of the redundant parameter in the local variable table, and according to this position, determine the target parameter loading instruction corresponding to the redundant parameter among the parameter loading instructions of each parameter of the constructor; Determine the position of the redundant parameter in the parameter array of the constructor according to the execution order of the target parameter loading instruction in the bytecode fragment of the enclosing method, and locate and delete the redundant parameter in the parameter array of the constructor.
7. A hot fix application device, characterized in that, The device includes: A bytecode acquisition unit, configured to acquire the bytecode file of the outer class where the modified anonymous inner class is located after the anonymous inner class fragment in the application source code is modified; wherein, the constructor of the modified anonymous inner class has redundant parameters to be deleted; A variable table acquisition unit, configured to acquire the class information of the outer class where the modified anonymous inner class is located and the method information of the enclosing method of the modified anonymous inner class according to the class information of the modified anonymous inner class, and look up the bytecode fragment of the enclosing method in the bytecode file according to the class information of the outer class and the method information of the enclosing method; in the bytecode fragment of the enclosing method, locate the creation process of the modified anonymous inner class, and in the creation process, identify the parameter loading instructions of the constructor of the modified anonymous inner class, and, in the bytecode fragment of the enclosing method, acquire the local variable table of the enclosing method of the modified anonymous inner class; A parameter name lookup unit, configured to look up the parameter names of each parameter of the constructor in the local variable table according to the parameter values of the parameter loading instructions; wherein, the parameter values are used to represent the positions of the parameter names of the constructor in the local variable table; A parameter deletion unit, configured to locate and delete the redundant parameter in the parameter array of the constructor according to the parameter name of the redundant parameter and the parameter names of each parameter of the constructor; An application repair unit, configured to generate a patch package for the application based on the constructor after deletion, and use the patch package to perform hot repair on the application.
8. A hot fix application device, characterized in that, Including: A processor; And A memory configured to store computer-executable instructions, and the computer-executable instructions, when executed, cause the processor to implement the steps of the application hot repair method according to any one of claims 1-6 above.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store computer-executable instructions, and the computer-executable instructions, when executed by a processor, implement the steps of the application hotfix method described in any one of claims 1-6 above.
10. A computer program product, characterized in that, The computer program product, when executed, implements the steps of the application hotfix method described in any one of claims 1-6 above.
Citation Information
Patent Citations
Method, device, equipment and storage medium for obtaining parameter name and local variable name
CN108628635A
Thermal repair method and device
CN112667521A