Inline implementation method and device, electronic device, storage medium and program product

By obtaining and generating the class and method node relationship of the inline method, replacing method instructions, and realizing Java semantic inlining, it solves the time-consuming problem of program running caused by Java method inlining and reduces the calling overhead.

CN114003317BActive Publication Date: 2024-09-20BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111272867.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-29
Publication Date
2024-09-20
Estimated Expiration
2041-10-29

AI Technical Summary

Technical Problem

Java method inlining does not support semantic inlining, causing the virtual machine stack to enter and pop out frequently, increasing program running time.

Method used

By obtaining the configuration information, the corresponding relationship between the class with the inline method and the method node of the inline method is generated, the bytecode manipulation framework is used to traverse the method instructions in the class file, and the calling instructions are replaced to achieve inlining in Java semantics .

Benefits of technology

It reduces program running call overhead, realizes Java semantic inlining, and solves the time-consuming problem of program running caused by method inlining.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114003317B
    Figure CN114003317B
Patent Text Reader

Abstract

The present disclosure relates to an inline implementation method and device, electronic device, storage medium and program product, and relates to the field of computer technology. The method includes: obtaining configuration information, wherein the configuration information includes a class with an inline method and a corresponding inline method; obtaining a class file of a class with an inline method in the configuration information, and obtaining a method node of the inline method in the configuration information through a bytecode manipulation framework; generating a correspondence between a class with an inline method and a method node of the inline method; traversing the method instructions in the class file through the bytecode manipulation framework, if the bytecode instruction in the method instruction is a call instruction, and the class and method corresponding to the method instruction belong to a corresponding relationship, then obtaining a method node corresponding to the method instruction, and replacing the method instruction with the method node. The method can implement Java semantic inlining and solve the problem of time-consuming program operation caused by method inlining in related technologies.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to an inline implementation method and device, an electronic device, a storage medium, and a program product. Background Art

[0002] Java method inlining is a technique that "copies" the caller function code to the caller function to reduce the function call overhead. In related technologies, Java does not support semantic inlining, and the judgment of inline methods needs to be made by the virtual machine. When a method is not marked as an inline method by the virtual machine, calling it with a normal method will cause frequent entry and pop-up of the virtual machine stack, increasing the program running time.

[0003] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention

[0004] The present disclosure provides an inline implementation method and device, electronic device, storage medium and program product to at least solve the problem of program running time consumption caused by method inline in the related art. The technical solution of the present disclosure is as follows:

[0005] According to one aspect of an embodiment of the present disclosure, an inline implementation method is provided, comprising: obtaining configuration information, the configuration information comprising a class with an inline method and a corresponding inline method; obtaining a class file of the class with the inline method in the configuration information, and obtaining a method node of the inline method in the configuration information through a bytecode manipulation framework; generating a correspondence between the class with the inline method and the method node of the inline method; traversing the method instructions in the class file through the bytecode manipulation framework, and if the bytecode instruction in the method instruction is a call instruction, and the class and method corresponding to the method instruction belong to the correspondence, obtaining a method node corresponding to the method instruction, and replacing the method instruction with the method node.

[0006] In one embodiment of the present disclosure, the method also includes: querying the inline method through an annotation processor, and determining the class with the inline method based on the inline method; using the class name of the class with the inline method as an index, and using the method signatures of one or more of the inline methods contained in the class with the inline method as a value to generate the configuration information.

[0007] In one embodiment of the present disclosure, the generating of the correspondence between the class with the inline method and the method node of the inline method includes: taking the class name of the class with the inline method as an index, taking one or more method nodes of the inline method contained in the class with the inline method as a value, and storing as Map data.

[0008] In one embodiment of the present disclosure, if the bytecode instruction in the method instruction is a call instruction, and the class and method corresponding to the method instruction belong to the corresponding relationship, then the method node corresponding to the method instruction is obtained, and the method instruction is replaced with the method node, including: judging whether the bytecode instruction in the method instruction is a call instruction, and the class name and method name following the method instruction belong to the stored Map data; if so, querying the method node corresponding to the method instruction in the stored Map data according to the class name and method name following the method instruction, and then replacing the method instruction with the instruction in the queried method node.

[0009] In one embodiment of the present disclosure, the inline method has an inline annotation mark.

[0010] In one embodiment of the present disclosure, the inline method is a static method.

[0011] According to another aspect of an embodiment of the present disclosure, an inline implementation device is provided, including: a configuration module, configured to obtain configuration information, the configuration information including a class with an inline method and a corresponding inline method; an acquisition module, configured to obtain a class file of the class with an inline method in the configuration information, and obtain a method node of the inline method in the configuration information through a bytecode manipulation framework; a generation module, configured to generate a correspondence between the class with an inline method and the method node of the inline method; a replacement module, configured to traverse the method instructions in the class file through the bytecode manipulation framework, and if the bytecode instruction in the method instruction is a call instruction, and the class and method corresponding to the method instruction belong to the correspondence, then obtain the method node corresponding to the method instruction, and replace the method instruction with the method node.

[0012] In one embodiment of the present disclosure, the configuration module is configured to: query the inline method through an annotation processor, and determine the class with the inline method based on the inline method; use the class name of the class with the inline method as an index, and use the method signatures of one or more inline methods contained in the class with the inline method as a value to generate the configuration information.

[0013] In one embodiment of the present disclosure, the generation module is configured to: use the class name of the class with inline methods as an index, use one or more method nodes of the inline methods contained in the class with inline methods as values, and store as Map data.

[0014] In one embodiment of the present disclosure, the replacement module is configured to: determine whether the bytecode instruction in the method instruction is a call instruction, and whether the class name and method name following the method instruction belong to the stored Map data; if so, then based on the class name and method name following the method instruction, query the method node corresponding to the method instruction in the stored Map data, and then replace the method instruction with the instruction in the queried method node.

[0015] In one embodiment of the present disclosure, the inline method has an inline annotation mark.

[0016] In one embodiment of the present disclosure, the inline method is a static method.

[0017] According to another aspect of an embodiment of the present disclosure, there is provided an electronic device, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the above-mentioned inline implementation method.

[0018] According to another aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the above-mentioned inline implementation method.

[0019] According to another aspect of an embodiment of the present disclosure, a computer program product is provided, including a computer program / instruction, and when the computer program / instruction is executed by a processor, the above-mentioned inline implementation method is implemented.

[0020] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects: configuration information including classes with inline methods and inline methods can be obtained, and then the class file of the class with inline methods can be analyzed by using the bytecode manipulation framework to obtain the method node of the inline method, and a correspondence between the class with inline methods and the method node of the inline method is generated. In this way, when traversing the method instructions in the class file, the method instructions that need to be replaced are determined in combination with the generated correspondence, and then the method nodes of the inline method are used to replace the method instructions, thereby realizing Java semantic inlining and solving the problem of time-consuming program running caused by method inlining in related technologies.

[0021] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.

[0023] Figure 1 The figure is a flow chart showing an inline implementation method according to an exemplary embodiment.

[0024] Figure 2 The figure is a flowchart of generating configuration information according to an exemplary embodiment.

[0025] Figure 3 This is the data structure diagram of the generated Map data.

[0026] Figure 4 The present invention is a flowchart showing the analysis of method instructions in a class file according to an exemplary embodiment.

[0027] Figure 5 is a flowchart of an inline implementation method according to yet another exemplary embodiment.

[0028] Figure 6 The figure is a block diagram of an inline implementation device according to an exemplary embodiment.

[0029] Figure 7 The figure is a structural block diagram of an inline implementation device according to an exemplary embodiment. DETAILED DESCRIPTION

[0030] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.

[0031] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0032] The method provided in the embodiments of the present disclosure can be executed by any type of electronic device, such as a server or a terminal device, or the interaction between a server and a terminal device. The terminal device and the server can be directly or indirectly connected via wired or wireless communication, and this application does not limit this.

[0033] Among them, the server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), as well as big data and artificial intelligence platforms.

[0034] The terminal device can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited to these.

[0035] Figure 1 FIG. 1 is a flow chart showing an inline implementation method according to an exemplary embodiment. Figure 1 As shown, the inline implementation method includes the following steps.

[0036] In step S110, configuration information is obtained, wherein the configuration information includes classes having inline methods and corresponding inline methods.

[0037] An inline method is a method that needs to be inlined in a Java file. If a method is an inline method, the code of the method needs to be "copied" to the calling function. In the disclosed embodiment, the inline method is a static method. Therefore, the inline method belongs to the class, not the object, and the inline method can be called by the class name.method name before the object is instantiated.

[0038] A class with inline methods means that the class contains methods that need to be inlined. For example, class1, class2, and class3 are classes with inline methods, and the methods that need to be inlined in class1 are method1 and method4, the methods that need to be inlined in class2 are method2 and method3, and the method that needs to be inlined in class3 is method5. Then the configuration information includes classes class1, class2, and class3, as well as methods method1, method2, method3, method4, and method5.

[0039] In step S120, the class file of the class having the inline method in the configuration information is obtained, and the method node of the inline method in the configuration information is obtained through a bytecode manipulation framework.

[0040] The class file is a file generated by compiling a Java file, also known as a bytecode file. After obtaining the class with inline methods in the configuration information, the class file can be traversed to obtain the class file of the class with inline methods. Then, the class file of the class with inline methods can be analyzed using ASM (i.e., bytecode manipulation framework) to obtain the methodnode (i.e., method node) of the inline method in the configuration information. The specific implementation can be to customize the gradle (i.e., an open source tool for project automation construction based on the concepts of Apache Ant and Apache Maven) plug-in, and use the gradle plug-in to manipulate the class file of the class with inline methods through the object model access mode in ASM, and the class file can obtain the methodnode through the classnode, so the methodnode of the inline method recorded in the configuration information can be obtained. Among them, methodnode has the attribute InsnList, which is a two-way linked list object that contains the byte instruction sequence of the storage method.

[0041] In step S130, a correspondence between the class having the inline method and the method node of the inline method is generated.

[0042] After obtaining the methodnode of the inline method and the class with the inline method, a correspondence between the class with the inline method and the methodnode of the inline method can be generated. For example, the methods that need to be inlined in class1 include method1 and method4. Through step S120, the methodnode of method1 and the methodnode of method4 can be obtained, so the correspondence between class1 and the methodnode of method1 and the methodnode of method4 can be generated.

[0043] In step S140, the method instructions in the class file are traversed through the bytecode manipulation framework. If the bytecode instruction in the method instruction is a call instruction, and the class and method corresponding to the method instruction belong to the corresponding relationship, the method node corresponding to the method instruction is obtained, and the method instruction is replaced by the method node.

[0044] Traverse the class file and use ASM to traverse the method instructions of all methods in the class file. If the bytecode instruction in a method instruction is a call instruction, it means that the method is a call method. In this case, if the corresponding relationship generated in step S130 includes the class and method corresponding to the method instruction, it means that method inlining needs to be performed, so the methodnode corresponding to the method instruction can be obtained, and the method instruction can be replaced by the methodnode.

[0045] The Java inline implementation method provided by the embodiment of the present disclosure can obtain the configuration information including the class with the inline method and the inline method, and then use ASM to analyze the class file of the class with the inline method to obtain the methodnode of the inline method, and generate a correspondence between the class with the inline method and the methodnode of the inline method. In this way, when traversing the method instructions in the class file, the method instruction that needs to be replaced is determined in combination with the generated correspondence, and then the methodnode of the inline method is used to replace the method instruction, thereby realizing Java semantic inlining, solving the problem of program running time consumption caused by method inlining in the related technology, reducing the number of called methods, and reducing the program running call overhead.

[0046] In an exemplary embodiment, the inline implementation method may further include generating configuration information. Figure 2 FIG. 1 is a flow chart showing a method of generating configuration information according to an exemplary embodiment. Figure 2 As shown, the steps of generating configuration information may include:

[0047] Step S210, querying the inline method through the annotation processor, and then determining the class having the inline method according to the inline method.

[0048] Step S220: Generate the configuration information by taking the class name of the class having the inline method as an index and the method signatures of one or more inline methods contained in the class having the inline method as a value.

[0049] During the coding period of a Java file, an inline annotation can be used to mark the method that needs to be inlined, such as marking the method that needs to be inlined with the @Inline annotation, so that during the compilation period, the annotation processor can query the method with the annotation mark. Therefore, in the embodiment of the present disclosure, the inline method has an inline annotation mark.

[0050] The annotation processor can be understood as a Java program that can be used to parse annotations during the compilation of a Java file. When a Java file is compiled into a bytecode file, the method with an inline annotation mark in the Java file can be parsed by the annotation processor. That is to say, the inline method can be queried through the annotation processor, and then the class to which the inline method belongs can be determined, that is, the class with the inline method can be determined. Then, configuration information can be generated with the class name of the class with the inline method as the index and the method signature of the inline method contained in the class with the inline method as the value. Among them, the method signature consists of the method name and a parameter list (that is, the order and type of the method parameters).

[0051] For example, if methods method1, method2, method3, method4, and method5 are inline methods, then during the coding of the Java file, methods method1, method2, method3, method4, and method5 can be marked with the @Inline annotation. When coding the Java file, the annotation processor will query the methods method1, method2, method3, method4, and method5 marked with the @Inline annotation. In addition, it can be determined that methods method1 and method4 belong to class class1, methods method2 and method3 belong to class class2, and method5 belongs to class class3. Therefore, the classes with inline methods are class1, class2, and class3. Finally, generate configuration information with the class name of class1 as the index and the method signatures of the inline methods method1 and method4 contained in class1 as the value; generate configuration information with the class name of class2 as the index and the method signatures of the inline methods method2 and method3 contained in class2 as the value; and generate configuration information with the class name of class3 as the index and the method signature of the inline method method5 contained in class3 as the value.

[0052] In the related art, a virtual machine is required to perform inline judgment, while in the embodiments of the present disclosure, during the Java file encoding period, inline annotations are used to mark methods that need to be inlined. In this way, during the Java file compilation period, the methods that need to be inlined are obtained through the annotation processor, and then a configuration file including a class with an inline method and the inline method is generated, so that the configuration file can be used to implement Java semantic inlining later.

[0053] In an exemplary embodiment, step S130 of generating the correspondence between the class with the inline method and the methodnode of the inline method may include: taking the class name of the class with the inline method as an index, taking the methodnode of one or more inline methods contained in the class with the inline method as a value, and storing as Map data.

[0054] Figure 3 This is the data structure diagram of the generated Map data. Figure 3In the example, method1, method2, method3, method4 and method5 are inline methods, and class1, class2 and class3 are classes with inline methods. It can be seen that class1 corresponds to the method nodes of method1 and method4, class2 corresponds to the method nodes of method2 and method3, and class3 corresponds to the method node of method5. In other words, through class1, you can quickly query the method nodes of method1 and method4, through class2, you can quickly query the method nodes of method2 and method3, and through class3, you can quickly query the method node of method5.

[0055] In the disclosed embodiment, Map data can be stored with the class name of the class having the inline method as the index and the methodnode of the inline method contained in the class having the inline method as the value. Since Map data is a key-value pair data type with an extremely fast search speed, instruction replacement can be performed according to the stored Map data to quickly find the corresponding method node, further reducing the program running time.

[0056] Figure 4 FIG. 1 is a flowchart showing the analysis of method instructions in a class file according to an exemplary embodiment. Figure 4 As shown, the steps of analyzing the method instructions in the class file may include:

[0057] Step S410, determining whether the bytecode in the method instruction is a call instruction, if so, executing step S420;

[0058] Step S420, determining whether the class name and method name following the method instruction belong to the stored Map data, if so, executing step S430;

[0059] Step S430, according to the class name and method name following the method instruction, the method node corresponding to the method instruction is searched in the stored Map data, and then the method instruction is replaced with the instruction in the searched method node.

[0060] ASM traverses the method instructions in the class file, that is, analyzes the instruction contents of all methods in the class file one by one. If the bytecode in a method instruction is a call instruction invokestatic, and the class name and method name following the method instruction belong to the stored Map data, it means that the method function code is "copied". Therefore, the methodnode corresponding to the method instruction can be found in the stored Map data and then replaced. Figure 3Take the Map data shown as an example. If the bytecode in a method instruction Method Instruction1 is a call instruction invokestatic, and the class name behind it is class1 and the method name is method1, then delete the instruction statement and add the instruction in methodnode of method1 to the position of the deleted instruction. If the class name behind a method instruction Method Instruction2 is class1 and the method name is method2, since it is not stored in the Map data, there is no need to replace the instruction.

[0061] Figure 5 FIG. 1 is a flowchart of a Java inline implementation method according to another exemplary embodiment. Figure 5 As shown, the inline implementation method includes the following steps:

[0062] Step S510, querying the inline method in the Java file through the annotation processor, and then determining the class with the inline method according to the queried inline method, wherein the queried inline method is a static method;

[0063] Step S520, generating configuration information by taking the class name of the class having the inline method as an index and taking the method signatures of one or more inline methods contained in the class having the inline method as a value;

[0064] Step S530, traversing the Java class files through the gradle plug-in and ASM, obtaining the class files of the classes having the inline methods in the configuration information, and obtaining the method nodes of the inline methods in the configuration information;

[0065] Step S540, storing the data as Map data by taking the class name of the class with the inline method as an index and taking the method nodes of one or more inline methods contained in the class with the inline method as values;

[0066] Step S550, traversing method instructions in the Java class file through ASM;

[0067] Step S560, determining whether the bytecode instruction in the method instruction is a call instruction invokestatic, and whether the class name and method name following the method instruction belong to the stored Map data, if so, executing step S570, if not, executing step S580;

[0068] Step S570, according to the class name and method name following the method instruction, in the stored Map data, a method node corresponding to the method instruction is searched, and then the method instruction is replaced with the instruction in the searched method node;

[0069] Step S580, determining whether to traverse all method instructions in the Java class file. If all method instructions in the Java class file are traversed, the process ends and Java inlining is implemented. Otherwise, the traversal continues.

[0070] During the coding period of Java files, inline annotation tags can be used to mark static methods that need to be inlined. Therefore, the inline methods in the Java file (that is, the static methods that need to be inlined) can be queried through the annotation processor, and the class with the inline method can be obtained. Then, the gradle plug-in and ASM can be used to modify the class file to achieve Java semantic inlining, avoiding inlining through the virtual machine, reducing the frequent entry and exit of the virtual machine stack, reducing the number of called methods, and reducing the program running call overhead.

[0071] The following description uses the inline method as the sum of two parameters. The inline implementation method provided in the embodiment of the present disclosure is also applicable to business data in other business scenarios, and the present disclosure does not limit this.

[0072]

[0073]

[0074] As shown in the above code, class T is defined to contain method add, which is used to sum parameters a and b and return c, and the inline annotation mark @Inline is added to method add. Therefore, during the compilation period, the annotation processor is used to query the method add and the class T to which the method add belongs, and then the corresponding configuration information can be generated with the class name of class T as the index and the method signature of the method add contained in class T as the value. Then, through the gradle plug-in and ASM, the class file of class T is obtained, and then the methodnode of the method add is obtained. Then, the class name of class T is indexed and the methodnode of the method add contained in class T is used as the value, and it is stored as Map data. In this way, when traversing the method instructions in the class file of class User, it is determined that the method instruction is a call instruction, and the class corresponding to the method instruction is T and the corresponding method is add. Therefore, the method instruction can be replaced with the instruction in the methodnode of the method add, so the code int c=T.add(a,b) will become c=a+b after compilation, avoiding the method call and realizing method inlining.

[0075] Figure 6 is a block diagram of an inline implementation device according to an exemplary embodiment. Figure 6 The inline implementation device 600 includes a configuration module 610, an acquisition module 620, a generation module 630 and a replacement module 640.

[0076] The configuration module 610 is configured to obtain configuration information, wherein the configuration information may include: a class with an inline method and a corresponding inline method.

[0077] The acquisition module 620 is configured to acquire the class file of the class having the inline method in the configuration information, and obtain the methodnode of the inline method in the configuration information through ASM.

[0078] The generating module 630 is configured to generate a correspondence between the class having the inline method and the methodnode of the inline method.

[0079] The replacement module 640 is configured to traverse the method instructions in the class file through ASM. If the bytecode instruction in the method instruction is a call instruction, and the class and method corresponding to the method instruction are in a corresponding relationship, then the methodnode corresponding to the method instruction is obtained and the methodnode is used to replace the method instruction.

[0080] In an exemplary embodiment, the configuration module 610 can also be configured to: query the inline method through the annotation processor, and determine the class with the inline method based on the inline method; use the class name of the class with the inline method as an index, and use the method signatures of one or more inline methods contained in the class with the inline method as a value to generate configuration information.

[0081] In an exemplary embodiment, the generation module 630 may also be configured to: use the class name of the class with the inline method as an index, and use the method nodes of one or more inline methods contained in the class with the inline method as values, and store as Map data.

[0082] In an exemplary embodiment, the replacement module 640 can also be configured to: determine whether the bytecode instruction in the method instruction is a call instruction, and the class name and method name following the method instruction belong to the stored Map data; if so, then based on the class name and method name following the method instruction, query the method node corresponding to the method instruction in the stored Map data, and then use the instructions in the queried method node to replace the method instruction.

[0083] In an exemplary embodiment, the inline method has an inline annotation marker.

[0084] In an exemplary embodiment, the inline method is a static method.

[0085] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0086] Figure 7It is a structural block diagram of an inline implementation device according to an exemplary embodiment. It should be noted that the electronic device shown in the figure is only an example and should not bring any limitation to the function and scope of use of the embodiment of the present invention.

[0087] Refer to the following Figure 7 An electronic device 700 according to this embodiment of the present invention will be described. Figure 7 The electronic device 700 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0088] like Figure 7 As shown, the electronic device 700 is in the form of a general computing device. The components of the electronic device 700 may include but are not limited to: at least one processing unit 710, at least one storage unit 720, and a bus 730 connecting different system components (including the storage unit 720 and the processing unit 710).

[0089] The storage unit stores program codes, which can be executed by the processing unit 710, so that the processing unit 710 performs the steps according to various exemplary embodiments of the present invention described in the above “Exemplary Method” section of this specification. For example, the processing unit 710 can perform the following steps: Figure 1 In step S110 shown in the figure, configuration information is obtained, and the configuration information includes a class with an inline method and a corresponding inline method; in step S120, a class file of the class with an inline method in the configuration information is obtained, and a method node of the inline method in the configuration information is obtained through a bytecode manipulation framework; in step S130, a correspondence is generated between the class with an inline method and the method node of the inline method; in step S140, a method instruction in the class file is traversed through the bytecode manipulation framework, and if the bytecode instruction in the method instruction is a call instruction, and the class and method corresponding to the method instruction belong to the correspondence, a method node corresponding to the method instruction is obtained, and the method instruction is replaced with the method node.

[0090] The storage unit 720 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 7201 and / or a cache storage unit 7202 , and may further include a read-only storage unit (ROM) 7203 .

[0091] The storage unit 720 may also include a program / utility 7204 having a set (at least one) of program modules 7205, such program modules 7205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.

[0092] Bus 730 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.

[0093] The electronic device 700 may also communicate with one or more external devices 800 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 700, and / or communicate with any device that enables the electronic device 700 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 750. Furthermore, the electronic device 700 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 770. As shown, the network adapter 770 communicates with other modules of the electronic device 700 via a bus 730. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 700, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.

[0094] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.

[0095] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the above method of the present specification is stored. In some possible implementations, various aspects of the present invention can also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary embodiments of the present invention described in the above "Exemplary Method" section of the present specification.

[0096] The program product for implementing the above method according to the embodiment of the present invention may adopt a portable compact disk read-only memory (CD-ROM) and include program code, and may be run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto, and in this document, a readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, apparatus, or device.

[0097] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0098] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0099] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.

[0100] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).

[0101] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.

[0102] In addition, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.

[0103] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the implementation of the present disclosure.

[0104] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any modification, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the appended claims.

[0105] It should be understood that the present disclosure is not limited to the exact structures that have been 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

1. An inline implementation method, characterized in that: include: Acquire configuration information, the configuration information including a class having an inline method and a corresponding inline method; the inline method has an inline annotation mark; Obtaining a class file of the class having the inline method in the configuration information, and obtaining a method node of the inline method in the configuration information through a bytecode manipulation framework; Generate a correspondence between the class having the inline method and the method node of the inline method; Traversing the method instructions in the class file through the bytecode manipulation framework, if the bytecode instruction in the method instruction is a call instruction, and the class and method corresponding to the method instruction belong to the corresponding relationship, obtaining the method node corresponding to the method instruction, and replacing the method instruction with the method node; The method further includes: querying the inline method having the inline annotation mark through an annotation processor, and determining the class having the inline method according to the inline method; using the class name of the class having the inline method as an index, and using the method signatures of one or more inline methods contained in the class having the inline method as a value, to generate the configuration information.

2. The method according to claim 1, characterized in that The generating a correspondence between the class having the inline method and the method node of the inline method includes: The data is stored as Map data with the class name of the class having the inline method as an index and one or more method nodes of the inline method contained in the class having the inline method as a value.

3. The method according to claim 2, characterized in that If the bytecode instruction in the method instruction is a call instruction, and the class and method corresponding to the method instruction belong to the corresponding relationship, obtaining a method node corresponding to the method instruction, and replacing the method instruction with the method node includes: Determine whether the bytecode instruction in the method instruction is a call instruction, and whether the class name and method name following the method instruction belong to the stored Map data; If so, the method node corresponding to the method instruction is searched in the stored Map data according to the class name and method name following the method instruction, and the method instruction is then replaced with the instruction in the searched method node.

4. The method according to any one of claims 1 to 3, characterized in that: The inline method is a static method.

5. An inline implementation device, characterized in that: include: A configuration module is configured to obtain configuration information, wherein the configuration information includes a class having an inline method and a corresponding inline method; The inline method has an inline annotation marker; an acquisition module, configured to acquire a class file of a class having an inline method in the configuration information, and obtain a method node of the inline method in the configuration information through a bytecode manipulation framework; A generating module, configured to generate a corresponding relationship between the class having the inline method and the method node of the inline method; A replacement module is configured to traverse the method instructions in the class file through the bytecode manipulation framework, and if the bytecode instruction in the method instruction is a call instruction, and the class and method corresponding to the method instruction belong to the corresponding relationship, obtain a method node corresponding to the method instruction, and replace the method instruction with the method node; Among them, the configuration module is configured to: query the inline method with the inline annotation mark through the annotation processor, and determine the class with the inline method according to the inline method; use the class name of the class with the inline method as an index, and use the method signature of one or more inline methods contained in the class with the inline method as a value to generate the configuration information.

6. The device according to claim 5, characterized in that The generation module is configured to: The data is stored as Map data with the class name of the class having the inline method as an index and one or more method nodes of the inline method contained in the class having the inline method as a value.

7. The device according to claim 6, characterized in that The replacement module is configured as follows: Determine whether the bytecode instruction in the method instruction is a call instruction, and whether the class name and method name following the method instruction belong to the stored Map data; if so, query the method node corresponding to the method instruction in the stored Map data according to the class name and method name following the method instruction, and then replace the method instruction with the instruction in the queried method node.

8. The device according to any one of claims 5 to 7, characterized in that: The inline method is a static method.

9. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the inline implementation method according to any one of claims 1 to 4. 10 . A computer-readable storage medium, when instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the inline implementation method according to any one of claims 1 to 4.

11. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the inline implementation method according to any one of claims 1 to 4 is implemented.