Method, device and electronic device for determining link of method call corresponding to business

By describing the method call relationship of application code through structured data, and automatically constructing a method call relationship tree, solving the problem of difficulty in monitoring and positioning the execution results of independent services in applications in the prior art, improving monitoring efficiency and accuracy.

CN112506923BActive Publication Date: 2025-06-06BEIJING SANKUAI ONLINE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

The prior art is difficult to efficiently monitor and locate the execution results of independent services in applications, making it difficult to quickly locate specific services and codes when an application occurs abnormally.

Method used

Through structured data, describe the class objects, method objects, their attribute information and method call relationships declared in the application code, automatically build a method call relationship tree to determine each method call link of the business.

Benefits of technology

Improves the efficiency of determining the method call link for specifying business module codes in the application, and reduces human errors and time-consuming compared to manual combing, and achieves rapid positioning and monitoring.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112506923B_ABST
    Figure CN112506923B_ABST
Patent Text Reader

Abstract

The present application discloses a method for determining a method call link for a corresponding service, which belongs to the field of computer technology and helps to improve the efficiency of determining a method call link for a specified service. The method comprises: describing the class objects declared in the application code, the method objects declared in each of the class objects, and the attribute information and method call relationship of each of the method objects through structured data; traversing the structured data, and determining the start call method object and the end call method object associated with different service identifiers according to the attribute information and service identifier of the method object; for each start call method object, based on the method call relationship described in the structured data, respectively constructing a call relationship tree associated with the specified service identifier; traversing the method call relationship tree associated with the specified service identifier, and determining each method call link of the service identified by the specified service identifier, so that the method call circuit of each service module in the application can be automatically determined.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computer technology, and in particular, to a method, device, electronic device, and computer-readable storage medium for determining a method call link corresponding to a service. Background Art

[0002] With the development of terminal application-based businesses, the pace of APP (Application) version updates has accelerated, and the hidden dangers brought by online application defects to business stability have become increasingly serious. It has become very important to monitor the availability of various business modules in online applications. Since many business modules are usually integrated in an application, each business module is implemented by executing several program code modules, and there are also situations where multiple business modules share a program code module, the code implementation of the application is very complicated. In the prior art, there is only monitoring of the overall operation stability of the application, and there is no monitoring method for the program execution results of independent businesses. However, as an application branch or functional module that implements an independent business, its stability is very important. Provide a method that can determine the composition of the business, so that when an exception occurs in the application, it is possible to quickly locate the specific business, or even the specific code of the business.

[0003] In the prior art, all methods of a business are found by manually combing the business logic and code logic, thereby determining the business and its execution information. The solution for determining the business in the prior art is not only inefficient, but also prone to errors. Summary of the invention

[0004] The embodiment of the present application provides a method for determining a method call link of a corresponding service, which helps to improve the efficiency of determining a method call link of a specified service module code in an application.

[0005] In order to solve the above problems, in a first aspect, an embodiment of the present application provides a method for determining a link for a corresponding service, including:

[0006] Describing class objects declared in the application code, method objects declared in each class object, and attribute information and method call relationships of each method object through structured data, wherein at least part of the attribute information of the method object includes: an identifier for indicating that the method object is a start call method or an end call method, and a service identifier associated with the method object;

[0007] Traversing the structured data, and determining, according to the attribute information of the method object and the service identifier, a start calling method object and an end calling method object associated with different service identifiers respectively;

[0008] For each of the start calling method objects, based on the method calling relationship described in the structured data, respectively construct a method calling relationship tree associated with a specified service identifier, wherein the specified service identifier is the service identifier associated with the start calling method object;

[0009] The method call relationship tree associated with the specified service identifier is traversed to determine each method call link of the service identified by the specified service identifier.

[0010] In a second aspect, an embodiment of the present application provides a method for determining a service-related link call, including:

[0011] A program code structured processing module, used to describe the class objects declared in the application code, the method objects declared in each of the class objects, and the attribute information and method call relationship of each of the method objects through structured data, wherein at least part of the attribute information of the method objects includes: an identifier for indicating that the method object is a start call method or an end call method, and a service identifier associated with the method object;

[0012] A start and end calling method determination module, used for traversing the structured data, and determining the start calling method object and the end calling method object associated with different service identifiers according to the attribute information of the method object and the service identifier;

[0013] A method call relationship tree construction module, configured to respectively construct a method call relationship tree associated with a specified service identifier for each of the start call method objects based on the method call relationship described in the structured data, wherein the specified service identifier is the service identifier associated with the start call method object;

[0014] The method call link determination module is used to traverse the method call relationship tree associated with the specified service identifier and determine each method call link of the service identified by the specified service identifier.

[0015] In a third aspect, an embodiment of the present application further discloses an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method for implementing the corresponding service described in the embodiment of the present application calls a link determination method.

[0016] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the method for the corresponding service disclosed in the embodiment of the present application calls the steps of the link determination method.

[0017] The method for determining a method call link for a corresponding service disclosed in an embodiment of the present application uses structured data to describe class objects declared in an application code, method objects declared in each of the class objects, and attribute information and method call relationships of each of the method objects, wherein at least part of the attribute information of the method objects includes: an identifier for indicating that the method object is a start call method or an end call method, and a service identifier associated with the method object; traversing the structured data, and determining a start call method object and an end call method object associated with different service identifiers according to the attribute information and the service identifier of the method object; for each start call method object, based on the method call relationship described in the structured data, constructing a method call relationship tree associated with a specified service identifier, wherein the specified service identifier is a service identifier associated with the start call method object; traversing the method call relationship tree associated with the specified service identifier, determining each method call link of the service identified by the specified service identifier, so that the method call circuit of each service module in the application can be automatically determined, and compared with manually combing through the method objects called by each service module in the prior art, the efficiency of determining the method call link of the specified service module code in the application is improved.

[0018] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0020] Figure 1 This is a flow chart of a method for determining a link for a method call corresponding to a service in Embodiment 1 of the present application;

[0021] Figure 2 is a schematic diagram of a method call relationship tree constructed in Example 1 of the present application;

[0022] Figure 3 This is a flow chart of a method for determining a link for a method call corresponding to a service in Embodiment 2 of the present application;

[0023] Figure 4This is one of the structural diagrams of the method call link determination device corresponding to the service of the third embodiment of the present application;

[0024] Figure 5 This is the second structural diagram of the method call link determination device corresponding to the service of the third embodiment of the present application;

[0025] Figure 6 A block diagram schematically shows an electronic device for executing the method according to the present application; and

[0026] Figure 7 A storage unit for holding or carrying a program code for implementing the method according to the present application is schematically shown. DETAILED DESCRIPTION

[0027] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0028] Embodiment 1

[0029] A method corresponding to a service disclosed in an embodiment of the present application calls a link determination method, such as Figure 1 As shown, the method includes: steps 110 to 140.

[0030] Step 110, describing the class objects declared in the application code, the method objects declared in each class object, and the attribute information and method call relationship of each method object through structured data.

[0031] Among them, the program code of the start calling method object of each service is pre-set with an identifier that identifies the method object as the start calling method and the corresponding service identifier, and the program code of the end calling method of each service is pre-set with an identifier that identifies the method object as the end calling method and the corresponding service identifier. In the embodiment of the present application, the service identifier can be a number, a string, or a combination of a number and a string, which is used to uniquely identify a service. In the embodiment of the present application, the generation method of the service identifier is not limited.

[0032] The attribute information of different method objects may be different. In the structured data, at least part of the attribute information of the method objects (such as the start call method object and the end call method object) includes: an identifier for indicating that the method object is a start call method or an end call method, and a service identifier associated with the method object. The identifier indicating that the method object is a start call method is determined based on the program code pre-inserted in the application code for marking the method object as a start call method; the identifier indicating that the method object is an end call method is determined based on the program code pre-inserted in the application code for marking the method object as an end call method.

[0033] The method for determining the method call link of the corresponding service described in the embodiment of the present application is applicable to application code written in an object-oriented development language, such as Java, Objective C, etc. The application code is usually composed of declaration codes of several classes, and the declaration code of each class further includes the definition of the attribute information of the class, the method declaration of the current class and the statement for calling the method of other classes. Among them, the method object can further call other methods or classes.

[0034] During the specific implementation of the present application, first, in the program code of the start calling method and the end calling method of each business in the application code of the target application, an identifier indicating that the method object is a start calling method or an end calling method, as well as a business identifier indicating that the method object is associated with, are manually embedded. Afterwards, using the method disclosed in the embodiment of the present application, in the application code corresponding to each business, in other called method objects, an identifier indicating that the method object is an intermediate calling method object is automatically inserted, or a business identifier indicating that the method object is associated with is automatically inserted, or an identifier indicating that the method object is an intermediate calling method object and a business identifier indicating that the method object is associated with are automatically inserted. Among them, the business identifier associated with the method object is the business identifier of the business that calls the method object.

[0035] In some embodiments of the present application, program code for marking a service identifier and / or program code for marking a method object as a start call method or an end call method can be inserted into the application code by inserting a macro definition. For example, a macro definition named "BMPNodeStart" is inserted into the application code to mark the method object into which the macro definition is inserted as the start call method of a certain service, and a macro definition named "BMPNodeEnd" is inserted into the application code to mark the method object into which the macro definition is inserted as the end call method of a certain service, that is, the macro name is used as the identifier of the method type (such as the start call method, the end call method). Furthermore, the service identifier is represented by the parameter of the macro definition.

[0036] In other embodiments of the present application, corresponding identifiers may be inserted into the start calling method and end calling method of each service in the application code in other ways, which is not limited in the embodiments of the present application and will not be listed one by one here.

[0037] Based on the application code inserted with the start calling method identifier, the end calling method identifier and the business identifier, all method calling relationships in the project of the target application can be obtained through the link collection tool.

[0038] In some embodiments of the present application, the description of the class objects declared in the application code, the method objects declared in each of the class objects, and the attribute information and method calling relationships of each of the method objects through structured data includes: describing the attribute information of the class objects declared in the application code, the method objects declared and / or called in each of the class objects, and the attribute information of each of the method objects, as well as the method calling relationships of each of the method objects through JSON (JavaScript Object Notation, a lightweight data exchange format) key-value pairs.

[0039] Take the application development project of iOS development environment as an example, wherein the program code file is a source file with the extension .m. Usually, each application project includes multiple .m source files (i.e., program code files). Each .m source file (i.e., program code file) includes one or more class objects that implement corresponding functions, declaration codes, implementation codes, call codes, etc. of method objects. Among them, the call code includes: the code for calling the method in the third-party library, the code for calling the method of the class object defined in this project, etc., and the declaration, call, etc. codes of the object meet certain programming specifications. Therefore, by analyzing the grammar and syntax of the code in each source file in the application project, the class objects, the business attributes of the class objects, the method objects of the class objects, the business attributes of each method object, the call relationship of the method objects, etc. included in each source file can be obtained. Further, by performing source code parsing, it can also be determined whether a certain method object is a start call method or an end call method. For the start call method or the end call method, it can also be further determined that the business identifier associated with the start call method or the end call method.

[0040] In some embodiments of the present application, the structured data is data recorded in the form of key-value pairs, wherein the key and value may be class object names, method object names, keywords, etc. For example, information such as class objects, business attributes of class objects (such as notification classes, etc.), method objects of class objects, business attributes of each method object (such as associated business identifiers), and calling relationships of method objects included in each source file are stored in a json file, and structured data in the form of key-value pairs are used to represent class objects, business attributes of class objects, method objects of class objects, business attributes of each method object, and calling relationships of method objects included in the source file. For example, by parsing the source code of the application, it can be obtained that the methods declared in the class object viewController include: func1, func2, and func3, wherein the method object func3 is the method of the class object getData, and the method calling relationship obtained by parsing can be expressed as follows:

[0041] {"viewController":{methods:

[0042] ["className":"viewController","invoke":

[0043] ["methodName":"func1",

[0044] "methodName": "func2",

[0045] {"className":"getData","methodName":"func3"}]]}.

[0046] Among them, className, invoke, and methodName are keywords. The keywords are used to indicate the method call relationship, as well as information such as data types. That is, the method call relationship is represented by the corresponding relationship of character strings. Similarly, the corresponding relationship between the business identifier associated with the method object and the category attribute of the method object (that is, the method object and the identifier indicating whether the method is a start call method or an end call method) can also be represented by a key-value pair.

[0047] For another example, if a method object is a start calling method for a business (for example, the code of the method object includes macro code such as "BMPNodeStart(@"business ID")"), or if a method object is an end calling method for a business (for example, the code of the method object includes macro code such as "BMPNodeEnd(@"business ID")"), the correspondence between the method object and the method type attribute information can be represented by a key-value pair of a method name string and a method type string (such as "nodetype": 0), where nodetype is a keyword indicating the method type and its value is the method type identifier. Similarly, for the start calling method and the end calling method of a business, the key-value pair representing the correspondence between the method object and the business identifier can also be obtained based on the source code.

[0048] According to this method, each source file of the application code (such as a file in .m format) can generate a corresponding structured data file (such as a file in .json format). In each structured data file, the calling relationship of the method object, the business identifier associated with some method objects (used to indicate which business method the method object implements) and the method type identifier (used to indicate whether the method object is a start calling method or an end calling method) are described in the form of a string mapping relationship.

[0049] Step 120, traverse the structured data, and determine the start call method object and the end call method object associated with different service identifiers according to the attribute information of the method object and the service identifier.

[0050] Next, all structured data files obtained through code analysis are further analyzed, and all method objects declared in the target application are determined by analyzing the structured data. For example, all method objects parsed from the source code of the target application are determined by traversing the key-value pairs in all .json files obtained in the above steps. Then, the start call method object and the end call method object among all the method objects parsed are determined based on whether the attribute information of each method object includes an identifier indicating that the method type is a start call method or an end call method.

[0051] Among the determined start calling method objects and end calling method objects, the start calling method objects and end calling method objects corresponding to the same business identifier are determined according to the business identifier corresponding to each method object described in the structured data. Since an application usually includes multiple business modules, there may be multiple entrances to a business module, and there may also be multiple exits from one business module to other business modules or to exit the application. Therefore, under normal circumstances, by executing this step, multiple groups of start calling method objects and end calling method objects can be determined, and each group of start calling method objects and end calling method objects corresponds to a business identifier, that is, each group of start calling method objects and end calling method objects belongs to the program code of a business module. Each group of start calling method objects and end calling method objects can include one or more start calling method objects, and one or more end calling method objects.

[0052] In some embodiments of the present application, structured data uses method name strings, class name strings, and method type identification strings in the application source code to represent the method calling relationships of method objects and the correspondence between method objects and business identifiers and method type identifiers. After executing the aforementioned steps, the method object names of all start calling methods and all end calling methods corresponding to each business identifier in the application source code can be obtained.

[0053] Step 130: for each of the start calling method objects, based on the method calling relationship described in the structured data, respectively construct a method calling relationship tree associated with the specified service identifier.

[0054] The designated service identifier is the service identifier associated with the start calling method object.

[0055] After determining the start call method objects and end call method objects associated with different service identifiers, for each service identifier, a method call relationship tree is constructed according to all the start call method objects and end call method objects associated with the service identifier. In some embodiments of the present application, for each of the start calling method objects, based on the method calling relationship described in the structured data, a method calling relationship tree associated with the specified business identifier is constructed respectively, including: for each of the start calling method objects, a root node is constructed according to the start calling method object; with the start calling method object as the current level method object, the following node construction sub-steps are executed: a calling method determination sub-step, based on the method calling relationship described in the structured data, determining each next level method object called by the current level method object; a child node construction sub-step, constructing a child node of the node corresponding to the current level method object according to each of the next level method objects; a jump judgment sub-step, in response to each of the next level method objects including a method object that does not belong to the end calling method object, the next level method objects that do not belong to the end calling method object are respectively used as the current level method objects, and jumping to execute the calling method determination sub-step and the child node construction sub-step until all of the next level method objects are the end calling method objects.

[0056] The following is a specific example of a specific scheme for constructing a method call relationship tree corresponding to a business identifier. As mentioned above, a business identifier can correspond to multiple start calling methods and multiple end calling methods, that is, there are multiple process branches in the execution of a business code. Accordingly, when constructing the method call relationship tree corresponding to the business identifier, a method call relationship tree is constructed for each start calling method, and multiple method call relationship trees can be obtained.

[0057] For a specific example, assume that the business identifier ID1 corresponds to M start calling methods and N end calling methods, the M start calling methods are represented as startFunc1, startFunc2, ..., startFuncM, and the N end calling methods are represented as endFunc1, endFunc2, ..., endFuncN, respectively, where M and N are integers greater than 1, and a root node of a method call relationship tree is constructed according to the start calling methods startFunc1, startFunc2, ..., startFuncM, respectively. Then, by traversing the method call relationship recorded in the structured data determined in the previous steps, child nodes of each root node are constructed according to the called method object until the called method object is traversed to one of the end calling methods endFunc1, endFunc2, ..., endFuncN, and a leaf node of the root node is constructed according to the traversed end calling method, thereby completing the construction of a branch of the method call relationship tree.

[0058] Further, when constructing the method call relationship tree corresponding to the start call method startFunc1 corresponding to the business identifier ID1, firstly construct the root node according to the start call method startFunc1, such as Figure 2 The root node 200 of the method call relationship tree in . Then, starting to call the method startFunc1 is used as the current layer node, and the child nodes of the current layer node (i.e., the root node) are constructed. In specific implementation, by traversing the structured data determined in the aforementioned steps, all methods called by the method object startFunc1 can be determined according to the key-value pairs describing the method call relationship of the method object startFunc1. In this embodiment, it is assumed that there are three method objects called by the determined method object startFunc1, which are represented as: func11, func12, and endFunc1. Next, the child nodes of the root node will be constructed according to the method objects func11, func12, and endFunc1, respectively, to obtain the child nodes corresponding to the method objects func11, func12, and endFunc1, such as Figure 2 The method calls the child nodes 210, 220 and 230 of the root node 200 of the relationship tree.

[0059] After constructing the child nodes of the current layer node, it is first necessary to determine whether the method objects corresponding to the child nodes of the current layer node are end-call method objects. If the method object corresponding to a child node is an end-call method object, it means that the method object does not continue to call other method objects, and there is no need to continue traversing the call relationship of the method object corresponding to the child node, such as the method object endFunc1 corresponding to the child node 210. If the method object corresponding to a child node is not an end-call method object, it means that in the program code, the method object has called other method objects, and it is necessary to continue traversing the call relationship of the method object corresponding to the child node, such as the method objects func11 and func12 corresponding to the child nodes 220 and 230.

[0060] Specifically for this embodiment, the method objects func11 and func12 corresponding to the child nodes 220 and 230 are not the end-calling method objects, and therefore it is necessary to continue traversing the method calling relationship of the method objects func11 and func12.

[0061] Next, take child nodes 220 and 220 as the current layer nodes respectively, and determine all methods called by method object func11 according to the key-value pairs describing the method call relationship of method object func11 by traversing the structured data determined in the previous steps, and construct child nodes of node 220 according to all methods called by method object func11, such as Figure 2 Nodes 2201 and 2202 in the method object func12; according to the key-value pair describing the method call relationship of the method object func12, determine all methods called by the method object func12, and construct the child nodes of node 230 according to all methods called by the method object func12, such as Figure 2 Nodes 2301 and 2302 in . So far, the construction of another layer of nodes of the method call relationship tree has been completed.

[0062] Next, after constructing the child nodes of the current layer node, it is also necessary to determine whether the method objects corresponding to the child nodes of the current layer node are end call method objects. For example, determine whether the method objects corresponding to nodes 2201, 2202, 2301 and 2302 are end call method objects, and determine whether to continue to construct the next layer of nodes based on the judgment results. Specifically for this embodiment, assuming that the method objects corresponding to nodes 2201, 2202, 2301 and 2302 are all end call method objects (for example, the method objects corresponding to nodes 2201, 2202, 2301 and 2302 are end call method objects, respectively), it means that the method objects called layer by layer by the start call method startFunc1 have been traversed and constructed into the method call relationship tree corresponding to the start call method startFunc1.

[0063] At this point, the method call relationship tree corresponding to the start calling method startFunc1 is completed. According to this method, the method call relationship trees corresponding to the start calling methods startFunc2, ..., startFuncM are constructed respectively, and M method call relationship trees corresponding to the business identifier ID1 can be obtained. If there are N end calling method objects corresponding to the business identifier ID1, then these N end calling method objects will correspond to the leaf nodes of the above M method call relationship trees, where each method call relationship tree may contain multiple leaf nodes, that is, each method call relationship tree may include multiple method call links.

[0064] In some embodiments of the present application, a key-value pair is constructed by combining a string and a description keyword to describe the method call relationship, wherein the string can be a method object name, a class object name, or generated based on the method object name, a class object name; the keyword is a description word for the call relationship, affiliation, etc. For example, the structured data generated by the aforementioned steps will use a key-value pair such as ["className":"getData","methodName":"func3"] to describe the method object func3 declared in the class object getData, that is, the method object contained in the class object is described by the key-value correspondence between the class object name and the method object name. For a general class-based method call source code, the structured data generated by the aforementioned steps will use a specified keyword (such as "invoke") to describe the method call relationship between the method object and the class object. In some embodiments of the present application, based on the method call relationship described in the structured data, the step of determining each next-level method object called by the current-level method object includes any one or more of the following methods.

[0065] The first method is to determine the class object name and method object name called by the current-level method object based on the structured data, and then determine the method object to which the method object name corresponding to the class object name belongs according to the structured data as the method object called by the current-level method object. For example, for the current-level method object func1, if the structured data is traversed to include a method name mapping relationship with "func1" as the value, such as the key-value pair "methodName": "func1" {"invoke": [["className": "viewController", "methodName": "func2"]], then further search for the key corresponding to the keyword "invoke", and determine the method called by the method object "func1" from the value corresponding to "invoke", such as determining that the current-level method object func1 calls the method object func2 in the class object viewController, and then use the method object func2 as the method object called by the current-level method object func1.

[0066] The second method is to determine the class object name corresponding to the page to which the calling method jumps based on the structured data, and then determine the method objects to which all method object names corresponding to the class object name belong based on the structured data as the method objects called by the current level method object. For example, for the current level method object func1, if the structured data traversed includes the key-value pair "methodName" = "func1", and the key-value pair data after the key-value pair "methodName" = "func1" includes keywords indicating the page jump relationship, then the class object name corresponding to the page to which the jump is based on the key-value pair containing the keywords indicating the page jump relationship is further determined. Afterwards, the category declaration key-value pairs with the class object name as the key are traversed in the structured data to obtain the class object declaration of the category name that has a method object.

[0067] The third method is to determine all method objects that receive notifications sent by the current-level method object according to the structured data as method objects called by the current-level method object. For another example, when the method object func1 is determined to be a method object of a message notification type according to the attribute information of the current-level method object func1, all method objects that receive notification messages sent by the method object func1 are determined by matching the key-value pairs in the structured data with the object name of the method object func1 and the keywords describing the relationship of receiving the notification call, and all the determined method objects are used as method objects called by the method object func1.

[0068] A fourth method is to determine all method objects that monitor the method object of the current level according to the structured data as method objects called by the method object of the current level. For another example, by matching the key-value pairs in the structured data with the object name of the method object func1 and the keywords describing the monitoring call relationship, all method objects that monitor the method object func1 are determined, and all the determined method objects are used as method objects called by the method object func1.

[0069] The fifth method is to determine all class objects that comply with the proxy protocol of the method object of the current level according to the structured data, and use all method objects of all determined class objects as method objects called by the method object of the current level. For another example, when the method object func1 is determined to be a method object of the method proxy type according to the attribute information of the method object func1 of the current level, all class objects that comply with the proxy protocol of the method object func1 are determined by matching the key-value pairs in the structured data with the object name of the method object func1 and the keywords describing compliance with the method proxy protocol, and further determine all method objects declared in each class object, and use all determined method objects as method objects called by the method object func1.

[0070] The above specific examples of determining the next-level method objects called by a method object are merely one possible implementation method. In specific implementations, the keywords describing the calling relationship may also be defined as other words, and the strings in the key-value pairs may also be generated by other methods based on the object name or method name. This application does not list them one by one.

[0071] In some embodiments of the present application, each source code file will usually generate a structured data file. In order to facilitate the construction of a method call relationship tree based on structured data and improve the subsequent traversal efficiency, some data in the structured data file can be merged and simplified first. For example, for some classes or methods provided by third parties, and classes or methods that do not need to track the operation status, their corresponding key-value correspondence data can be deleted from the structured data. For another example, for methods of the same class declared in different source files, their key-value mapping relationships can be merged into the same structured data file. For another example, for the key-value mapping relationship of a method object or class object of a notification class or proxy class, it is usually distributed in multiple structured data files. The key-value mapping relationship of a method object or class object of a notification class or proxy class can be merged into a structured data file.

[0072] In some embodiments of the present application, in order to facilitate subsequent source code matching, the structured data file and the class object may be stored in correspondence, that is, in a structured data file, only the key-value mapping relationship of a class object is stored.

[0073] Step 140: traverse the method call relationship tree associated with the specified service identifier to determine each method call link of the service identified by the specified service identifier.

[0074] Furthermore, starting from each leaf node, traversing the nodes of each level of the method call relationship tree layer by layer upwards, a tree branch corresponding to the leaf node can be obtained, and each tree branch corresponds to a method call link. According to this method, traversing each method call relationship tree corresponding to all start call method objects (such as the aforementioned start call methods startMethod1, startMethod2, ..., startMethodM) corresponding to a specified business identifier (such as business identifier ID1) can obtain all method call links covered by the business identified by the specified business identifier.

[0075] The method for determining a method call link for a corresponding service disclosed in an embodiment of the present application uses structured data to describe class objects declared in an application code, method objects declared in each of the class objects, and attribute information and method call relationships of each of the method objects, wherein at least part of the attribute information of the method objects includes: an identifier for indicating that the method object is a start call method or an end call method, and a service identifier associated with the method object; traversing the structured data, and determining a start call method object and an end call method object associated with different service identifiers according to the attribute information and the service identifier of the method object; for each start call method object, based on the method call relationship described in the structured data, constructing a method call relationship tree associated with a specified service identifier, wherein the specified service identifier is a service identifier associated with the start call method object; traversing the method call relationship tree associated with the specified service identifier, determining each method call link of the service identified by the specified service identifier, so that the method call circuit of each service module in the application can be automatically determined, and compared with manually combing through the method objects called by each service module in the prior art, the efficiency of determining the method call link of the specified service module code in the application is improved.

[0076] The method for determining the method call link of the corresponding business disclosed in the embodiment of the present application is to insert an identifier in the program code of the start call method object of each business module of the application program in advance, so as to mark the method object as the start call method, and insert an identifier in the program code of the end call method object, so as to mark the method object as the end call method object, and then, based on the method call relationship, construct the method call relationship tree corresponding to each business module, and finally, for a specified business module, by traversing all the method call relationship trees corresponding to the business module, determine the method call link of the specified business module. The process of constructing the method call relationship tree and traversing the method call relationship tree is fully automatically executed. For an application program containing dozens or even hundreds of business modules, on the basis of manually marking the start call method object and the end call method object of each business module, the method call relationship tree is automatically found through static code analysis and construction of the method call relationship tree, which fully improves the efficiency of determining the method call link of the specified business module code. In addition, manually marking hundreds or even thousands of method objects is prone to mislabeling and omission, while automatically marking the intermediate call method is more accurate and will not be omitted. Furthermore, when the program code undergoes version iteration, the method call links of each business module can be quickly determined by executing the method disclosed in the embodiment of the present application, which has high maintainability.

[0077] Embodiment 2

[0078] like Figure 3 As shown, based on the first embodiment, another embodiment of the present application discloses a method for corresponding service calling a link determination method, which, after step 140, further includes: steps 150 to 170.

[0079] Step 150, traverse all the method call links of the services identified by each service identifier, determine all intermediate call method objects associated with each service identifier, and determine all service identifiers associated with each intermediate call method object.

[0080] According to the method described in the embodiment, all method objects called in the program code that implements each business module in the target application can be determined. Next, detection code is inserted into the method objects of the program code that implements different business modules to obtain the execution status of the business module during the execution of the target application, for example, to monitor whether the business module is executed abnormally.

[0081] In order to insert the detection code into the code of the method object, it is first necessary to find the method object in the application code where the detection code needs to be inserted. Since the code identifying the type identifier of the method object needs to be manually inserted in advance in the start calling method object and the end calling method object of each business, in some embodiments of the present application, the detection code can be inserted at the same time as the code identifying the type identifier of the method object is manually inserted. Therefore, in the embodiments of the present application, the method of determining the intermediate calling method object of the business in the application code and the method of inserting the detection code in the determined intermediate calling method object are described in detail.

[0082] Normally, an application program code will contain hundreds or thousands of method object codes. Different business modules need to execute the program code of some of these method objects during operation, and different business modules often execute the same method object code. Then, based on this method object call relationship, the nodes in the method call relationship tree associated with different business identifiers may correspond to the same method object. In order to ensure that the detection code inserted at each intermediate calling method can detect the execution of all businesses that execute the method object, and avoid repeatedly inserting the detection code into the intermediate calling method, thereby improving the insertion efficiency of the detection code, in some embodiments of the present application, the method objects called in each business are collected by traversing the method call relationship tree associated with all business identifiers, and then the call relationship of each method object is merged, and the detection code is inserted based on the merged call relationship.

[0083] In some embodiments of the present application, the traversal of all the method call links of the business identified by each business identifier, determining all the intermediate call method objects associated with each business identifier, and determining all the business identifiers associated with each intermediate call method object, includes: traversing each of the method call links of the business identified by each business identifier, respectively determining the intermediate call method objects included in each of the method call links, and establishing an association relationship between the determined intermediate call method objects and the business identifier of the method call link to which they belong; for each of the intermediate call method objects, merging all the association relationships between the intermediate call method object and each of the business identifiers to obtain all the business identifiers associated with the intermediate call method.

[0084] As described in Example 1, after constructing a method call relationship tree by executing the method described in Example 1, one or more method call relationship trees associated with each business identifier can be obtained. Each method call relationship tree records the call relationship of the method object, and each node in the method call relationship tree stores relevant information of the method object corresponding to the node, such as the name of the method object. At the same time, each method call relationship tree is associated with a business identifier, and the business identifier associated with each method call relationship tree is also the business identifier of the business to which the method object corresponding to each node in the method call relationship tree belongs.

[0085] For example, Figure 2 The method call relationship tree shown is associated with business identifier ID1, then, Figure 2 The method objects startFunc, func1, func 2, ... corresponding to each node 200, 210, 220, ..., 2301, 2302 in the method call relationship tree shown also correspond to the business identifier ID1. That is, there is a corresponding relationship between the method objects corresponding to the nodes in the method call relationship tree and the business identifier associated with the method call relationship tree. Further, for any business identifier (such as business identifier ID1), by traversing all method call relationship trees associated with the business identifier, the method objects corresponding to all nodes in all method call relationship trees associated with the business identifier can be collected, and it can be determined from this process that all the collected method objects are associated with a business identifier (such as business identifier ID1). So far, the association relationship between a group of method objects and business identifiers can be determined.

[0086] According to the above method, the method call relationship tree associated with the business identifier of each business module in the target application is traversed to determine the association relationship between multiple groups of method objects and business identifiers.

[0087] Next, the obtained multiple sets of associations between method objects and business identifiers are merged, that is, for each method object in the multiple sets of associations between method objects and business identifiers, all its associations with different business identifiers are determined, and then a one-to-many association between the method object and the business identifier is suggested. For example, one method object is associated with multiple business identifiers.

[0088] Step 160, matching each of the determined intermediate call method objects with the method objects declared in the application code, and determining the successfully matched method objects as the method objects to be plugged corresponding to the corresponding intermediate call method objects.

[0089] Next, you need to find the intermediate call method object in the source code of the target application.

[0090] In some embodiments of the present application, it is possible to determine whether the method object declared in the application source code matches the intermediate calling method object by regular matching. Taking the method object name string in structured data as an example, when the method object func2 in the source code is described by structured data, it is represented as a key-value pair in the form of "methodName": "func2". Therefore, the name of the intermediate calling method object is matched with the method object name in the application source code to determine the intermediate calling method in the source code.

[0091] In some embodiments of the present application, the structured data includes source code storage file information of a class object corresponding to a class object name, and the matching of each determined intermediate call method object with a method object declared in the application code includes: performing the following method object matching operations in sequence until a method object matching the intermediate call method object is determined: matching the intermediate call method object with a method object declared in a source code storage file of a class to which the intermediate call method object belongs; matching the intermediate call method object with a method object declared in a source code storage file of an extended class object of the class to which the intermediate call method object belongs; matching the intermediate call method object with a method object declared in a source code storage file corresponding to a parent class of the intermediate call method object; matching the intermediate call method object with method objects declared in all source code storage files of the target application.

[0092] For example, in order to improve the insertion efficiency of the detection code, the storage path and file name of the source code of the class object corresponding to each class object name will be recorded in the structured data. When matching the determined intermediate call method object with the method object declared in the application code and determining the method object to be inserted, the storage file of the source code of the class object corresponding to the intermediate call method object can be determined based on the structured data first, and then only the intermediate call method object is matched with the method object in the file, which can effectively reduce the number of matches and improve the matching efficiency.

[0093] If after matching the intermediate calling method object with the method object declared in the source code storage file corresponding to the original class, it is determined that the method object matching fails, the following method object matching operations are performed in sequence until the method object matching the intermediate calling method object is determined: matching the intermediate calling method object with the method object declared in the source code storage file of the extended class object of the class to which the intermediate calling method object belongs, matching the intermediate calling method object with the method object declared in the source code storage file corresponding to the parent class of the intermediate calling method object, and matching the intermediate calling method object with the method objects declared in all source code storage files of the target application. There are many ways to call a method, which may be a conventional method call based on the original class, a method call based on the parent class, or a method call based on the extended class. However, most of the time, it is a call based on the original class. Therefore, by matching objects in a small to large matching range, the object matching efficiency can be improved. Among them, the parent class of the method object and the source code storage file of the parent class can be obtained in the structured data; the extended class object of the class of the method object can be determined by performing class object name matching in the structured data.

[0094] Step 170: insert detection code into the declaration code of each method object to be plugged.

[0095] The detection code is generated according to all service identifiers associated with the intermediate calling method object corresponding to the method object to be plugged.

[0096] After finding the method to be plugged in the source code of the application, a detection code can be generated using a preset coding rule according to the business identifier of the business module that calls the method to be plugged, and the generated detection code is inserted before the first line of source code of the method to be plugged. For example, for the intermediate calling method object func2 in the method calling link determined in step 140, if the intermediate calling method object func2 is determined to be associated with the business identifiers ID1 and ID2 in the aforementioned steps, and at the same time, the intermediate calling method object func2 is determined to match the method object func2 declared in the source code file 1.m in the aforementioned steps, then the detection code can be generated according to the business identifiers ID1 and ID2 (such as building a macro), and the generated detection code can be inserted before the first line of the source code of the method object func2 in the source code file 1.m.

[0097] In some embodiments of the present application, in order to better detect the execution status of the business module, a rule for generating a detection code according to a business identifier can be configured according to business requirements to obtain more business module execution information by executing the detection code.

[0098] In the prior art, in order to determine the execution information of a method object called by a certain business module, after manually combing through the business logic and code logic to find all the methods on the business, the monitoring code is usually manually inserted so that the execution status of each called method object can be obtained during the execution of the program code of the business module. If the business code is changed, the monitoring code needs to be modified again, which has poor maintainability. However, through the method for determining the method call link of the corresponding business disclosed in this embodiment, after accurately determining the method object called by the specified business module, the detection code can be automatically inserted into each intermediate method object called by the specified business module to monitor the calling status of each method object by the specified business module, thereby improving the detection efficiency of the business execution information and facilitating maintenance.

[0099] Embodiment 3

[0100] A method for corresponding services disclosed in an embodiment of the present application calls a link determination device, such as Figure 4 As shown, the device comprises:

[0101] The program code structured processing module 410 is used to describe the class objects declared in the application code, the method objects declared in each of the class objects, and the attribute information and method call relationship of each of the method objects through structured data, wherein at least part of the attribute information of the method objects includes: an identifier for indicating that the method object is a start call method or an end call method, and a service identifier associated with the method object;

[0102] A start and end calling method determination module 420, configured to traverse the structured data and determine a start calling method object and an end calling method object associated with different service identifiers according to the attribute information of the method object and the service identifier;

[0103] A method call relationship tree construction module 430 is used to construct a method call relationship tree associated with a specified service identifier for each of the start call method objects based on the method call relationship described in the structured data, wherein the specified service identifier is the service identifier associated with the start call method object;

[0104] The method call link determination module 440 is used to traverse the method call relationship tree associated with the specified service identifier and determine each method call link of the service identified by the specified service identifier.

[0105] In some embodiments of the present application, Figure 5 As shown, the device also includes:

[0106] The link instrumentation module 450 is used to traverse all the method call links of the services identified by each service identifier, determine all the intermediate call method objects associated with each service identifier, and determine all the service identifiers associated with each intermediate call method object;

[0107] The link instrumentation module 450 is further used to match each of the determined intermediate calling method objects with the method objects declared in the application code, and determine the successfully matched method objects as the method objects to be instrumented corresponding to the corresponding intermediate calling method objects; and insert a detection code into the declaration code of each method object to be instrumented, wherein the detection code is generated based on all business identifiers associated with the intermediate calling method objects corresponding to the method objects to be instrumented.

[0108] In some embodiments of the present application, traversing all the method call links of the services identified by each service identifier, determining all intermediate call method objects associated with each service identifier, and determining all service identifiers associated with each intermediate call method object, includes:

[0109] Traversing each method call link of the service identified by each service identifier, respectively determining the intermediate call method object included in each method call link, and establishing an association relationship between the determined intermediate call method object and the service identifier of the method call link to which it belongs;

[0110] For each of the intermediate calling method objects, all the associations between the intermediate calling method object and each of the service identifiers are merged to obtain all the service identifiers associated with the intermediate calling method.

[0111] In some embodiments of the present application, the structured data includes source code storage file information of a class object corresponding to a class object name, and the matching of each determined intermediate call method object with a method object declared in the application code includes:

[0112] The following method object matching operations are performed in sequence until a method object matching the intermediate call method object is determined:

[0113] Matching the intermediate calling method object with a method object declared in a source code storage file of a class to which the intermediate calling method object belongs;

[0114] Matching the intermediate calling method object with a method object declared in a source code storage file of an extended class object of a class to which the intermediate calling method object belongs;

[0115] Matching the intermediate calling method object with a method object declared in a source code storage file corresponding to a parent class of the intermediate calling method object;

[0116] The intermediate calling method object is matched with method objects declared in all source code storage files of the target application.

[0117] In some embodiments of the present application, Figure 5 As shown, the method call relationship tree construction module 430 further includes: a calling method determination submodule 4301, a child node construction submodule 4302 and a jump judgment submodule 4303. The method call relationship tree construction module 430 is further used to construct a root node according to the starting calling method object for each starting calling method object; and execute the calling method determination submodule 4301, the child node construction submodule 4302 and the jump judgment submodule 4303 with the starting calling method object as the current level method object, wherein,

[0118] The calling method determination submodule 4301 is used to determine each next-level method object called by the current-level method object based on the method calling relationship described in the structured data;

[0119] The sub-node construction sub-module 4302 is used to construct the sub-node of the node corresponding to the current-level method object according to each of the next-level method objects;

[0120] The jump judgment submodule 4303 is used to respond to the fact that each of the next-level method objects includes a method object that does not belong to the end calling method object, and use the next-level method objects that do not belong to the end calling method object as the current-level method objects, and jump to execute the calling method determination submodule 4301 and the child node construction submodule 4302 until all of the next-level method objects are the end calling method objects.

[0121] In some embodiments of the present application, the determining of each next-level method object called by the current-level method object based on the method call relationship described in the structured data includes any one or more of the following methods:

[0122] Determine the class object name and method object name of the current-level method object call based on the structured data, and then determine the method object to which the method object name corresponding to the class object name belongs according to the structured data as the method object called by the current-level method object;

[0123] Determine the class object name corresponding to the page to which the method jumps in the start calling method according to the structured data, and then determine the method objects to which all method object names corresponding to the class object name belong according to the structured data as the method objects called by the current level method object;

[0124] Determine, according to the structured data, all method objects that receive notifications sent by the current-level method object as method objects called by the current-level method object;

[0125] Determine, according to the structured data, all method objects that monitor the method object of the current level as method objects called by the method object of the current level;

[0126] All class objects that comply with the current-level method object proxy protocol are determined according to the structured data, and all method objects of all determined class objects are used as method objects called by the current-level method object.

[0127] In some embodiments of the present application, the program code structured processing module 410 is further used to:

[0128] The attribute information of the class objects declared in the application code, the method objects declared and / or called in each of the class objects, the attribute information of each of the method objects, and the method calling relationship of each of the method objects are described through JSON key-value pairs.

[0129] The method call link determination device for the corresponding service disclosed in the embodiment of the present application is used to implement the method call link determination method for the corresponding service described in Embodiment 1 and Embodiment 2 of the present application. The specific implementation methods of each module of the device will not be repeated here, and reference can be made to the specific implementation methods of the corresponding steps in the method embodiment.

[0130] The method call link determination device for the corresponding service disclosed in the embodiment of the present application uses structured data to describe the class objects declared in the application code, the method objects declared in each of the class objects, and the attribute information and method call relationship of each of the method objects, wherein at least part of the attribute information of the method objects includes: an identifier for indicating that the method object is a start call method or an end call method, and a service identifier associated with the method object; traverses the structured data, and determines the start call method object and the end call method object associated with different service identifiers according to the attribute information and the service identifier of the method object; for each start call method object, based on the method call relationship described in the structured data, constructs a method call relationship tree associated with a specified service identifier, wherein the specified service identifier is the service identifier associated with the start call method object; traverses the method call relationship tree associated with the specified service identifier, and determines each method call link of the service identified by the specified service identifier, so that the method call circuit of each service module in the application can be automatically determined, which improves the efficiency of determining the method call link of the specified service module code in the application compared to manually combing through the method objects called by each service module in the prior art.

[0131] The method call link determination device for the corresponding business disclosed in the embodiment of the present application inserts an identifier in the program code of the start call method object of each business module of the application program in advance, which is used to mark the method object as the start call method, and inserts an identifier in the program code of the end call method object, which is used to mark the method object as the end call method object. Then, a method call relationship tree corresponding to each business module is constructed based on the method call relationship. Finally, for a specified business module, all method call relationship trees corresponding to the business module are traversed to determine the method call link of the specified business module. The process of constructing the method call relationship tree and traversing the method call relationship tree is fully automatically executed. For an application program containing dozens or even hundreds of business modules, on the basis of manually marking the start call method object and the end call method object of each business module, the intermediate call method is automatically found through static code analysis and construction of the method call relationship tree, which fully improves the efficiency of determining the method call link of the specified business module code. In addition, manually marking hundreds or even thousands of method objects is prone to mislabeling and omission, while automatically marking the intermediate call method is more accurate and will not be omitted. Furthermore, when the program code undergoes version iteration, the method call links of each business module can be quickly determined by executing the method disclosed in the embodiment of the present application, which has high maintainability.

[0132] Furthermore, through the method call link determination device for the corresponding business disclosed in this embodiment, after accurately determining the method object called by the specified business module, a detection code can be automatically inserted into each intermediate method object called by the specified business module to monitor the calling status of each method object by the specified business module, thereby improving the detection efficiency of business execution information and facilitating maintenance.

[0133] Each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0134] The above is a detailed introduction to a method and device for determining a link for a method call corresponding to a service provided by the present application. This article uses specific examples to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

[0135] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0136] The various component embodiments of the present application can be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or digital signal processor (DSP) can be used in practice to implement some or all functions of some or all components in the electronic device according to the embodiment of the present application. The present application can also be implemented as a device or apparatus program (e.g., computer program and computer program product) for executing part or all of the methods described herein. Such a program implementing the present application can be stored on a computer-readable medium, or can have the form of one or more signals. Such a signal can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.

[0137] For example, Figure 6An electronic device that can implement the method according to the present application is shown. The electronic device can be a PC, a mobile terminal, a personal digital assistant, a tablet computer, etc. The electronic device traditionally includes a processor 610 and a memory 620 and a program code 630 stored on the memory 620 and can be run on the processor 610, and the processor 610 implements the method described in the above embodiment when executing the program code 630. The memory 620 can be a computer program product or a computer-readable medium. The memory 620 can be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk or a ROM. The memory 620 has a storage space 6201 for the program code 630 of a computer program for executing any method step in the above method. For example, the storage space 6201 for the program code 630 can include various computer programs for implementing the various steps in the above method respectively. The program code 630 is a computer-readable code. These computer programs can be read from one or more computer program products or written into the one or more computer program products. These computer program products include program code carriers such as hard disks, compact disks (CDs), memory cards or floppy disks. The computer program includes a computer readable code, and when the computer readable code is executed on an electronic device, the electronic device is caused to execute the method according to the above embodiment.

[0138] The embodiment of the present application further discloses a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the method for calling a link determination method for the corresponding service as described in Embodiments 1 and 2 of the present application is implemented.

[0139] Such a computer program product may be a computer-readable storage medium, which may have a computer-readable storage medium having a Figure 6 The memory 620 in the electronic device shown in the figure is similar to the storage segment, storage space, etc. The program code can be compressed and stored in the computer-readable storage medium in an appropriate form. The computer-readable storage medium is generally as shown in the reference Figure 7 The portable or fixed storage unit. Generally, the storage unit includes computer readable code 630', which is a code read by a processor. When the code is executed by the processor, each step in the method described above is implemented.

[0140] The term "one embodiment", "embodiment" or "one or more embodiments" herein means that a particular feature, structure or characteristic described in conjunction with the embodiment is included in at least one embodiment of the present application. In addition, please note that the examples of the term "in one embodiment" here do not necessarily all refer to the same embodiment.

[0141] In the description provided herein, a large number of specific details are described. However, it is understood that the embodiments of the present application can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.

[0142] In the claims, any reference signs placed between brackets shall not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present application may be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third etc. does not indicate any order. These words may be interpreted as names.

[0143] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A method corresponding to the service calls a link determination method, It is characterized in that include: Describing class objects declared in the application code, method objects declared in each class object, and attribute information and method call relationships of each method object through structured data, wherein at least part of the attribute information of the method object includes: an identifier for indicating that the method object is a start call method or an end call method, and a service identifier associated with the method object; Traversing the structured data, and determining, according to the attribute information of the method object and the service identifier, a start calling method object and an end calling method object associated with different service identifiers respectively; For each of the start calling method objects, based on the method calling relationship described in the structured data, respectively construct a method calling relationship tree associated with a specified service identifier, wherein the specified service identifier is the service identifier associated with the start calling method object; Traversing the method call relationship tree associated with the specified service identifier to determine each method call link of the service identified by the specified service identifier; The step of constructing a method call relationship tree associated with a specified service identifier for each of the start calling method objects based on the method call relationship described in the structured data includes: For each of the start calling method objects, construct a root node according to the start calling method object; Taking the start calling method object as the current level method object, execute the following node construction sub-steps: A calling method determination sub-step, determining each next-level method object called by the current-level method object based on the method calling relationship described in the structured data; A sub-node construction sub-step, constructing a sub-node of the node corresponding to the current-level method object according to each of the next-level method objects; The jump judgment sub-step is responsive to the fact that each of the next-level method objects includes a method object that does not belong to the end calling method object, and the next-level method objects that do not belong to the end calling method object are respectively used as the current-level method objects, and the jump is made to the execution of the calling method determination sub-step and the sub-node construction sub-step until all of the next-level method objects are the end calling method objects.

2. The method according to claim 1, It is characterized in that After the step of determining each method call link of the service identified by the specified service identifier, the method further includes: Traversing all the method call links of the services identified by each service identifier, determining all intermediate call method objects associated with each service identifier, and determining all service identifiers associated with each intermediate call method object; Matching each of the determined intermediate call method objects with the method objects declared in the application code, and determining the successfully matched method objects as the method objects to be plugged corresponding to the corresponding intermediate call method objects; In the declaration code of each of the method objects to be plugged, a detection code is inserted, wherein the detection code is generated according to all service identifiers associated with the intermediate calling method object corresponding to the method object to be plugged.

3. The method according to claim 2, It is characterized in that The step of traversing all the method call links of the services identified by each service identifier, determining all intermediate call method objects associated with each service identifier, and determining all service identifiers associated with each intermediate call method object includes: Traversing each method call link of the service identified by each service identifier, respectively determining the intermediate call method object included in each method call link, and establishing an association relationship between the determined intermediate call method object and the service identifier of the method call link to which it belongs; For each of the intermediate calling method objects, all the associations between the intermediate calling method object and each of the service identifiers are merged to obtain all the service identifiers associated with the intermediate calling method.

4. The method according to claim 2, It is characterized in that The structured data includes source code storage file information of the class object corresponding to the class object name, and the step of matching each of the determined intermediate call method objects with the method objects declared in the application code includes: The following method object matching operations are performed in sequence until a method object matching the intermediate call method object is determined: Matching the intermediate calling method object with a method object declared in a source code storage file of a class to which the intermediate calling method object belongs; Matching the intermediate calling method object with a method object declared in a source code storage file of an extended class object of a class to which the intermediate calling method object belongs; Matching the intermediate calling method object with a method object declared in a source code storage file corresponding to a parent class of the intermediate calling method object; The intermediate call method object is matched with method objects declared in all source code storage files of the target application.

5. The method according to claim 1, It is characterized in that The step of determining each next-level method object called by the current-level method object based on the method call relationship described in the structured data includes any one or more of the following methods: Determine the class object name and method object name of the current-level method object call based on the structured data, and then determine the method object to which the method object name corresponding to the class object name belongs according to the structured data as the method object called by the current-level method object; Determine the class object name corresponding to the page to which the method jumps in the start calling method according to the structured data, and then determine the method objects to which all method object names corresponding to the class object name belong according to the structured data as the method objects called by the current level method object; Determine, according to the structured data, all method objects that receive notifications sent by the current-level method object as method objects called by the current-level method object; Determine, according to the structured data, all method objects that monitor the method object of the current level as method objects called by the method object of the current level; All class objects that comply with the current-level method object proxy protocol are determined according to the structured data, and all method objects of all determined class objects are used as method objects called by the current-level method object.

6. The method according to any one of claims 1 to 4, It is characterized in that The step of describing the class objects declared in the application code, the method objects declared in each of the class objects, and the attribute information and method call relationship of each of the method objects through structured data includes: The attribute information of the class objects declared in the application code, the method objects declared and / or called in each of the class objects, the attribute information of each of the method objects, and the method calling relationship of each of the method objects are described through JSON key-value pairs.

7. A method for corresponding services calls a link determination device, It is characterized in that include: A program code structured processing module, used to describe the class objects declared in the application code, the method objects declared in each of the class objects, and the attribute information and method call relationship of each of the method objects through structured data, wherein at least part of the attribute information of the method objects includes: an identifier for indicating that the method object is a start call method or an end call method, and a service identifier associated with the method object; A start and end calling method determination module, used for traversing the structured data, and determining the start calling method object and the end calling method object associated with different service identifiers according to the attribute information of the method object and the service identifier; A method call relationship tree construction module, configured to respectively construct a method call relationship tree associated with a specified service identifier for each of the start call method objects based on the method call relationship described in the structured data, wherein the specified service identifier is the service identifier associated with the start call method object; A method call link determination module, used to traverse the method call relationship tree associated with the specified service identifier, and determine each method call link of the service identified by the specified service identifier; The step of constructing a method call relationship tree associated with a specified service identifier for each of the start calling method objects based on the method call relationship described in the structured data includes: For each of the start calling method objects, construct a root node according to the start calling method object; Taking the start calling method object as the current level method object, execute the following node construction sub-steps: A calling method determination sub-step, determining each next-level method object called by the current-level method object based on the method calling relationship described in the structured data; A sub-node construction sub-step, constructing a sub-node of the node corresponding to the current-level method object according to each of the next-level method objects; The jump judgment sub-step is responsive to the fact that each of the next-level method objects includes a method object that does not belong to the end calling method object, and the next-level method objects that do not belong to the end calling method object are respectively used as the current-level method objects, and the jump is made to the execution of the calling method determination sub-step and the sub-node construction sub-step until all of the next-level method objects are the end calling method objects.

8. An electronic device comprising a memory, a processor, and a program code stored in the memory and executable on the processor, It is characterized in that When the processor executes the program code, the method for implementing the corresponding service described in any one of claims 1 to 6 calls a link determination method.

9. A computer-readable storage medium having program code stored thereon, It is characterized in that When the program code is executed by a processor, the method for corresponding services described in any one of claims 1 to 6 implements the step of calling a link determination method.

Citation Information

Patent Citations

  • Information processing method, server and computer storage medium

    CN108874470A

  • Calling link construction method, device and equipment

    CN110007957A