CN113626051A - Byte code updating method and device and electronic equipment - Google Patents

Byte code updating method and device and electronic equipment Download PDF

Info

Publication number
CN113626051A
CN113626051A CN202110850465.6A CN202110850465A CN113626051A CN 113626051 A CN113626051 A CN 113626051A CN 202110850465 A CN202110850465 A CN 202110850465A CN 113626051 A CN113626051 A CN 113626051A
Authority
CN
China
Prior art keywords
modified
class
bytecode
target
updating
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110850465.6A
Other languages
Chinese (zh)
Inventor
吴俊洲
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN202110850465.6A priority Critical patent/CN113626051A/en
Publication of CN113626051A publication Critical patent/CN113626051A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The disclosure relates to the technical field of computers, and particularly relates to a bytecode updating method. The specific implementation scheme is as follows: acquiring a first class to be modified in the bytecode, wherein the first class to be modified is a class containing a method to be modified; acquiring a second class to be modified, and acquiring a third class to be modified according to the first class to be modified and the second class to be modified; and determining a target bytecode based on the third class to be modified, and updating the target bytecode, wherein the target bytecode is a bytecode for calling the method to be modified in the third class to be modified. And acquiring the third class to be modified through the first class to be modified and the second class to be modified, determining a target bytecode based on the third class to be modified, and updating the target bytecode, so that the method to be modified for calling all subclasses of a certain class is modified.

Description

Byte code updating method and device and electronic equipment
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method and an apparatus for updating a bytecode, and an electronic device.
Background
In the process of program development, in order to meet different business requirements, methods in the program need to be modified. In the prior art, method calls in a program are generally modified in a compiling period, but the technical scheme for modifying the method calls in the program in the compiling period can only modify a method to be modified in a certain class into a target method, and cannot modify methods to be modified for calling all subclasses of the certain class.
Disclosure of Invention
The present disclosure provides a method and an apparatus for updating a bytecode, and an electronic device, so as to at least solve a problem that a method to be modified for invoking all subclasses of a certain class cannot be modified in a related art. The technical scheme of the disclosure is as follows:
according to a first aspect of the embodiments of the present disclosure, there is provided a method for updating a bytecode, including: acquiring a first class to be modified in the bytecode, wherein the first class to be modified is a class containing a method to be modified;
acquiring a second class to be modified, and acquiring a third class to be modified according to the first class to be modified and the second class to be modified;
determining a target bytecode based on the third class to be modified, and updating the target bytecode according to a predetermined configuration file, wherein the target bytecode is a bytecode for calling the method to be modified in the third class to be modified;
and acquiring the second class to be modified and the replacement relation of the method to be modified contained in the second class to be modified from the predetermined configuration file.
Optionally, the obtaining a first class to be modified in the bytecode includes:
traversing a class in the bytecode, and determining the class as the first class to be modified if the class contains the method to be modified;
and forming a first set according to the first class to be modified.
Optionally, the obtaining the second class to be modified and obtaining a third class to be modified according to the first class to be modified and the second class to be modified includes:
traversing the first set, and if the first class to be modified is a direct subclass or an indirect subclass of the second class to be modified, determining that the first class to be modified is a third class to be modified;
and forming a second set according to the third class to be modified.
Optionally, the obtaining, from the predetermined configuration file, the second class to be modified and the replacement relationship of the method to be modified included in the second class to be modified includes:
traversing the bytecode, and if the bytecode calls the to-be-modified method of the third to-be-modified class in the second set, determining the bytecode as a target bytecode;
and replacing the method to be modified in the target bytecode with a target method to generate an updated target bytecode.
According to a second aspect of the embodiments of the present disclosure, there is provided a byte code updating apparatus, including:
the device comprises a first class to be modified acquisition module, a second class to be modified acquisition module and a modification module, wherein the first class to be modified is a class containing a method to be modified;
the second to-be-modified class acquisition module is used for acquiring a second to-be-modified class and acquiring a third to-be-modified class according to the first to-be-modified class and the second to-be-modified class;
an updating module, configured to determine a target bytecode based on the third class to be modified and update the target bytecode according to a predetermined configuration file, where the target bytecode is a bytecode for calling the method to be modified in the third class to be modified;
and acquiring the second class to be modified and the replacement relation of the method to be modified contained in the second class to be modified from the predetermined configuration file.
Optionally, the first class to be modified obtaining module includes:
the first traversal submodule is used for traversing the class in the byte codes, and if the class contains the method to be modified, the class is determined to be the first class to be modified;
and the first set construction submodule is used for forming a first set according to the first class to be modified.
Optionally, the second class to be modified obtaining module includes:
the second traversal submodule is used for traversing the first set, and if the first class to be modified is a direct subclass or an indirect subclass of the second class to be modified, determining that the first class to be modified is a third class to be modified;
and the second set constructing submodule is used for forming a second set according to the third class to be modified.
Optionally, the update module includes:
a third traversal submodule, configured to traverse the bytecode, and determine that the bytecode is a target bytecode if the bytecode calls a to-be-modified method of the third to-be-modified class in the second set;
and the updating submodule is used for replacing the method to be modified in the target bytecode with a target method so as to generate an updated target bytecode.
According to a third aspect of the embodiments of the present disclosure, there is provided a bytecode updating apparatus, including:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the bytecode updating method according to any of the first aspect.
According to a fourth aspect of embodiments of the present disclosure, there is provided a non-transitory computer-readable storage medium having instructions therein, which when executed by a processor of a bytecode updating apparatus, enable the bytecode updating apparatus to perform the bytecode updating method according to any one of the first aspects.
According to a fifth aspect of embodiments of the present disclosure, there is provided a computer program product comprising a computer program which, when executed by a processor, implements the method of any one of the first aspects.
The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects:
and screening the subclasses and indirect subclasses of the second class to be modified from the first set, further determining target bytes, and finally updating the target byte codes. The problem that the method to be modified for calling all the subclasses of a certain class cannot be modified is solved, byte codes are updated, and the efficiency and accuracy of byte code updating are improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the disclosure and are not to be construed as limiting the disclosure.
Fig. 1 is a flow chart illustrating a bytecode updating method according to an exemplary embodiment.
Fig. 2 is a flow chart illustrating a bytecode update method according to an exemplary embodiment.
Fig. 3 is a flow chart illustrating a method for bytecode update according to an exemplary embodiment.
Fig. 4 is a flow chart illustrating a bytecode update method according to an exemplary embodiment.
Fig. 5 is a block diagram illustrating an apparatus for updating bytecode according to an exemplary embodiment.
Fig. 6 is a block diagram illustrating an apparatus for updating bytecode according to an exemplary embodiment.
Fig. 7 is a block diagram illustrating an apparatus for updating bytecode according to an exemplary embodiment.
Fig. 8 is a block diagram illustrating an apparatus for updating bytecode according to an exemplary embodiment.
Fig. 9 is a flowchart illustrating a bytecode update method according to an exemplary embodiment.
Fig. 10 is a block diagram illustrating an apparatus for updating bytecode according to an exemplary embodiment.
Detailed Description
In order to make the technical solutions of the present disclosure better understood by those of ordinary skill in the art, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in sequences other than those illustrated or otherwise described herein. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
Fig. 1 is a flowchart illustrating a bytecode updating method according to an exemplary embodiment, where the bytecode updating method is used in a program, as shown in fig. 1, and includes the following steps.
In step 101, a first class to be modified in the bytecode is obtained, wherein the first class to be modified is a class containing a method to be modified.
In order to realize bytecode update, the method to be modified, the second class to be modified, and the target method need to be configured, and a configuration file in a Json format is used for configuration, so that the method to be modified in the subclass or indirect subclass of the second class to be modified is finally changed into the target method. In this step, the class containing the method to be modified, that is, the first class to be modified, can be screened from the byte code file according to the method tag of the method to be modified. And after the first class to be modified is screened out, forming a first set by the first class to be modified.
In step 102, a second class to be modified is obtained, and a third class to be modified is obtained according to the first class to be modified and the second class to be modified.
And if the byte codes corresponding to the first class to be modified in the first set do not need to be updated, further screening the first class to be modified by acquiring a class label of a second class to be modified through the configuration file, and judging whether the first class to be modified is the third class to be modified. If the first class to be modified is a direct subclass or an indirect subclass of the second class to be modified, determining that the first class to be modified is a third class to be modified; and if the first class to be modified is not the direct subclass or the indirect subclass of the second class to be modified, determining that the first class to be modified is not the third class to be modified. And after the third class to be modified is screened out, the third class to be modified forms the second set.
In step 103, a target bytecode is determined based on the third class to be modified, and the target bytecode is updated according to a predetermined configuration file, where the target bytecode is a bytecode for calling the method to be modified in the third class to be modified.
The second set including the third class to be modified may be obtained through the foregoing steps, and in order to update the bytecode, a bytecode, that is, a target bytecode, that calls the method to be modified in the third class to be modified is retrieved through this step. And replacing the name of the method to be modified in the target bytecode with the name of the target method, so that the process of updating the target bytecode can be completed.
And acquiring the second class to be modified and the replacement relation of the method to be modified contained in the second class to be modified from the predetermined configuration file.
The method to be modified, the second class to be modified and the target method are set through the configuration file. In a possible implementation manner, a configuration file in a Json format is used for configuration, the method to be modified is "getScrollX", the second class to be modified is "android/webkit/WebView", and the target method is "getWebScrollX". The configuration in the configuration file is "inner": "android/webkit/WebView", "before": "getScrollX", "after": "getWebScrolX".
The method to be modified, the second class to be modified and the target method are defined through the configuration file, the first class to be modified corresponding to the method to be modified is conveniently found from the byte code file, and the method to be modified is changed into the target method.
Fig. 2 is a flowchart illustrating a bytecode updating method according to an exemplary embodiment, where the bytecode updating method is used in a program, as shown in fig. 2, and includes the following steps:
step 201, traversing a class in the bytecode, and determining the class as the first class to be modified if the class contains the method to be modified;
in order to realize bytecode update, it is first necessary to scan all bytecode files, find the class in which all methods before bytecode update are called, that is, find the first class to be modified containing the method to be modified. In one possible embodiment, where the modified method is "getScrollX," then all types that call the "getScrollX" method are found and placed in the first set. And screening by the steps to obtain the first class to be modified.
Step 202, forming a first set according to the first class to be modified.
And the first classes to be modified are collected together to form the first set. And facilitating the subsequent further screening of the first class to be modified.
Fig. 3 is a flowchart illustrating a bytecode updating method according to an exemplary embodiment, where the bytecode updating method is used in a program, as shown in fig. 3, and includes the following steps:
step 301, traversing the first set, and if the first class to be modified is a direct subclass or an indirect subclass of the second class to be modified, determining that the first class to be modified is a third class to be modified;
in this step, the first class to be modified in the first set is further screened, and in this embodiment, only the first class to be modified belonging to the subclass or the indirect subclass of the second class to be modified needs to be screened, and the bytecode for calling the first class to be modified is updated. In a possible embodiment, the second class to be modified is "android/webkit/WebView", and all the first classes to be modified belonging to the "android", "webkit", "WebView" subclass or indirect subclass are found and placed in the second set. And screening by the steps to obtain the third class to be modified.
And step 302, forming a second set according to the third class to be modified.
And collecting the third classes to be modified together to form the second set. The subsequent retrieval of the bytes and byte code updating are facilitated.
Fig. 4 is a flowchart illustrating a bytecode updating method according to an exemplary embodiment, where the bytecode updating method is used in a program, as shown in fig. 4, and includes the following steps:
step 401, traversing the bytecode, and if the bytecode calls the to-be-modified method of the third to-be-modified class in the second set, determining that the bytecode is a target bytecode;
step 402, replacing the method to be modified in the target bytecode with a target method to generate an updated target bytecode.
And after the third class to be modified is obtained through screening, byte code updating can be carried out. The bytecode update needs to find a bytecode, which calls the method to be modified in the third class to be modified, in the bytecode, that is, a target bytecode, and change a name of the method to be modified in the target bytecode into the name of the target method. In a possible embodiment, the method to be modified is "getScrollX", and the target method is "getWebScrollY". Changing the 'getScrollX' in the target bytecode to the 'getWebScrollY', namely, completing the bytecode update.
And screening the subclasses and indirect subclasses of the second class to be modified from the first set, further determining target bytes, and finally updating the target byte codes. The problem that the method to be modified for calling all the subclasses of a certain class cannot be modified is solved, byte codes are updated, and the efficiency and accuracy of byte code updating are improved.
Fig. 9 is a flowchart illustrating a bytecode update method according to an exemplary embodiment.
As shown in fig. 9, first, the second class to be modified and the replacement relationship between the method to be modified and the target method included in the second class to be modified are obtained from a predetermined configuration file, in a possible embodiment, the method to be modified is "getscalx", the second class to be modified is "android/webkit/WebView", and the target method is "getwebscaly". After the preparation work is completed, byte code updating is started: firstly, traversing all byte code files, finding a class calling the method 'getScrollX' to be modified, determining the class as a first class to be modified and putting the class into a set A; traversing the set A, searching the class belonging to the sub-class or indirect sub-class of the second class to be modified, determining the class as a third class to be modified, and putting the third class into the set B; and finally, traversing the bytecode file, finding out the bytecode file for calling the method 'getScrollX' to be modified in the third class to be modified, and modifying 'getScrollX' in the bytecode file into the target method 'getWebScrollY'. This completes the byte code update process.
Fig. 5 is a block diagram illustrating an apparatus for updating bytecode according to an exemplary embodiment. Referring to fig. 5, the apparatus 500 includes a first to-be-modified class acquisition module 510, a second to-be-modified class acquisition module 520, and an update module 530.
A first class to be modified obtaining module 510, configured to obtain a first class to be modified in the bytecode, where the first class to be modified is a class including a method to be modified;
in order to realize bytecode update, the method to be modified, the second class to be modified, and the target method need to be configured, and a configuration file in a Json format is used for configuration, so that the method to be modified in the subclass or indirect subclass of the second class to be modified is finally changed into the target method. The module can screen the class containing the method to be modified, namely the first class to be modified, from the byte code file according to the method label of the method to be modified. And after the first class to be modified is screened out, forming a first set by the first class to be modified.
A second class-to-be-modified obtaining module 520, configured to obtain a second class to be modified, and obtain a third class to be modified according to the first class to be modified and the second class to be modified;
and if the first class to be modified in the first set is not all the classes to be modified, the module acquires a class label of a second class to be modified through the configuration file to further screen the first class to be modified, and judges whether the first class to be modified is the third class to be modified. If the first class to be modified is a direct subclass or an indirect subclass of the second class to be modified, determining that the first class to be modified is a third class to be modified; and if the first class to be modified is not the direct subclass or the indirect subclass of the second class to be modified, determining that the first class to be modified is not the third class to be modified. And after the third class to be modified is screened out, the third class to be modified forms the second set.
An updating module 530, configured to determine a target bytecode based on the third class to be modified, and update the target bytecode according to a predetermined configuration file, where the target bytecode is a bytecode for calling the method to be modified in the third class to be modified;
the second set including the third class to be modified may be obtained by the foregoing module, and in order to update the bytecode, a bytecode, that is, a target bytecode, that calls the method to be modified in the third class to be modified is retrieved by the present module. And replacing the name of the method to be modified in the target bytecode with the name of the target method, so that the process of updating the target bytecode can be completed.
And acquiring the second class to be modified and the replacement relation of the method to be modified contained in the second class to be modified from the predetermined configuration file.
The method to be modified, the second class to be modified and the target method are set through the configuration file. In a possible implementation manner, a configuration file in a Json format is used for configuration, the method to be modified is "getScrollX", the second class to be modified is "android/webkit/WebView", and the target method is "getWebScrollX". The configuration in the configuration file is "inner": "android/webkit/WebView", "before": "getScrollX", "after": "getWebScrolX".
The method to be modified, the second class to be modified and the target method are defined through the configuration file, the first class to be modified corresponding to the method to be modified is conveniently found from the byte code file, and the method to be modified is changed into the target method.
Fig. 6 is a block diagram illustrating an apparatus for updating bytecode according to an exemplary embodiment. Referring to FIG. 6, the apparatus 600 includes a first traversal sub-module 610 and a first set construction sub-module 620.
A first traversal submodule 610, configured to traverse a class in the bytecode, and determine the class as the first class to be modified if the class includes the method to be modified;
in order to realize bytecode update, it is first necessary to scan all bytecode files, find the class in which all methods before bytecode update are called, that is, find the first class to be modified containing the method to be modified. In one possible embodiment, where the modified method is "getScrollX," then all types that call the "getScrollX" method are found and placed in the first set. And screening the modules to obtain the first class to be modified.
A first set constructing sub-module 620, configured to form a first set according to the first class to be modified.
And the first classes to be modified are collected together to form the first set. And facilitating the subsequent further screening of the first class to be modified.
Fig. 7 is a block diagram illustrating an apparatus for updating bytecode according to an exemplary embodiment. Referring to FIG. 7, the apparatus 700 includes a second traversal submodule 710 and a second set building submodule 720.
A second traversal submodule 710, configured to traverse the first set, and if the first class to be modified is a direct subclass or an indirect subclass of the second class to be modified, determine that the first class to be modified is a third class to be modified;
the module further filters the first class to be modified in the first set, and in this embodiment, only the first class to be modified belonging to the subclass or the indirect subclass of the second class to be modified needs to be filtered, so as to update the bytecode for calling the subclass or the indirect subclass. In a possible embodiment, the second class to be modified is "android/webkit/WebView", and all the first classes to be modified belonging to the "android", "webkit", "WebView" subclass or indirect subclass are found and placed in the second set. And screening the modules to obtain the third class to be modified.
And the second set constructing submodule 720 is configured to form a second set according to the third class to be modified.
And collecting the third classes to be modified together to form the second set. The subsequent retrieval of the bytes and byte code updating are facilitated.
Fig. 8 is a block diagram illustrating an apparatus for updating bytecode according to an exemplary embodiment. Referring to FIG. 8, the apparatus 800 includes a third traversal submodule 810 and an update submodule 820.
A third traversal submodule 810, configured to traverse the bytecode, and determine that the bytecode is a target bytecode if the bytecode calls a to-be-modified method of the third to-be-modified class in the second set;
an updating sub-module 820, configured to replace the method to be modified in the target bytecode with a target method to generate an updated target bytecode.
And after the third class to be modified is obtained through screening, byte code updating can be carried out. The bytecode update needs to find a bytecode, which calls the method to be modified in the third class to be modified, in the bytecode, that is, a target bytecode, and change a name of the method to be modified in the target bytecode into the name of the target method. In a possible embodiment, the method to be modified is "getScrollX", and the target method is "getWebScrollY". Changing the 'getScrollX' in the target bytecode to the 'getWebScrollY', namely, completing the bytecode update.
And screening the subclasses and indirect subclasses of the second class to be modified from the first set, further determining target bytes, and finally updating the target byte codes. The problem that the method to be modified for calling all the subclasses of a certain class cannot be modified is solved, byte codes are updated, and the efficiency and accuracy of byte code updating are improved.
Fig. 10 is a block diagram illustrating an apparatus for updating bytecode according to an exemplary embodiment.
The bytecode update means is intended to represent various forms of digital computers such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other suitable computers. The bytecode update device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 10, the apparatus 1000 includes a computing unit 1001 that can perform various appropriate actions and processes according to a computer program stored in a Read Only Memory (ROM)1002 or a computer program loaded from a storage unit 1003 into a Random Access Memory (RAM) 1003. In the RAM 1003, various programs and data necessary for the operation of the device 1000 can also be stored. The calculation unit 1001, the ROM 1002, and the RAM 1003 are connected to each other by a bus 1004. An input/output (I/O) interface 1005 is also connected to bus 1004.
A number of components in device 1000 are connected to I/O interface 1005, including: an input unit 1006 such as a keyboard, a mouse, and the like; an output unit 1007 such as various types of displays, speakers, and the like; a storage unit 1008 such as a magnetic disk, an optical disk, or the like; and a communication unit 1009 such as a network card, a modem, a wireless communication transceiver, or the like. The communication unit 1009 allows the device 1000 to exchange information/data with other devices through a computer network such as the internet and/or various telecommunication networks.
Computing unit 1001 may be a variety of general and/or special purpose processing components with processing and computing capabilities. Some examples of the computing unit 1001 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various dedicated Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, and so forth. The calculation unit 1001 executes the respective methods and processes described above, such as the update method of the bytecode. For example, in some embodiments, the bytecode update method can be implemented as a computer software program tangibly embodied in a machine-readable medium, such as the storage unit 1008. In some embodiments, part or all of the computer program may be loaded and/or installed onto device 1000 via ROM 1002 and/or communications unit 1009. When the computer program is loaded into the RAM 1003 and executed by the computing unit 1001, one or more steps of the bytecode update method described above may be performed. Alternatively, in other embodiments, the computing unit 1001 may be configured to perform the bytecode updating method by any other suitable means (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, Field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), system on a chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the program codes, when executed by the processor or controller, cause the functions/operations specified in the flowchart and/or block diagram to be performed. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.
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. A 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.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), Wide Area Networks (WANs), the internet, and blockchain networks.
The computer system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The Server can be a cloud Server, also called a cloud computing Server or a cloud host, and is a host product in a cloud computing service system, so as to solve the defects of high management difficulty and weak service expansibility in the traditional physical host and VPS service ("Virtual Private Server", or simply "VPS"). The server may also be a server of a distributed system, or a server incorporating a blockchain.
And screening the subclasses and indirect subclasses of the second class to be modified from the first set, further determining target bytes, and finally updating the target byte codes. The problem that the method to be modified for calling all the subclasses of a certain class cannot be modified is solved, byte codes are updated, and the efficiency and accuracy of byte code updating are improved.
It should be understood that various forms of the flows shown above may be used, with steps reordered, added, or deleted. For example, the steps described in the present disclosure may be executed in parallel, sequentially, or in different orders, as long as the desired results of the technical solutions disclosed in the present disclosure can be achieved, and the present disclosure is not limited herein.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (10)

1. A method for updating byte codes, comprising:
acquiring a first class to be modified in the bytecode, wherein the first class to be modified is a class containing a method to be modified;
acquiring a second class to be modified, and acquiring a third class to be modified according to the first class to be modified and the second class to be modified;
determining a target bytecode based on the third class to be modified, and updating the target bytecode according to a predetermined configuration file, wherein the target bytecode is a bytecode for calling the method to be modified in the third class to be modified;
and acquiring the second class to be modified and the replacement relation of the method to be modified contained in the second class to be modified from the predetermined configuration file.
2. The method of claim 1, wherein obtaining the first class to be modified in the bytecode comprises:
traversing a class in the bytecode, and determining the class as the first class to be modified if the class contains the method to be modified;
and forming a first set according to the first class to be modified.
3. The method according to claim 2, wherein the obtaining the second class to be modified and obtaining a third class to be modified according to the first class to be modified and the second class to be modified comprises:
traversing the first set, and if the first class to be modified is a direct subclass or an indirect subclass of the second class to be modified, determining that the first class to be modified is a third class to be modified;
and forming a second set according to the third class to be modified.
4. The method according to claim 1, wherein the obtaining the second class to be modified and the replacement relationship of the method to be modified included in the second class to be modified from the predetermined configuration file comprises:
traversing the bytecode, and if the bytecode calls the to-be-modified method of the third to-be-modified class in the second set, determining the bytecode as a target bytecode;
and replacing the method to be modified in the target bytecode with a target method to generate an updated target bytecode.
5. An apparatus for updating byte codes, comprising:
the device comprises a first class to be modified acquisition module, a second class to be modified acquisition module and a modification module, wherein the first class to be modified is a class containing a method to be modified;
the second to-be-modified class acquisition module is used for acquiring a second to-be-modified class and acquiring a third to-be-modified class according to the first to-be-modified class and the second to-be-modified class;
an updating module, configured to determine a target bytecode based on the third class to be modified and update the target bytecode according to a predetermined configuration file, where the target bytecode is a bytecode for calling the method to be modified in the third class to be modified;
and acquiring the second class to be modified and the replacement relation of the method to be modified contained in the second class to be modified from the predetermined configuration file.
6. The apparatus of claim 5, wherein the first class to be modified obtaining module comprises:
the first traversal submodule is used for traversing the class in the byte codes, and if the class contains the method to be modified, the class is determined to be the first class to be modified;
and the first set construction submodule is used for forming a first set according to the first class to be modified.
7. The apparatus of claim 6, wherein the second class to be modified obtaining module comprises:
the second traversal submodule is used for traversing the first set, and if the first class to be modified is a direct subclass or an indirect subclass of the second class to be modified, determining that the first class to be modified is a third class to be modified;
and the second set constructing submodule is used for forming a second set according to the third class to be modified.
8. An apparatus for updating byte codes, comprising:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the bytecode update method of any of claims 1-4.
9. A non-transitory computer-readable storage medium, wherein instructions in the storage medium, when executed by a processor of a bytecode updating apparatus, enable the bytecode updating apparatus to perform the bytecode updating method according to any one of claims 1 to 4.
10. A computer program product, characterized in that it comprises a computer program which, when being executed by a processor, carries out the method according to any one of claims 1 to 4.
CN202110850465.6A 2021-07-27 2021-07-27 Byte code updating method and device and electronic equipment Pending CN113626051A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110850465.6A CN113626051A (en) 2021-07-27 2021-07-27 Byte code updating method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110850465.6A CN113626051A (en) 2021-07-27 2021-07-27 Byte code updating method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN113626051A true CN113626051A (en) 2021-11-09

Family

ID=78381063

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110850465.6A Pending CN113626051A (en) 2021-07-27 2021-07-27 Byte code updating method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN113626051A (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080172656A1 (en) * 2007-01-16 2008-07-17 Sun Microsystems, Inc. Processing engine for enabling a set of code intended for a first platform to be executed on a second platform
US20080172658A1 (en) * 2007-01-16 2008-07-17 Sun Microsystems, Inc. Mechanism for enabling a set of code intended for a first platform to be executed on a second platform
US20130179868A1 (en) * 2007-05-06 2013-07-11 Compuware Corporation System And Method For Extracting Instrumentation Relevant Inheritance Relationships For A Distributed, Inheritance Rule Based Instrumentation System
CN109445807A (en) * 2017-08-28 2019-03-08 腾讯科技(深圳)有限公司 Realize the method, apparatus and computer readable storage medium of application program update
CN110716859A (en) * 2019-08-30 2020-01-21 平安普惠企业管理有限公司 Method for automatically pushing test cases for modified codes and related device
CN111638907A (en) * 2020-04-20 2020-09-08 北京达佳互联信息技术有限公司 Method, device, terminal and storage medium for replacing third-party code segment
US10884764B1 (en) * 2019-07-18 2021-01-05 International Business Machines Corporation Optimizing managed runtime applications for serverless environments
CN113157296A (en) * 2021-04-27 2021-07-23 北京达佳互联信息技术有限公司 Compiled file updating method, device, server and storage medium

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080172656A1 (en) * 2007-01-16 2008-07-17 Sun Microsystems, Inc. Processing engine for enabling a set of code intended for a first platform to be executed on a second platform
US20080172658A1 (en) * 2007-01-16 2008-07-17 Sun Microsystems, Inc. Mechanism for enabling a set of code intended for a first platform to be executed on a second platform
US20130179868A1 (en) * 2007-05-06 2013-07-11 Compuware Corporation System And Method For Extracting Instrumentation Relevant Inheritance Relationships For A Distributed, Inheritance Rule Based Instrumentation System
CN109445807A (en) * 2017-08-28 2019-03-08 腾讯科技(深圳)有限公司 Realize the method, apparatus and computer readable storage medium of application program update
US10884764B1 (en) * 2019-07-18 2021-01-05 International Business Machines Corporation Optimizing managed runtime applications for serverless environments
CN110716859A (en) * 2019-08-30 2020-01-21 平安普惠企业管理有限公司 Method for automatically pushing test cases for modified codes and related device
CN111638907A (en) * 2020-04-20 2020-09-08 北京达佳互联信息技术有限公司 Method, device, terminal and storage medium for replacing third-party code segment
CN113157296A (en) * 2021-04-27 2021-07-23 北京达佳互联信息技术有限公司 Compiled file updating method, device, server and storage medium

Similar Documents

Publication Publication Date Title
CN113342345A (en) Operator fusion method and device of deep learning framework
CN112506602B (en) Page generation method and device, electronic equipment and computer readable medium
CN112199007A (en) Menu display method and device, electronic equipment and storage medium
CN114021156A (en) Method, device and equipment for organizing vulnerability automatic aggregation and storage medium
CN112015468A (en) Interface document processing method and device, electronic equipment and storage medium
CN112506581A (en) Method and device for rendering small program, electronic equipment and readable storage medium
CN114816393A (en) Information generation method, device, equipment and storage medium
CN112947916A (en) Method, device, equipment and storage medium for realizing online canvas
CN114168119B (en) Code file editing method, device, electronic equipment and storage medium
CN113626051A (en) Byte code updating method and device and electronic equipment
CN113360689B (en) Image retrieval system, method, related device and computer program product
CN115309730A (en) Data auditing method and device, electronic equipment and storage medium
CN112799642B (en) Method, apparatus, device and storage medium for processing data
CN115102948A (en) Automatic downloading method, device and equipment of map tiles and storage medium
CN113138760A (en) Page generation method and device, electronic equipment and medium
CN114327271B (en) Lifecycle management method, apparatus, device and storage medium
CN116521199B (en) Component upgrading method, device, equipment and storage medium
CN112528291B (en) Code auditing method and device based on knowledge graph
CN115454480A (en) Data updating method, device and system, vehicle and electronic equipment
CN116467080A (en) Cloud computing resource supply management method, device and equipment
CN115146201A (en) Page time cheating screening method and device, electronic equipment and medium
CN113722344A (en) Data production method, data production device, electronic device, storage medium, and program product
CN115329999A (en) Operation and maintenance task processing method, device, platform and storage medium
CN115202538A (en) Menu configuration method and device, electronic equipment and storage medium
CN113961775A (en) Data visualization method and device, electronic equipment and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination