Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure have been shown in the accompanying drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustration purposes only and are not intended to limit the scope of the present disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order and/or performed in parallel. Furthermore, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "including" and variations thereof as used herein are intended to be open-ended, i.e., including, but not limited to. The term "based on" is based at least in part on. The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments. Related definitions of other terms will be given in the description below.
It should be noted that the terms "first," "second," and the like in this disclosure are used merely to distinguish one device, module, or unit from another device, module, or unit, and are not intended to limit the order or interdependence of the functions performed by the devices, modules, or units.
It should be noted that references to "one", "a plurality" and "a plurality" in this disclosure are intended to be illustrative rather than limiting, and those of ordinary skill in the art will appreciate that "one or more" is intended to be understood as "one or more" unless the context clearly indicates otherwise.
The names of messages or information interacted between the various devices in the embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
The following describes the technical solutions of the present disclosure and how the technical solutions of the present disclosure solve the above technical problems in detail with specific embodiments. The following embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments. Embodiments of the present disclosure will be described below with reference to the accompanying drawings.
In the prior art, for an SDK hot repair code of an expression containing a syntax sugar in a class to be repaired, for example, an SDK hot repair code containing a lambda expression, in a compiling process of the SDK, a desugaring process is performed by using a third party software such as a retrolambda plug-in, a Jack plug-in, as shown in fig. 1, step S101 is performed, a retrolambda plug-in is introduced in the compiling process of the SDK, step S102 is performed, a java compiling result is obtained by using a hook function, and all the processes using the lambda expression in the java compiling result are desugared by using the retrolambda plug-in, step S103 is performed, so as to generate a desugared SDK.
Since the desugaring process is put in the SDK compiling process, there are the following disadvantages:
1. in the compiling process, when the tool such as retrolambda is used for desugaring, partial functions and support of the desugaring tool of the APK are not available (as shown in the figure, the desugaring function of the google official d8 tool can not be used any more) are caused when the APP is connected to the SDK after desugaring treatment;
2. If the lambda expressions in the code are many, the method number is obviously increased in this way, so that the data size of the SDK hot repair code is large;
3. aiming at the condition that a custom plug-in exists in the SDK compiling process, the product generated by the javac (java compiler) compiler can be collected into the custom plug-in advance, so that the retrolambda plug-in cannot be effective, and the success of all desugarization cannot be ensured.
In order to solve the problems in the prior art, the technical scheme for desugaring in the patch compiling process of the SDK provided by the present disclosure does not affect the compiling process of the SDK, does not affect the hot repair of the APK, does not increase the data volume of the hot repair code of the SDK after the compiling process of the SDK, and can effectively desugaring the hot repair code of the SDK to generate a patch corresponding to the hot repair code of the SDK.
The execution main body of the technical scheme is a server, and the server can be an independent physical server, can also be a server cluster or a distributed system formed by a plurality of physical servers, and can also be a cloud server for providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDNs, basic cloud computing services such as big data and artificial intelligent platforms.
Technical term interpretation:
syntax sugar (syntax sugar): also referred to as a sugar-containing grammar, refers to an addition or component added to the grammar of a computer language that does not affect the function of the language, but is more convenient for a programmer to use. Generally, using syntax sugar can increase the readability of a program, thereby reducing the chance of program code errors.
Desugaring (Desugaring): for source code using grammatical sugar, when compiling the source code, the sugar-containing grammar is converted into a program by using a simpler core grammar so as to meet the compiling requirement.
Fig. 2 is a flow chart of a software development kit hot repair method according to an embodiment of the disclosure, where, as shown in fig. 2, the method may include:
step S201, obtaining a code to be repaired of an SDK, wherein the code to be repaired comprises a class to be repaired, and the class to be repaired comprises an expression containing grammatical sugar;
the SDK in the present disclosure may specifically be a data packet corresponding to a library containing a logic code and a resource code of an application program for implementing a corresponding function of the application program. For example, in a game application, when a payment function is required to purchase a game item or the like, a library related to the payment function needs to be relied on, and a data packet formed by these libraries is an SDK corresponding to the application.
The code to be repaired of the SDK in the present disclosure may be a thermal repair code of the SDK, which is used to generate a thermal repair patch, and the server issues the thermal repair patch to the terminal device, so that the terminal device thermally repairs the SDK by using the thermal repair patch.
The server receives a code to be repaired of the SDK sent by a program developer through the terminal equipment, wherein the class to be repaired in the code to be repaired comprises an expression containing grammatical sugar. Generally, using syntax sugar can increase the readability of a program, thereby reducing the chance of program code errors.
The expression containing the grammatical sugar means that the computer language designs the corresponding grammatical sugar for some expressions in the program, and when the code to be repaired is subjected to the desugarization process, the expressions need to be subjected to the desugarization process.
Step S202, desugaring treatment is carried out on the class to be repaired, and a private method and an internal class corresponding to the expression containing grammatical sugar are generated;
specifically, the retrolambda plug-in can be utilized to carry out desugaring treatment on the code to be repaired, and a private method and an internal class corresponding to the expression containing the grammatical sugar are generated in the process of desugaring the class to be repaired of the expression containing the grammatical sugar.
The desugarization processing refers to converting the grammar sugar corresponding to the expression containing the grammar sugar into an instruction for the Android virtual machine to identify, so that after the application program is accessed into the SDK of the expression containing the grammar sugar, the application program can normally run on the Android device.
The class to be repaired includes expressions containing grammatical sugar, that is, at least one method in the class to be repaired includes expressions containing grammatical sugar.
In one possible implementation manner, the code to be repaired is in a compressed packet form generated through conversion operation, and the desugaring treatment is performed on the class to be repaired, including:
decompressing the code to be repaired to obtain decompressed data of the code to be repaired;
determining a desugaring parameter of the retrolambda insert based on the decompressed data;
and carrying out desugarization treatment on the class to be repaired based on the desugarization parameters.
In practical application, the code to be repaired in the form of a compressed package generated through a conversion (transform) plug-in conversion operation is decompressed to obtain decompressed data, wherein the compressed package form refers to JAR (Java Archive) file, and JAR is a software package file format, and is generally used for aggregating a large number of Java class files, related metadata and resource (text, picture, etc.) files into one file so as to develop Java platform application software or library.
The parameters for the decompression data as a retrolambda insert, namely the desugaring parameters, include: and (3) utilizing the inputfile parameter, the classpath parameter and the like to carry out desugaring treatment on the code to be repaired by utilizing the desugaring parameter.
Step S203, obtaining a patch class corresponding to the class to be repaired, and adding the private method and the internal class into the patch class;
setting corresponding patch classes for the to-be-repaired class in the to-be-repaired code in advance, adding the private method and the internal class corresponding to the expression containing the grammatical sugar, which are obtained by the desugarization of the to-be-repaired class, into the patch class, wherein the patch class contains the private method and the internal class corresponding to the to-be-repaired class, and the purpose is to generate the patch corresponding to the to-be-repaired class by utilizing the private method and the internal class.
Step S204, based on the patch class added with the private method and the internal class, each patch corresponding to the code to be repaired is generated.
Adding the patch class into a patch set, wherein the patch set comprises patch classes corresponding to each to-be-repaired class, executing a method in each patch class based on each patch class corresponding to each to-be-repaired class, and generating patches corresponding to each to-be-repaired class, namely each patch corresponding to the to-be-repaired code.
In one possible implementation, adding the private method and the internal class to the patch class includes:
the private method is copied/moved into the patch class and the internal class is copied/moved into the patch class.
In practical application, the private method and the internal class corresponding to the expression containing the grammatical sugar, which are obtained by desugarizing the class to be repaired, can be added into the patch class in a copying or moving mode, so that the patch class contains the private method and the internal class of the corresponding class to be repaired.
In step S205, each patch is sent to the terminal device, so that the terminal device thermally repairs the SDK with each patch.
In practical application, after patches corresponding to each to-be-repaired class in the to-be-repaired code are generated, the server sends the to-be-repaired code and each corresponding patch to terminal equipment of a user, and the terminal equipment thermally repairs the SDK accessed by the installed application program by using each patch.
In one possible implementation, the grammatical sugar-containing expression is a lambda expression;
the private method comprises logic codes of lambda expressions, and after copying/moving the private method into a patch class corresponding to the class to be repaired, the method further comprises:
modifying the attribute of the private method into a public static method, and modifying the method calling mode of the logic code of the lambda expression in the private method after attribute modification into a reflection mode calling.
Wherein Lambd expression (lambda expression) is an anonymous function for implementing the logic of the variable. In order to enable the private method to be found in the patch class, the control descriptor of the attribute of the private method is modified to a public static method (public static) and the method call mode of the logic code of the lambda expression in the private method is modified to a reflection mode call.
Where reflection refers to an ability of a program to access, detect and modify its own state or behavior. In the Java environment, the reflection method allows the program to acquire definition information of a certain class, such as attributes and methods, when executing, and can also realize the functions of dynamically creating objects of the class, changing contents of the attributes, or executing specific methods.
In one possible implementation, after modifying the method call mode of the logic code of the lambda expression in the private method to a reflection mode call, the method further includes:
and translating the logic codes of the lambda expression with the modified calling mode so that the SDK identifies the logic rules corresponding to the logic codes.
In practical application, since the technical scheme of the present disclosure is that the patch compiling is performed after the SDK compiling process, and the code confusion process is performed on the logic codes in the lambda expression in the SDK compiling process, the logic codes in the lambda expression need to be translated in the process of generating the patch, and translated into the logic rules that can be used by the SDK to be repaired, and the translated logic codes can be used by the SDK.
The code confusion processing refers to reorganizing and processing codes, so that the processed codes have the same functions as the codes before processing, and the confused codes are difficult to decompil, and even if the decompil is successful, the true semantics of the program are difficult to obtain. The obfuscated program code still conforms to the original file format and instruction set, and the execution result is the same as before obfuscation, except that the names of variables, functions and classes in the code are changed.
In one possible implementation, after copying/moving the internal class into the patch class, the method further comprises:
the call to the private method by the internal class is modified to a call to the public static method.
In practical application, the original private method cannot be directly called, after the private method is copied to the patch class, the attribute of the private method is modified into a public static method, the internal class modifies the call to the private method into the call to the public static method, and then the internal class can directly call the method.
The patch compiling process of the technical scheme of the present disclosure is described below by a specific embodiment. The present embodiment is only one implementation manner of the technical solution of the present disclosure, and does not represent all implementation manners of the technical solution of the present disclosure.
As shown in fig. 3, step S301 is executed to obtain a code to be repaired of the software development kit SDK, and classify the code to be repaired (collect hot repair code transform product (jar package) as shown in the figure) by using transform plug-in, where the code to be repaired includes a class to be repaired including lambda expression;
executing step S302, performing desugaring treatment on the code to be repaired through a retrolambda plug-in (processing jar packets through the retrolambda plug-in as shown in the figure);
step S303 is executed, before the patch is generated, the class to be repaired is desugared (the class to be repaired is desugared before the patch is automatically generated as shown in the figure);
in the process of executing step S303, steps S304 and S308 are executed, where for the class to be repaired containing the lambda expression, a private method (a lambda private method is newly added in the class to be repaired as shown in the figure) and an internal class (an internal class is newly added in the class to be repaired as shown in the figure) are newly added, and the logic code of the lambda expression is contained in the newly added private method; step S305 is executed, the newly added private method is copied into the patch class corresponding to the to-be-repaired class (the new method is copied into the patch class corresponding to the to-be-repaired class as shown in the figure);
executing step S306, changing the attribute of the private method into a public static method (changing the control modifier of the new method into public static as shown in the figure);
Executing step S307, modifying the calling mode of the logic code of the lambda expression in the newly added private method into a reflection mode call, and translating the private method to obtain the confused code (as shown in the figure, the content in the new method is changed into the reflection mode call, and the logic rule that can be used by the code after SDK confusion is translated);
step S309 is executed to change the call to the newly added private method in the newly added internal class into the call to the public static method copied into the patch class (the modification shown in the figure calls the lambda method, and moves from the to-be-repaired class to the patch class);
step S310 is executed, wherein the newly added internal class is added into a patch set (the class is added into the patch set as shown in the figure), and the patch set comprises a plurality of patch classes corresponding to the codes to be repaired;
step S311 is executed to execute the obfuscated code of the newly added private method and the newly added internal class, and generate a patch of the code to be repaired (generating a patch as shown in the figure).
In the software development kit hot repair method provided by the embodiment of the disclosure, a code to be repaired of an SDK is obtained, the code to be repaired comprises a class to be repaired, and the class to be repaired comprises an expression containing grammatical sugar; and performing desugaring treatment on the class to be repaired to obtain a private method and an internal class corresponding to the expression containing the grammatical sugar, and adding the private method and the internal class into a patch class corresponding to the class to be repaired to generate each patch. In the technical scheme provided by the disclosure, in the process of generating the patch corresponding to the SDK code to be repaired, the patch corresponding to the SDK code to be repaired is generated based on the private method and the internal class generated by the desugarizing treatment of the class to be repaired. The method has no influence on the compiling process of the SDK, does not influence the function of the desugaring tool of the APK after the code to be repaired of the SDK is accessed into the application program, does not increase the data volume of the code to be repaired of the SDK, and expands the usability of the code to be repaired of the SDK.
Based on the same principle as the method shown in fig. 2, a software development kit thermal repairing apparatus 40 is also provided in an embodiment of the present disclosure, and as shown in fig. 4, the software development kit thermal repairing apparatus 40 may include:
an obtaining module 41, configured to obtain a code to be repaired of the software development kit SDK, where the code to be repaired includes a class to be repaired, and the class to be repaired includes an expression containing a syntax sugar;
a first generation module 42, configured to perform desugaring processing on the class to be repaired, and generate a private method and an internal class corresponding to the expression containing the grammatical sugar;
the adding module 43 is configured to obtain a patch class corresponding to the to-be-repaired class, and add the private method and the internal class to the patch class;
a second generating module 44, configured to generate each patch corresponding to the code to be repaired based on the patch class to which the private method and the internal class are added;
and the sending module 45 is configured to send each patch to the terminal device, so that the terminal device thermally repairs the SDK by using each patch.
In one possible implementation, the adding module 43 is configured to:
the private method is copied/moved into the patch class and the internal class is copied/moved into the patch class.
In one possible implementation, the expression containing the grammatical sugar is a lambda expression, the private method comprises logic code of the lambda expression, and the apparatus 40 further comprises a modification module for:
After copying/moving the private method to the patch class corresponding to the to-be-repaired class, modifying the attribute of the private method to be a public static method, and modifying the method calling mode of the logic code of the lambda expression in the private method with the modified attribute to be a reflection mode calling.
In one possible implementation, the modification module is further configured to:
after the method calling mode of the logic codes of the lambda expression in the private method is modified into the reflection mode calling, the logic codes of the lambda expression after the calling mode modification are translated, so that the SDK identifies the logic rules corresponding to the logic codes.
In one possible implementation, the modification module is further configured to:
after copying/moving the internal class into the patch class, the call to the private method by the internal class is modified to a call to the public static method.
In one possible implementation, the code to be repaired is in the form of a compressed packet generated through a conversion operation, and the first generating module 42 is configured to:
decompressing the code to be repaired to obtain decompressed data of the code to be repaired;
determining a desugaring parameter of the retrolambda insert based on the decompressed data;
and carrying out desugarization treatment on the class to be repaired based on the desugarization parameters.
The software development kit hot repair device according to the embodiments of the present disclosure may perform the software development kit hot repair method provided by the embodiments of the present disclosure, and the implementation principle is similar, and actions performed by each module in the software development kit hot repair device according to each embodiment of the present disclosure correspond to steps in the software development kit hot repair method according to each embodiment of the present disclosure, and detailed functional descriptions of each module in the software development kit hot repair device may be referred to the descriptions in the corresponding software development kit hot repair method shown in the foregoing, which are not repeated herein.
The software development kit hot repairing device provided by the embodiment of the disclosure obtains a code to be repaired of the SDK, wherein the code to be repaired comprises a class to be repaired, and the class to be repaired comprises an expression containing grammatical sugar; and performing desugaring treatment on the class to be repaired to obtain a private method and an internal class corresponding to the expression containing the grammatical sugar, and adding the private method and the internal class into a patch class corresponding to the class to be repaired to generate each patch. In the technical scheme provided by the disclosure, in the process of generating the patch corresponding to the SDK code to be repaired, the patch corresponding to the SDK code to be repaired is generated based on the private method and the internal class generated by the desugarizing treatment of the class to be repaired. The method has no influence on the compiling process of the SDK, does not influence the function of the desugaring tool of the APK after the code to be repaired of the SDK is accessed into the application program, does not increase the data volume of the code to be repaired of the SDK, and expands the usability of the code to be repaired of the SDK.
Referring now to fig. 5, a schematic diagram of an electronic device 600 suitable for use in implementing embodiments of the present disclosure is shown. The execution subject of the technical solution of the embodiment of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (e.g., vehicle-mounted navigation terminals), and the like, and fixed terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 5 is merely an example and should not be construed to limit the functionality and scope of use of the disclosed embodiments.
An electronic device includes: a memory and a processor, where the processor may be referred to as a processing device 601 described below, the memory may include at least one of a Read Only Memory (ROM) 602, a Random Access Memory (RAM) 603, and a storage device 608 described below, as follows:
as shown in fig. 5, the electronic device 600 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 601, which may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage means 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic apparatus 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
In general, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, and the like; an output device 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 608 including, for example, magnetic tape, hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While fig. 5 shows an electronic device 600 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a non-transitory computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via communication means 609, or from storage means 608, or from ROM 602. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by the processing device 601.
It should be noted that the computer readable medium described in the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
In some implementations, the clients, servers may communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol ), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the internet (e.g., the internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed networks.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: acquiring a code to be repaired of a Software Development Kit (SDK), wherein the code to be repaired comprises a class to be repaired, and the class to be repaired comprises an expression containing grammatical sugar; performing desugaring treatment on the class to be repaired to generate a private method and an internal class corresponding to the expression containing the grammatical sugar; obtaining a patch class corresponding to the class to be repaired, and adding the private method and the internal class into the patch class; generating each patch corresponding to the code to be repaired based on the patch class added with the private method and the internal class; and sending each patch to the terminal equipment so that the terminal equipment can thermally repair the SDK by using each patch.
Computer program code for carrying out operations of the present disclosure may be written in one or more programming languages, including, but not limited to, an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules or units involved in the embodiments of the present disclosure may be implemented by means of software, or may be implemented by means of hardware. Where the name of a module or unit does not in some cases constitute a limitation of the unit itself.
The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a system on a chip (SOC), a Complex Programmable Logic Device (CPLD), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
In accordance with one or more embodiments of the present disclosure, the present disclosure provides a software development kit hot fix method, the method comprising:
acquiring a code to be repaired of a Software Development Kit (SDK), wherein the code to be repaired comprises a class to be repaired, and the class to be repaired comprises an expression containing grammatical sugar;
performing desugaring treatment on the class to be repaired to generate a private method and an internal class corresponding to the expression containing the grammatical sugar;
obtaining a patch class corresponding to the class to be repaired, and adding the private method and the internal class into the patch class;
generating each patch corresponding to the code to be repaired based on the patch class added with the private method and the internal class;
and sending each patch to a terminal device so that the terminal device thermally repairs the SDK by using each patch.
In one possible implementation, the adding the private method and the internal class to the patch class includes:
copying/moving the private method into the patch class and copying/moving the internal class into the patch class.
In one possible implementation manner, the expression containing the grammatical sugar is a lambda expression, the private method includes logic code of the lambda expression, and after copying/moving the private method into the patch class corresponding to the to-be-repaired class, the method further includes:
Modifying the attribute of the private method into a public static method, and modifying the method calling mode of the logic code of the lambda expression in the private method after attribute modification into a reflection mode calling.
In one possible implementation, after modifying the method call mode of the logic code of the lambda expression in the private method to a reflection mode call, the method further includes:
and translating the logic codes of the lambda expression with the modified calling mode so that the SDK identifies the logic rules corresponding to the logic codes.
In one possible implementation, after copying/moving the internal class into the patch class, the method further includes:
and modifying the call of the internal class to the private method into the call to the public static method.
In one possible implementation manner, the code to be repaired is in a compressed packet form generated through conversion operation, and the desugaring processing is performed on the class to be repaired, including:
decompressing the code to be repaired to obtain decompressed data of the code to be repaired;
determining a desugaring parameter of a retrolambda insert based on the decompressed data;
And carrying out desugarization treatment on the class to be repaired based on the desugarization parameter.
In accordance with one or more embodiments of the present disclosure, the present disclosure provides a software development kit hot repair apparatus, the apparatus comprising:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring to-be-repaired codes of a Software Development Kit (SDK), the to-be-repaired codes comprise to-be-repaired classes, and the to-be-repaired classes comprise expressions containing grammatical sugar;
the first generation module is used for carrying out desugaring treatment on the class to be repaired and generating a private method and an internal class corresponding to the expression containing the grammatical sugar;
the adding module is used for obtaining a patch class corresponding to the class to be repaired and adding the private method and the internal class into the patch class;
the second generation module is used for generating each patch corresponding to the code to be repaired based on the patch class added with the private method and the internal class;
and the sending module is used for sending the patches to terminal equipment so that the terminal equipment can thermally repair the SDK by utilizing the patches.
In one possible implementation manner, the adding module is configured to:
copying/moving the private method into the patch class and copying/moving the internal class into the patch class.
In one possible implementation, the expression containing a grammatical sugar is a lambda expression, the private method includes logic code of the lambda expression, and the apparatus further includes a modification module for:
after copying/moving the private method to the patch class corresponding to the class to be repaired, modifying the attribute of the private method to be a public static method, and modifying the method calling mode of the logic code of the lambda expression in the private method after attribute modification to be a reflection mode calling.
In one possible implementation, the modification module is further configured to:
after the method calling mode of the logic codes of the lambda expression in the private method is modified into the reflection mode calling, the logic codes of the lambda expression with the modified calling mode are translated, so that the SDK identifies the logic rules corresponding to the logic codes.
In one possible implementation, the modification module is further configured to:
after copying/moving the internal class into the patch class, the call to the private method by the internal class is modified to a call to a public static method.
In one possible implementation manner, the code to be repaired is in a compressed packet form generated through a conversion operation, and the first generating module is configured to:
decompressing the code to be repaired to obtain decompressed data of the code to be repaired;
determining a desugaring parameter of a retrolambda insert based on the decompressed data;
and carrying out desugarization treatment on the class to be repaired based on the desugarization parameter.
According to one or more embodiments of the present disclosure, the present disclosure provides an electronic device comprising:
one or more processors;
a memory;
one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, the one or more applications configured to perform the software development kit hot fix method.
In accordance with one or more embodiments of the present disclosure, the present disclosure provides a computer-readable medium for storing computer instructions that, when executed on a computer, cause the computer to perform the software development kit hot fix method.
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by persons skilled in the art that the scope of the disclosure referred to in this disclosure is not limited to the specific combinations of features described above, but also covers other embodiments which may be formed by any combination of features described above or equivalents thereof without departing from the spirit of the disclosure. Such as those described above, are mutually substituted with the technical features having similar functions disclosed in the present disclosure (but not limited thereto).
Moreover, although operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. In certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are example forms of implementing the claims.