Call relationship analysis method, device, electronic device and storage medium

By obtaining and analyzing the bytecode information in Java code, judging remote calls and constructing virtual remote call information, it solves the problem of analyzing the calling relationship between methods in Java code and achieves the accuracy of static analysis.

CN118503971BActive Publication Date: 2024-10-25HANGZHOU NEWGRAND TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410962957.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-18
Publication Date
2024-10-25
Estimated Expiration
2044-07-18

AI Technical Summary

Technical Problem

In the existing technology, due to the complexity of the project architecture, the calling relationship between methods in the Java code cannot be determined through static analysis.

Method used

By obtaining the bytecode information, it is determined whether there is a remote call. If it exists, virtual remote call information is constructed based on the interface information in the remote call to implement static analysis of the call relationship in the bytecode.

Benefits of technology

It solves the problem of being unable to determine the bytecode calling relationship through static analysis due to the complexity of the project architecture, and achieves accurate static analysis of the calling relationship in the bytecode.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118503971B_ABST
    Figure CN118503971B_ABST
Patent Text Reader

Abstract

The present application discloses a method, device, electronic device and storage medium for analyzing call relations. Obtain bytecode information; determine whether there is a remote call in the bytecode information; if so, construct virtual remote call information according to the interface information in the remote call to analyze the call relations in the bytecode. The present application realizes determining the call relations in the bytecode through static analysis.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to information processing technology, and in particular to a call relationship analysis method, device, electronic device and storage medium. Background Art

[0002] During code analysis, it is necessary to analyze the calling relationship between methods to ensure the normal operation of the functions.

[0003] In the prior art, when analyzing the calling relationship between methods in Java (a professional term, a programming method) code, the calling information between methods is usually parsed by analyzing the bytecode file. However, due to the complexity of the project architecture, the calling relationship in the bytecode cannot be determined by static analysis. Summary of the invention

[0004] The present application provides a call relationship analysis method, device, electronic device and storage medium to determine the call relationship in bytecode through static analysis.

[0005] In a first aspect, the present application provides a call relationship analysis method, the call relationship analysis method comprising:

[0006] Get bytecode information;

[0007] Determine whether there is a remote call in the bytecode information;

[0008] If so, virtual remote call information is constructed according to the interface information in the remote call to analyze the call relationship in the bytecode.

[0009] In a second aspect, the present application further provides a call relationship analysis device, the call relationship analysis device comprising:

[0010] A bytecode information acquisition module, used to acquire bytecode information;

[0011] A remote call judgment module is used to judge whether there is a remote call in the bytecode information;

[0012] The virtual remote call information construction module is used to construct the virtual remote call information according to the interface information in the remote call to realize the analysis of the call relationship in the bytecode.

[0013] In a third aspect, the present application further provides an electronic device, the electronic device comprising:

[0014] one or more processors;

[0015] A storage device for storing one or more programs;

[0016] When one or more programs are executed by one or more processors, the one or more processors implement any one of the call relationship analysis methods provided in the embodiments of the present application.

[0017] In a fourth aspect, the present application further provides a storage medium comprising computer executable instructions, which, when executed by a computer processor, are used to execute any one of the call relationship analysis methods provided in the embodiments of the present application.

[0018] The present application obtains bytecode information; determines whether there is a remote call in the bytecode information, and promptly identifies the remote call relationship in the bytecode information; if so, constructs virtual remote call information according to the interface information in the remote call to analyze the call relationship in the bytecode, and the inheritance relationship between interfaces can be obtained through the interface information, and then the virtual remote call information can be constructed, and the static analysis of the call relationship in the bytecode can be realized through the virtual remote call information. Therefore, the technical solution of the present application solves the problem that the call relationship in the bytecode cannot be determined through static analysis due to the complexity of the project architecture, and achieves the effect of determining the call relationship in the bytecode through static analysis. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 It is a flowchart of a call relationship analysis method in Embodiment 1 of the present application;

[0020] Figure 2 It is a flow chart of a call relationship analysis method in Embodiment 2 of the present application;

[0021] Figure 3a It is a flowchart of a call relationship analysis method in Embodiment 3 of the present application;

[0022] Figure 3b This is a schematic diagram of a class inheritance structure in Example 3 of the present application;

[0023] Figure 3c It is a schematic diagram of a virtual class calling relationship in the third embodiment of the present application;

[0024] Figure 4 It is a structural diagram of a call relationship analysis device in Embodiment 4 of the present application;

[0025] Figure 5 It is a structural diagram of an electronic device in Embodiment 5 of the present application. DETAILED DESCRIPTION

[0026] In order to enable those skilled in the art to better understand the solution of the present application, 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 only 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 should fall within the scope of protection of the present application.

[0027] It should be noted that the terms "first" and "second" etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0028] Embodiment 1

[0029] Figure 1 A flowchart of a call relationship analysis method provided in Example 1 of the present application. This embodiment is applicable to the situation of statically analyzing the call relationship in the bytecode. The method can be executed by a call relationship analysis device, which can be implemented in software and / or hardware and is specifically configured in an electronic device that needs to perform call relationship analysis.

[0030] See also Figure 1 The call relationship analysis method shown specifically includes the following steps:

[0031] S110. Obtain bytecode information.

[0032] Bytecode is a binary file that contains an executable program and consists of a sequence of operation codes and data pairs. After the code is compiled, bytecode information can be obtained. The bytecode information contains all class and interface information. According to the inheritance relationship of the class and the inheritance relationship of the interface, the calling relationship in the bytecode can be analyzed.

[0033] S120, determining whether there is a remote call in the bytecode information.

[0034] Remote call can be a process of calling methods or data in different services through network requests, which is used to determine the way to construct virtual remote call information. Exemplarily, it can be determined whether there is a remote call in the bytecode information through a call instruction, that is, when there is a call instruction, it can be determined that there is a remote call in the bytecode information, otherwise it does not exist. For example, it can be determined whether there is a remote call function in the bytecode information to determine whether there is a remote call in the bytecode information. When there is a remote call function, it is determined that there is a remote call in the bytecode information.

[0035] When there is a remote procedure call, the actual call is made through the network, not at the code level. Therefore, when analyzing the call relationship, it is necessary to analyze it through the inheritance relationship of the interface. When there is no remote procedure call, when analyzing the call relationship, it is only necessary to analyze it through the inheritance relationship of the class. Therefore, after obtaining the bytecode information, it is necessary to analyze whether there is a remote call.

[0036] S130: If yes, construct virtual remote call information according to the interface information in the remote call to analyze the call relationship in the bytecode.

[0037] If yes, that is, there is a remote call, and at this time, it is necessary to construct virtual remote call information based on the interface information in the remote call. The virtual remote call information can be obtained by statically analyzing the interface inheritance relationship in the bytecode information. The virtual remote call information can include all possible remote call relationships. The characteristic of remote calls is that they can make cross-process calls like local calls. Therefore, it is always possible to obtain the call relationship between the two parties of the remote call by analyzing the bytecode, determine the virtual remote call information, and then obtain the real call relationship based on the virtual remote call information, so as to realize the analysis of the call relationship in the bytecode.

[0038] In the jvm (professional term, a specification for computing devices) specification, for each variable, there are two types, namely "actual type" and "static type". Among them, the static type is the type of the variable when it is declared; the actual type is the actual type of the object pointed to by the variable in memory. To obtain the actual call situation, it can only be obtained based on the actual type of the object, but for static analysis, it can only obtain the static type of the caller when the call occurs.

[0039] When analyzing calling relationships through bytecodes, the focus is generally on the bytecode instructions in the bytecode that represent calls, such as invokestatic (professional term, a bytecode instruction), invokespecial (professional term, a bytecode instruction), invokevirtual (professional term, a bytecode instruction), invokeinterface (professional term, a bytecode instruction) and invokedynamic (professional term, a bytecode instruction).

[0040] The parsed call relationships of the invokestatic and invokespecial bytecode instructions are easy and accurate. Among all the method call types in Java, the easiest to parse and unambiguous ones are static method calls, private method calls, instance constructor calls, parent class method calls, and final (a professional term, a keyword) modified method calls using the invokestatic and invokespecial instructions. These called methods are called non-virtual methods. Because non-virtual methods are uniquely determined at compile time, these bytecode instructions are very suitable for static parsing.

[0041] On the contrary, the calling relationship directly parsed by the invokevirtual bytecode instruction is often invalid. The call of non-virtual methods is performed through the invokestatic and invokespecial instructions. The corresponding virtual methods are called using the invokevirtual instruction. Due to the dynamic dispatch characteristics of the JVM (Java Virtual Machine) or the working mode of the invokespecial instruction, if only the invokevirtual instruction in the bytecode is statically analyzed, the calling relationship that can be analyzed is very superficial. Because the invokespecial command will obtain the actual type of the method caller at the beginning of execution, that is, invokespecial can only determine the actual type of the method caller when it is executed. When the program is not executed, that is, during static analysis, it is impossible to obtain the actual type of the method caller based on the bytecode.

[0042] The technical solution of this embodiment obtains bytecode information; determines whether there is a remote call in the bytecode information, and promptly identifies the remote call relationship in the bytecode information; if so, constructs virtual remote call information according to the interface information in the remote call to analyze the call relationship in the bytecode, and the inheritance relationship between interfaces can be obtained through the interface information, and then the virtual remote call information is constructed, and the static analysis of the call relationship in the bytecode can be realized through the virtual remote call information. Therefore, the technical solution of this application solves the problem that the call relationship in the bytecode cannot be determined through static analysis due to the complexity of the project architecture, and achieves the effect of determining the call relationship in the bytecode through static analysis.

[0043] Embodiment 2

[0044] Figure 2 This is a flow chart of a call relationship analysis method provided in Example 2 of the present application. The technical solution of this embodiment is further refined on the basis of the above technical solution.

[0045] Furthermore, "constructing virtual remote call information according to the interface information in the remote call" is refined into: "obtaining annotation information in the interface information in the remote call; determining the first index corresponding to the caller and the second index corresponding to the callee according to the annotation information; constructing virtual remote call information according to the first index and the second index" to construct the virtual remote call information.

[0046] See also Figure 2 A call relationship analysis method shown includes:

[0047] S210. Obtain bytecode information.

[0048] S220, determine whether there is a remote call in the bytecode information.

[0049] S230: If yes, obtain the annotation information in the interface information in the remote call.

[0050] The annotation information can be an explanation statement of the function and usage of the code when making a remote call, which is used to indicate the purpose, parameter description and return value description of the method called by the interface, etc. This application does not make specific restrictions on this. The interface can realize code reuse between multiple classes, and the relevant information of the methods reused between different interfaces can be obtained through the annotation information. For example, the corresponding annotation information can be obtained through the annotation function.

[0051] S240. Determine a first index corresponding to the caller and a second index corresponding to the callee according to the annotation information.

[0052] The annotation information may include an interface request method and a network request string, wherein the network request string may include relevant information about the remote call method. For example, the relevant information about the method may include the purpose of the method, parameter description, and return value description, etc., which are not specifically limited in this application. When there are multiple remote call methods in the annotation information, there may be multiple corresponding network request strings, that is, each remote call method corresponds to a network request string.

[0053] The first index may be a hash index value generated according to the annotation information of the caller, and is used to represent the method information of the caller. Exemplarily, the first index may be a hash value obtained by performing a hash calculation on the network request string.

[0054] The second index may be a hash index value generated according to the annotation information of the callee, and is used to represent the callee information of the callee. Exemplarily, the second index may be a hash value obtained by performing a hash calculation on the network request string.

[0055] S250: Construct virtual remote call information according to the first index and the second index.

[0056] After collecting the first indexes corresponding to all callers and the second indexes corresponding to the callees, it can be determined whether the first index of the caller exists in the second index of the caller. If so, virtual remote call information can be constructed based on the calling relationship between the methods in the first index and the second index.

[0057] In an optional embodiment, constructing virtual remote call information according to the first index and the second index includes: determining whether the first index exists in the second index; if so, constructing the virtual remote call information according to method information of the first index and the second index.

[0058] Both the first index and the second index can be data sets including multiple numerical values. Exemplarily, to determine whether the first index value exists in the second index, it can be to traverse the numerical values ​​in the first index and determine whether there is a numerical value equal to it in the data set corresponding to the second index. If so, it is determined that the numerical value corresponding to the first index exists in the second index. If so, that is, the first index exists in the second index. At this time, the method corresponding to the first index remotely calls the method corresponding to the second index. Therefore, based on the method information of the first index and the second index, virtual remote call information for remote calls of corresponding methods between interfaces can be constructed.

[0059] By determining whether the first index value of the first index exists in the second index; if so, constructing virtual remote call information according to the method information of the first index and the second index, the integrity of the constructed virtual remote call information can be guaranteed.

[0060] When making a remote call, the actual call link is made through the network, not through the code level. Therefore, if you want to identify the call link by analyzing the bytecode, you can analyze it through virtual remote call information. The call relationship analysis process based on OpenFeig (a professional term, a remote call framework) which is common in the backend architecture of microservices is as follows:

[0061] Assume that there is a remote call client interface of service A and a remote call control interface of service B. There is a declaration of method aoperation in service A and a declaration of method boperation in service B. When method f in service A makes a remote call to method aoperation in service A, the bytecode instructions of remote call of method f in service A are parsed, and the parsed call relationship is that method f in service A calls method aoperation in service A. A remote call is initiated in service A, but the business implementation corresponding to method aoperation is often in another service. This call is actually an http (professional term, a network request method) request, which requests method boperation in service B.

[0062] Through bytecode analysis, we can find that method f in service A calls method aoperation of the remote call client of service A, which is not a real remote call relationship.

[0063] Therefore, in this application, virtual remote call information is constructed through the annotation information in the interface information corresponding to the method aoperation of the remote call client of service A. That is, the request method is determined to be GET (a professional term, a network request method), and the request path is the first index of the method operation, and then the called party is determined in the second index of the interface established in advance, that is, it is determined whether the first index exists in the second index established in advance, and the virtual remote call information is constructed according to the judgment result. The virtual remote call information generated at this time is: the method aoperation in the remote call client of service A calls the method boperation in the remote call control end of service B. At this time, the real network-based remote call is parsed into virtual remote call information. According to the virtual remote call information, the real call link can be obtained, that is: method f in service A calls the method boperation in the remote call control end of service B.

[0064] The premise of the implementation in the above example is based on the characteristics of remote procedure calls, that is, the client provided by the callee can always correspond to the caller according to certain code constraints. For example, the client provided by the callee and the caller are the client provided by the callee and the callee itself. Since the characteristic of remote calls is that they can make cross-process calls like local calls, it is always possible to analyze the call relationship during remote calls by analyzing the bytecode to construct virtual remote call information.

[0065] The technical solution of this embodiment is to obtain the annotation information in the interface information in the remote call; determine the first index corresponding to the caller and the second index corresponding to the callee according to the annotation information; construct virtual remote call information according to the first index and the second index, and construct all virtual remote call information according to the inheritance relationship in the annotation information, so as to realize static analysis of method call relationship when there is a remote call in the bytecode, and construct virtual remote call information through the inheritance relationship in the annotation information, so as to statically analyze all possible complete call links during remote call, and realize static analysis of call relationship.

[0066] Embodiment 3

[0067] Figure 3a This is a flow chart of a call relationship analysis method provided in Example 3 of the present application. The technical solution of this embodiment is further refined on the basis of the above technical solution.

[0068] Furthermore, after determining whether there is a remote call in the bytecode information, add "if not, construct virtual class call information based on the class inheritance key-value pairs including the inheritance relationship in the bytecode information to realize the analysis of the class call relationship in the bytecode" to realize the construction of virtual class call information of the class inheritance relationship.

[0069] See also Figure 3a A call relationship analysis method shown includes:

[0070] S310, obtaining bytecode information.

[0071] S320, determine whether there is a remote call in the bytecode information.

[0072] S330: If yes, construct virtual remote call information according to the interface information in the remote call to analyze the call relationship in the bytecode.

[0073] S340: If not, construct virtual class call information according to the class inheritance key-value pairs in the bytecode information to analyze the class call relationship in the bytecode.

[0074] If not, that is, there is no remote call in the bytecode information, then it is only necessary to analyze the class inheritance relationship to obtain the virtual class call information. The class inheritance key value can be a key-value pair consisting of a parent class and a child class with an inheritance relationship. Exemplarily, the class inheritance key-value pairs including the inheritance relationship in the bytecode information can be obtained according to the inheritance function, that is, the parent class and the child class are obtained according to the inheritance function. The virtual class call information can be a possible call relationship constructed according to the inheritance relationship corresponding to the class inheritance key-value pair, that is, each time a class inheritance key-value pair is obtained, a class virtual call link is added according to the class inheritance key-value pair to realize static analysis of the class call relationship in the bytecode.

[0075] Exemplarily, after obtaining the class inheritance key-value pairs, all methods in the parent class can be traversed, and the child class is considered to include all parent class methods, a virtual class calling relationship of the parent class calling the child class method is generated, and all possible class calling relationships in the bytecode are obtained. The class calling relationship in the bytecode is analyzed, and when performing actual analysis of the call chain, combined with the real call, a real and complete call chain can be obtained.

[0076] The following uses polymorphic class inheritance as an example to analyze how to obtain the call chain. Figure 3b This is a schematic diagram of a class inheritance structure. Figure 3b In the example, method op in class B is a subclass method that inherits method op in class A, and method op in class C and method op in class D are subclass methods that inherit method op in class B, that is, it includes three class inheritance key-value pairs: A and B, B and C, and B and D. When method f in class T calls method op in class B, the calling relationship obtained from bytecode analysis is that method f in class T calls method op in B. However, since class C is up-casted and points to its parent class B, the actual calling relationship is that method f in class T calls method op in class C. The actual call cannot be directly analyzed and obtained, and needs to be analyzed through the virtual class calling relationship.

[0077] according to Figure 3b The class inheritance structure in can be obtained Figure 3c A schematic diagram of a virtual class calling relationship is shown in FIG. Figure 3c Based on the virtual class call relationship in , we get two virtual class call links, one of which is consistent with the actual situation, where method f of class T calls method op of class C; the other is inconsistent with the actual situation, where method f of class T calls method op of class D. It can be found that the virtual call links obtained based on the analysis of virtual class call relationship have increased, and only one of them is consistent with the actual situation; the other one does not exist in reality. However, according to the virtual class call relationship, there is at least one situation that is real, that is, there is at least one virtual call link that is a real call link.

[0078] In summary, based on the polymorphic characteristics of class inheritance, the calling relationship between the non-existent parent and child class methods generated according to the inheritance relationship is used as the virtual class calling relationship. Combined with the real calling relationship directly parsed by invokevirtual, a series of unreliable calls are inferred, which can indirectly parse the calling chain that cannot be parsed.

[0079] In an optional embodiment, virtual class call information is constructed based on the class inheritance key-value pairs in the bytecode information, including: determining the parent class method in the class inheritance key-value pairs in the bytecode information; judging whether there is an overridden parent class method in the child class; if so, generating a virtual call relationship of the parent class method calling the child class method; taking the child class as the new parent class, and repeatedly judging whether there is an overridden parent class method in the child class until the judgment result is no.

[0080] According to the inheritance relationship in the bytecode information, the parent class and child class in the class inheritance key value are determined. The parent class can be the inherited party in the method with an inheritance relationship. The child class can be the inheriting party in the method with an inheritance relationship. The overridden parent class method, that is, the child class redefines the inherited parent class method. The parent class method overridden in the child class can inherit the method name, parameter list, return type, etc. from the parent class method, and the method can be overridden to a certain extent. Exemplarily, it can be determined whether the child class method overrides the parent class method by determining whether there is a declaration of the implementation of the inherited parent class method in the child class method. For example, it can be determined whether the child class method overrides the parent class method by determining whether the method signatures in the parent class and the child class are exactly the same.

[0081] After all class inheritance key-value pairs are collected, all parent classes and corresponding child classes are determined, and finally the top-level parent class is determined. Starting from the top-level parent class, it is determined layer by layer whether there is an overridden parent class method in its child class, and virtual class call information is constructed according to the judgment result; if so, that is, the parent class method is overridden in the child class, a virtual call relationship of the parent class method calling the child class method is generated, and the class inheritance relationship is logically converted into a method call relationship; after judging the top-level parent class, all child class methods of the top-level parent class are used as new parent class methods, and it is determined whether there is an overridden parent class method in its child class. If so, a virtual class call relationship is constructed based on the new parent class method and its child class method. If not, that is, the child class has not overridden the parent class method, and the judgment of whether there is an overridden parent class method in the child class is stopped until all the child classes of the new parent class method have not overridden the parent class method, and the construction of the entire virtual class call information is completed.

[0082] By determining the parent class method in the class inheritance key-value pair in the bytecode information; judging whether there is an overridden parent class method in the child class; if so, generating a virtual call relationship of the parent class method calling the child class method; taking the child class as the new parent class, and repeatedly executing the judgment of whether there is an overridden parent class method in the child class until the judgment result is no, the class inheritance relationship is logically converted into a method call relationship to ensure the integrity of the virtual class call information, thereby realizing static analysis of multiple inheritance and the call situation of the subclass transformation to any parent class.

[0083] In an optional embodiment, after determining whether there is an overridden parent class method in the subclass, the method further includes: if not, it is deemed that there is a parent class method in the subclass, and a virtual call relationship of the parent class method calling the subclass method is generated.

[0084] If not, that is, there is no overridden parent class method in the child class, then it is considered that the parent class method exists in the child class, that is, the child class method completely repeats the parent class method, and a virtual call relationship is generated in which the parent class method calls the child class method to ensure the integrity of the constructed virtual class call information.

[0085] After determining whether there is an overridden parent class method in the subclass, it also includes: if not, it is deemed that the parent class method exists in the subclass, and a virtual call relationship of the parent class method calling the subclass method is generated, to ensure the integrity of the constructed virtual class call information when the subclass method does not override the parent class method.

[0086] The technical solution of this embodiment is to add, after determining whether there is a remote call in the bytecode information, if not, to construct virtual class call information based on the class inheritance key-value pairs in the bytecode information to realize the analysis of the class call relationship in the bytecode. By constructing virtual class call information through the inheritance relationship in the class inheritance key-value pairs, all possible complete call links can be statically analyzed to realize static analysis of the call relationship.

[0087] Embodiment 4

[0088] Figure 4 The figure shows a schematic diagram of the structure of a call relationship analysis device provided in the fourth embodiment of the present application. This embodiment is applicable to the case of static analysis of the call relationship in the bytecode. The specific structure of the call relationship analysis device is as follows:

[0089] Bytecode information acquisition module 410, used to acquire bytecode information;

[0090] A remote call determination module 420 is used to determine whether there is a remote call in the bytecode information;

[0091] The virtual remote call information construction module 430 is used to construct the virtual remote call information according to the interface information in the remote call to analyze the call relationship in the bytecode.

[0092] The technical solution of this embodiment obtains bytecode information; determines whether there is a remote call in the bytecode information, and promptly identifies the remote call relationship in the bytecode information; if so, constructs virtual remote call information according to the interface information in the remote call to analyze the call relationship in the bytecode, and the inheritance relationship between interfaces can be obtained through the interface information, and then the virtual remote call information is constructed, and the static analysis of the call relationship in the bytecode can be realized through the virtual remote call information. Therefore, the technical solution of this application solves the problem that the call relationship in the bytecode cannot be determined through static analysis due to the complexity of the project architecture, and achieves the effect of determining the call relationship in the bytecode through static analysis.

[0093] Optionally, the virtual remote call information building module 430 includes:

[0094] An annotation information acquisition unit, used to acquire annotation information in the interface information in the remote call;

[0095] An index determination unit, used to determine a first index corresponding to the caller and a second index corresponding to the callee according to the annotation information;

[0096] The virtual remote call information construction unit is used to construct the virtual remote call information according to the first index and the second index.

[0097] Optionally, a virtual remote call information building unit includes:

[0098] An index call determination subunit, used to determine whether the first index exists in the second index;

[0099] The virtual remote call information construction subunit is used to construct the virtual remote call information according to the method information of the first index and the second index.

[0100] Optionally, the calling relationship analysis device further includes:

[0101] The virtual class call information construction module is used to construct virtual class call information according to the class inheritance key-value pairs in the bytecode information if no, so as to realize the analysis of the class call relationship in the bytecode.

[0102] Optionally, a virtual class calls the information building block, including:

[0103] A parent class method determination unit, used to determine the parent class method in the class inheritance key-value pair in the bytecode information;

[0104] The subclass method judgment unit is used to judge whether there is an overridden parent class method in the subclass;

[0105] A virtual class call information construction unit, for generating a virtual call relationship of a parent class method calling a child class method if yes;

[0106] The repeated judgment execution unit is used to take the subclass as a new parent class and repeatedly judge whether there is an overridden parent class method in the subclass until the judgment result is no.

[0107] Optionally, the virtual class call information building module also includes:

[0108] The subclass method determination unit is used to, if not, regard the parent class method as existing in the subclass and generate a virtual call relationship of the parent class method calling the subclass method.

[0109] The call relationship analysis device provided in the embodiment of the present application can execute the call relationship analysis method provided in any embodiment of the present application, and has the corresponding functional modules and beneficial effects for executing the call relationship analysis method.

[0110] Embodiment 5

[0111] Figure 5 A schematic diagram of the structure of an electronic device provided in Embodiment 5 of the present application is shown in FIG. Figure 5 As shown, the electronic device includes a processor 510, a memory 520, an input device 530 and an output device 540; the number of the processor 510 in the electronic device can be one or more. Figure 5 A processor 510 is taken as an example; the processor 510, the memory 520, the input device 530 and the output device 540 in the electronic device can be connected via a bus or other means. Figure 5 The example of connecting through bus is taken in the following.

[0112] The memory 520, as a computer-readable storage medium, can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the call relationship analysis method in the embodiment of the present application (for example, the bytecode information acquisition module 410, the remote call judgment module 420 and the virtual remote call information construction module 430). The processor 510 executes various functional applications and data processing of the electronic device by running the software programs, instructions and modules stored in the memory 520, that is, realizing the above-mentioned call relationship analysis method.

[0113] The memory 520 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the terminal, etc. In addition, the memory 520 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 520 may further include a memory remotely arranged relative to the processor 510, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0114] The input device 530 may be used to receive input character information and generate key signal input related to user settings and function control of the electronic device. The output device 540 may include a display device such as a display screen.

[0115] Embodiment 6

[0116] Embodiment 6 of the present application also provides a storage medium containing computer executable instructions, which, when executed by a computer processor, are used to execute a call relationship analysis method, the method comprising: obtaining bytecode information; determining whether there is a remote call in the bytecode information; if so, constructing virtual remote call information based on the interface information in the remote call to implement the analysis process of the call relationship in the bytecode.

[0117] Of course, the storage medium containing computer executable instructions provided in the embodiment of the present application, whose computer executable instructions are not limited to the method operations described above, can also execute related operations in the call relationship analysis method provided in any embodiment of the present application.

[0118] Through the above description of the implementation method, the technicians in the relevant field can clearly understand that the present application can be implemented with the help of software and necessary general hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for an electronic device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0119] It is worth noting that in the embodiment of the above-mentioned call relationship analysis device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application.

[0120] Note that the above are only preferred embodiments of the present application and the technical principles used. Those skilled in the art will understand that the present application is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present application. Therefore, although the present application is described in more detail through the above embodiments, the present application is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present application, and the scope of the present application is determined by the scope of the appended claims.

Claims

1. A call relationship analysis method, It is characterized in that include: Get bytecode information; Determine whether there is a remote call in the bytecode information; If yes, construct virtual remote call information according to the interface information in the remote call to analyze the call relationship in the bytecode; The step of constructing virtual remote call information according to the interface information in the remote call includes: Obtaining annotation information in the interface information in the remote call; Determine a first index corresponding to the caller and a second index corresponding to the callee according to the annotation information; the first index is a hash index value generated according to the annotation information of the caller; the second index is a hash index value generated according to the annotation information of the callee; Constructing virtual remote call information according to the first index and the second index; The step of constructing virtual remote call information according to the first index and the second index includes: Determine whether the first index exists in the second index; If so, construct the virtual remote call information according to the method information of the first index and the second index.

2. The method according to claim 1, It is characterized in that After determining whether there is a remote call in the bytecode information, the method further includes: If not, virtual class call information is constructed according to the class inheritance key-value pairs in the bytecode information to implement the analysis of the class call relationship in the bytecode.

3. The method according to claim 2, It is characterized in that The step of constructing virtual class call information according to the class inheritance key-value pairs in the bytecode information includes: Determine the parent class method in the class inheritance key-value pair in the bytecode information; Determine whether there is an overridden parent class method in the subclass; If yes, a virtual call relationship is generated where the parent class method calls the child class method; The subclass is used as a new parent class, and the determination of whether there is an overridden parent class method in the subclass is repeated until the determination result is no.

4. The method according to claim 3, It is characterized in that After determining whether there is an overridden parent class method in the subclass, the method further includes: If not, it is considered that the parent class method exists in the subclass, and a virtual call relationship is generated in which the parent class method calls the subclass method.

5. A call relationship analysis device, It is characterized in that include: A bytecode information acquisition module, used to acquire bytecode information; A remote call determination module, used to determine whether there is a remote call in the bytecode information; A virtual remote call information construction module, for constructing virtual remote call information according to the interface information in the remote call, so as to realize the analysis of the call relationship in the bytecode; Wherein, the remote call judgment module includes: An annotation information acquisition unit, used to acquire annotation information in the interface information in the remote call; An index determination unit, used to determine a first index corresponding to the caller and a second index corresponding to the callee according to the annotation information; the first index is a hash index value generated according to the annotation information of the caller; the second index is a hash index value generated according to the annotation information of the callee; A virtual remote call information construction unit, configured to construct virtual remote call information according to the first index and the second index; The virtual remote call information construction unit includes: An index calling determination subunit, used to determine whether the first index exists in the second index; The virtual remote call information construction subunit is used to construct the virtual remote call information according to the method information of the first index and the second index.

6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the calling relationship analysis method as described in any one of claims 1-4 is implemented.

7. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the calling relationship analysis method as described in any one of claims 1 to 4 is implemented.