WO2024016729A1 - 调用冲突的可视化方法及装置 - Google Patents

调用冲突的可视化方法及装置 Download PDF

Info

Publication number
WO2024016729A1
WO2024016729A1 PCT/CN2023/085916 CN2023085916W WO2024016729A1 WO 2024016729 A1 WO2024016729 A1 WO 2024016729A1 CN 2023085916 W CN2023085916 W CN 2023085916W WO 2024016729 A1 WO2024016729 A1 WO 2024016729A1
Authority
WO
WIPO (PCT)
Prior art keywords
calling
software development
call
conflicts
conflict
Prior art date
Application number
PCT/CN2023/085916
Other languages
English (en)
French (fr)
Inventor
王梦缘
程啸
王泽宇
俞俊杰
梁广泰
Original Assignee
华为云计算技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Priority claimed from CN202211102945.5A external-priority patent/CN117472419A/zh
Application filed by 华为云计算技术有限公司 filed Critical 华为云计算技术有限公司
Publication of WO2024016729A1 publication Critical patent/WO2024016729A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Definitions

  • the present application relates to the technical field of software development, and in particular to a method and device for visualizing call conflicts.
  • third-party libraries software development libraries
  • the software development library includes multiple class files, each class file includes one or more class methods, and the class methods are used to implement corresponding functions.
  • call conflicts may occur, causing exceptions on the software development platform.
  • third-party libraries are reusable software components developed and released by entities other than the developers of the calling software platform.
  • This application provides a method and device for visualizing call conflicts.
  • This application can visualize the calling relationships with calling conflicts, so that users can locate the calling conflicts based on the call graph, thereby eliminating the causes of the calling conflicts and avoiding the occurrence of calling conflicts during the development process.
  • the technical solutions provided by this application are as follows:
  • this application provides a visual method for calling conflicts.
  • the visualization method of the call conflict includes: obtaining the target call relationship that causes the call conflict on the software development platform; based on the call chain including the target call relationship, generating a call graph reflecting the call chain; displaying the call graph.
  • call relationships with call conflicts can be visualized, so that users can locate the call conflicts based on the call graph, thereby eliminating the causes of the call conflicts and avoiding the occurrence of call conflicts during the development process.
  • calling conflicts include one or more of the following: dependency conflicts caused by incompatibility between software development libraries with dependencies used by the software development platform, and class files with the same name in different software development libraries caused by the same name. Class conflict.
  • the implementation methods for determining whether a dependency conflict occurs on a software development platform include: when there are at least two versions of the same software development library in the software development platform, a dependency conflict occurs on the software development platform.
  • the content displayed in the call graph includes: the software development library called in the calling chain, and the calling relationship between the software development libraries.
  • the software development library can be represented by the name of the software development library.
  • the implementation methods for determining dependency conflicts on the software development platform include: when there are calls to risky methods between class files with the same name in different software development libraries, determining class conflicts with the same name on the software development platform.
  • the existence of risky method calls between two class files means that one of the two class files has a call to the target class method, and the other class file of the two class files does not have a call to the target class method.
  • the content displayed in the call graph includes: the class methods called in the call chain, and the calling relationship between the class methods.
  • class methods can be represented by the method name, method type and input parameters of the class method.
  • the representation method of this class method can be called using method body to represent class method.
  • class methods include a lot of information, if all the information of the class method is displayed, the display content will be too complicated.
  • the content displayed by the call graph also includes one or more of the following: the software development library and class file to which the class method belongs.
  • the call graph also includes one or more of the software development libraries and class files to which the class method belongs, it can provide more basis for users to locate call conflicts, further improve the efficiency of users in locating call conflicts, and make it easier for users to locate call conflicts. According to actual needs, adjust the software development library to which the class method that causes the calling conflict belongs, so as to avoid the occurrence of calling conflicts.
  • the target calling relationship and the calling relationship without calling conflict can be presented in different ways.
  • By presenting target calling relationships and calling relationships without calling conflicts in different ways it is possible for users to quickly identify target calling relationships with calling conflicts, further improving the efficiency of users in locating calling conflicts.
  • class methods with different roles are represented differently in the call graph.
  • all call subjects except the call starting point are call intermediate points.
  • the method for visualizing the calling conflict also includes: determining the target software development library that causes the calling conflict; and displaying the recommended software development library used to replace the target software development library.
  • displaying the recommended software development library it is convenient for the user to use the recommended software development library to replace the target software development library, thereby eliminating the cause of the calling conflict.
  • the software development library to which the content called by the target calling relationship belongs can be determined, and the software development library to which the content called by the target calling relationship belongs can be determined.
  • Develop libraries for target software after determining the target calling relationship, the software development library to which the content called by the target calling relationship belongs can be determined, and the software development library to which the content called by the target calling relationship belongs can be determined.
  • the visualization method of calling conflicts also includes: receiving a response operation to the recommended software development library; performing the operation indicated by the response operation, and the response operation indicates The indicated actions include: Replace the target software development library with the recommended software development library.
  • the computer device can use the recommended software development library to replace the target software development library, thereby achieving accurate selection of the software development library and avoiding compilation or runtime errors. An error occurs when calling the target software development library, thereby avoiding calling conflicts caused by the target software development library on the software development platform.
  • a call graph reflecting the call chain is generated, including: based on the structure of the call chain, determining the architecture of the call graph; based on the call chain, instantiating elements of the architecture , get the call graph, the elements include nodes and edges.
  • the architecture of the call graph is used to indicate the call subjects involved in the call chain and the dependencies between the call subjects, and the dependency relationship can be expressed as a calling relationship and a called relationship.
  • the call graph can be represented by call paths.
  • the calling path can be represented using a graph including nodes and edges. Nodes can represent the call bodies involved in the call chain. Edges can represent dependencies between calling entities. For example, when the calling conflict includes a dependency conflict, the calling subject may include the software development library being called in the calling chain, and the dependency relationship may include the calling relationship between software development libraries. For another example, when the calling conflict includes a class conflict with the same name, the calling body may include the class method being called in the calling chain, and the dependency relationship may include the calling relationship between class methods.
  • the calling subject may also include one or more of the following: the software development library and class file to which the class method belongs.
  • the call graph can represent a call chain starting from the root of the dependency tree. For example, a call chain can start from the main project.
  • a call graph reflecting the call chain which also includes: optimizing the instantiated elements.
  • processing to obtain an optimized call graph so that the optimized call graph presents elements with different attributes in different ways, in which the target call relationship and the call relationship without call conflicts are presented in different ways, and/or the role
  • Different software development libraries are presented in different ways in the call graph, and the roles include the calling starting point and the calling intermediate point, and/or, class methods with different roles are presented in different ways in the call graph, and the software development library includes multiple class methods.
  • the calling subject that causes the calling conflict can be determined, and all possible calling relationships of the calling subject are target calling relationships, or in the main project developed using the software development platform , the calling relationship to the calling subject that causes the calling conflict is the target calling relationship.
  • the calling conflict is a dependency conflict
  • the calling subject is the software development library.
  • the calling conflict is a class conflict with the same name
  • the calling subject is a class method.
  • all calling relationships can be determined as candidate calling relationships, and all candidate calling relationships can be screened to obtain filtered candidate calling relationships.
  • the candidate calling relationship is the target calling relationship.
  • all candidate calling relationships are screened to obtain the filtered target calling relationships, including: performing conflict evaluation on each candidate calling relationship to obtain an evaluation result of each candidate calling relationship, and the evaluation result is used to indicate The probability that the candidate calling relationship causes a calling conflict; the candidate calling relationship whose evaluation result indicates that it meets the preset conditions is determined as the target calling relationship.
  • the candidate calling relationship can be conflict evaluated with reference to indicators, and the evaluation results of the candidate calling relationship for each indicator can be obtained.
  • conflict evaluation is performed on a candidate calling relationship with reference to multiple indicators
  • the evaluation results of the candidate calling relationship with respect to the multiple indicators can be represented by a set of evaluation results of the candidate calling relationship with respect to each of the multiple indicators.
  • the indicators used for conflict evaluation of candidate calling relationships include one or more of the following: the number of dependencies between software development libraries introduced by the candidate calling relationships, the number of calls introduced by the candidate calling relationships The number of conflicts and the degree of safety of calling conflicts introduced by candidate calling relationships.
  • the safety degree of the call conflict introduced by the candidate call relationship can be expressed by the safety degree of the software development library that causes the call conflict.
  • the security level is used to indicate the possibility of security vulnerabilities.
  • the execution timing for obtaining call conflicts arising from the software development platform can be determined based on application requirements. For example, during the life cycle of the software development platform, you can periodically detect whether a calling conflict occurs on the software development platform, and when a calling conflict occurs on the software development platform, obtain the calling conflict that occurs on the software development platform.
  • a trigger condition when a trigger condition is generated in the software development platform, it can be detected whether a calling conflict occurs in the software development platform, and when a calling conflict occurs in the software development platform, the calling conflict that occurs in the software development platform can be obtained.
  • the trigger condition can be set according to application requirements.
  • the trigger condition can be a change in the software development library, that is, when the software development library in the software development platform changes, it is detected whether a calling conflict occurs on the software development platform, and when a calling conflict occurs on the software development platform, the occurrence of a calling conflict on the software development platform is obtained.
  • the calling conflict can be a change in the software development library, that is, when the software development library in the software development platform changes, it is detected whether a calling conflict occurs on the software development platform, and when a calling conflict occurs on the software development platform, the occurrence of a calling conflict on the software development platform is obtained. The calling conflict.
  • changes include upgrades and replacements.
  • upgrading refers to upgrading the software development library in the software development platform.
  • Replacement refers to using other software development libraries to replace the software development libraries in the software development platform.
  • the calling relationship between some dependencies may change. These changes may cause calling conflicts in the software development platform. Therefore, through the software development library in the software development platform, When changes are made, the calling conflicts that occur on the software development platform can be obtained, and the calling relationships in the software development platform can be incrementally detected. When the users of the software development platform are not aware of the existence of version conflicts, the software development library can be detected in a timely manner. Calling conflicts caused by changes and visualizing the calling conflicts can help to eliminate the causes of calling conflicts in a timely manner and avoid calling conflicts during the development process.
  • the target calling relationship generated by each software development library that has been changed can also be obtained separately, and the target calling relationship generated by it can be obtained for each software development library.
  • Each software development library displays its corresponding call graph to further improve positioning efficiency and visual effects, thereby improving user experience.
  • this application provides a visualization device for calling conflicts.
  • the visualization device of the call conflict includes: a processing module, used to obtain the target call relationship that causes the call conflict to occur on the software development platform; the processing module is also used to generate a call graph reflecting the call chain based on the call chain including the target call relationship; display Module for displaying call graphs.
  • calling conflicts include one or more of the following: dependency conflicts caused by incompatibility between software development libraries with dependencies used by the software development platform, and class files with the same name in different software development libraries caused by the same name. Class conflict.
  • the content displayed in the call graph includes: the software development library being called in the calling chain, and the calling relationship between the software development libraries.
  • a class conflict with the same name occurs on the software development platform.
  • risky method call between two class files it refers to two classes. One class file in the file has a call to the target class method, and the other class file in the two class files does not have a call to the target class method.
  • the content displayed in the call graph includes: the class methods called in the call chain, and the calling relationship between class methods.
  • the class method is represented by the method name, method type and input parameters of the class method.
  • the content displayed by the call graph also includes one or more of the following: the software development library and class file to which the class method belongs.
  • the target calling relationship and the calling relationship without calling conflicts are presented in different ways; and/or, software development libraries with different roles are presented in different ways in the call graph, and the roles include the calling starting point and the calling intermediate point; and/ Or, class methods with different roles are presented differently in the call graph.
  • processing module is also used to determine the target software development library that causes the calling conflict.
  • the display module is also used to display recommended software development libraries used to replace the target software development libraries.
  • the visualization device for calling conflicts also includes: an interaction module, configured to receive response operations to the recommended software development library.
  • the processing module is also used to perform operations indicated by the response operation.
  • the operations indicated by the response operation include: replacing the target software development library with the recommended software development library.
  • the optional processing module is specifically used to: determine the architecture of the call graph based on the structure of the call chain; instantiate the elements of the architecture based on the call chain to obtain the call graph, where the elements include nodes and edges.
  • the optional processing module is also specifically used to: optimize the instantiated elements to obtain an optimized call graph, so that the optimized call graph presents elements with different attributes in different ways.
  • the target Calling relationships and calling relationships without calling conflicts are presented in different ways
  • software development libraries with different roles are presented in different ways in the call graph.
  • the roles include the calling starting point and the calling intermediate point, and/or the roles are different.
  • Class methods are represented differently in call graphs, and software development libraries include multiple class methods.
  • the processing module is specifically used to: obtain all candidate calling relationships that cause calling conflicts on the software development platform; filter all candidate calling relationships to obtain the filtered target calling relationships.
  • processing module specifically used to: perform conflict evaluation on each candidate calling relationship, and obtain the evaluation result of each candidate calling relationship.
  • the evaluation result is used to indicate the probability of a calling conflict caused by the candidate calling relationship; indicate the evaluation result
  • the candidate calling relationship that meets the preset conditions is determined as the target calling relationship.
  • the indicators used for conflict evaluation of candidate calling relationships include one or more of the following: the number of dependencies between software development libraries introduced by the candidate calling relationships, the number of calling conflicts introduced by the candidate calling relationships, the number of calling conflicts introduced by the candidate calling relationships, How safe it is to introduce calling conflicts.
  • processing module specifically used for: when the software development library changes in the software development platform, obtain the information generated by the change The resulting target call relationship.
  • changes include upgrades and replacements.
  • processing module specifically used to: obtain the target calling relationship for each software development library that has changed.
  • this application provides a computer device, including a memory and a processor.
  • the memory stores program instructions
  • the processor runs the program instructions to execute the method provided in the first aspect of this application and any possible implementation thereof. .
  • the application provides a computer-readable storage medium.
  • the computer-readable storage medium is a non-volatile computer-readable storage medium.
  • the computer-readable storage medium includes program instructions. When the program instructions are stored on a computer device, When running, the computer device is caused to execute the method provided in the first aspect of the application and any possible implementation manner thereof.
  • this application provides a computer program product containing instructions.
  • the computer program product When the computer program product is run on a computer, it causes the computer to execute the method provided in the first aspect of this application and any possible implementation thereof.
  • Figure 1 is a schematic diagram of a call conflict occurring in a software development platform provided by an embodiment of the present application
  • Figure 2 is a schematic diagram of an application scenario involved in a method for visualizing call conflicts provided by an embodiment of the present application
  • Figure 3 is a schematic diagram of an application scenario involved in another method for visualizing call conflicts provided by an embodiment of the present application
  • Figure 4 is a flow chart of a method for visualizing call conflicts provided by an embodiment of the present application.
  • Figure 5 is a schematic diagram of a dependency conflict occurrence situation provided by an embodiment of the present application.
  • Figure 6 is a schematic diagram of another dependency conflict occurrence situation provided by an embodiment of the present application.
  • Figure 7 is a flow chart for screening all candidate calling relationships and obtaining filtered target calling relationships provided by an embodiment of the present application
  • Figure 8 is a flow chart for generating a call graph reflecting the call chain based on the call chain including the target call relationship provided by the embodiment of the present application;
  • Figure 9 is an architectural schematic diagram of a call graph with dependency conflicts provided by an embodiment of the present application.
  • Figure 10 is a schematic architectural diagram of a call graph with the same name conflict provided by an embodiment of the present application.
  • Figure 11 is a schematic diagram of a call graph with dependency conflicts provided by an embodiment of the present application.
  • Figure 12 is a schematic diagram of a call graph of a class conflict with the same name provided by an embodiment of the present application.
  • Figure 13 is a schematic diagram showing a recommended software development library in a call graph with dependency conflicts provided by an embodiment of the present application
  • Figure 14 is a schematic diagram showing a recommended software development library in a call graph of a class conflict with the same name provided by an embodiment of the present application;
  • Figure 15 is a schematic structural diagram of a visualization device for calling conflicts provided by an embodiment of the present application.
  • Figure 16 is a schematic structural diagram of another visualization device for calling conflicts provided by an embodiment of the present application.
  • Figure 17 is a schematic structural diagram of a computer device provided by an embodiment of the present application.
  • the software development library includes multiple class files, each class file includes one or more class methods, and the class methods are used to implement the corresponding functions.
  • call conflicts may occur, causing exceptions on the software development platform.
  • a main project needs to call the software development library Lib2 of version 1.0 (v1.0) (that is, Lib2 (v1.0)), and the main project needs to call the software development library Lib1, software development library Lib1 It needs to depend on the software development library Lib2 of version 2.0 (v2.0) (that is, Lib2 (v2.0)). In this way, the main project needs to rely on two versions of the software development library Lib2. Under the constraints of the build environment, the main project can only arbitrate and load one version from the two versions of the software development library Lib2, and obscure the Other versions. When the class file loaded by calling the software development library is not the expected class file of the main project, it will cause abnormal behavior at build or run time, so a dependency conflict occurs.
  • different software development libraries introduced by developers may also include class files with the same name.
  • one class file includes a certain method and the other class file does not include the method.
  • This type of calling conflict can be called a calling conflict caused by class files with the same name in different software development libraries, or it can also be referred to as a Same Class Conflict (SCC).
  • SCC Same Class Conflict
  • class files with the same name are called class files with the same name.
  • Class methods that are included in one class file but not included in another class file with the same name are called risky methods of the class file with the same name. Then the class conflict with the same name can be understood as the calling conflict caused by calling the risky method in the class file with the same name.
  • the software development library Lib1 and the software development library Lib2 (v1.0) both include class file A, class file B and class file C, that is, the software development library Lib1 and the software development library Lib2 (v1.0) include the same name Class file A, class file B with the same name, and class file C with the same name.
  • the class method A1 exists in the class file A in the software development library Lib1, but the class method A1 does not exist in the class file A in the software development library Lib2 (v1.0), that is, the class method A1 is in the class file A with the same name. risk approach.
  • the main project if the main project calls class method A1, it may cause abnormal behavior at runtime. For example, if class method A1 is called through class file A in the software development library Lib2 (v1.0), it will cause Abnormal behavior at runtime caused a class conflict with the same name in the main project.
  • the display results of the current display solution cannot show whether the calling relationship will cause calling conflicts, and manual work is required. Locating call conflicts results in low efficiency in locating call conflicts.
  • all calling relationships between software development libraries in the software development platform are displayed.
  • the current display solution shows the entire dependency tree path of the software development platform. Since the software development platform includes many software development libraries and their dependency paths are huge and intricate, the visual results are not very helpful in locating call conflicts, and manual search for call conflicts is required.
  • the embodiment of this application provides a visual method for calling conflicts.
  • the target call relationship that causes a call conflict in the software development platform can be obtained; based on the call chain including the target call relationship, a call graph reflecting the call chain is generated; and the call graph is displayed.
  • the calling relationships with calling conflicts can be visualized, so that users can locate the calling conflicts based on the call graph, thereby eliminating the causes of the calling conflicts and avoiding the occurrence of calling conflicts during the development process.
  • FIG. 2 is a schematic structural diagram of an implementation environment involved in a method for visualizing call conflicts provided by an embodiment of the present application.
  • the implementation environment includes: a computer device 20.
  • the computer device 20 can run a software development platform, and users (such as developers) can use the software development platform to develop program algorithms, debug programs, and deploy and launch services implemented through the programs.
  • the computer device 20 is used to run the software development platform according to the user's instructions and display the development interface of the software development platform to the user. Furthermore, the computer device 20 is also configured to generate a call graph indicating a call conflict and display the call graph to the user.
  • the software development platform can be installed in the user's computer device 20 in the form of an application installation package for the user to use the software development platform.
  • the computer device 20 may be a terminal.
  • the terminal may be a computer, a personal computer, a portable mobile terminal, a multimedia player, an e-book reader or a wearable device, etc.
  • the devices running the software development platform and the devices displaying the development interface of the software development platform to the user may be different devices, and/or the devices running the software development platform and displaying the call graph to the user may be different devices. equipment.
  • the implementation environment may also include a client 30.
  • the user can interact with the computer device 20 through the client 30 .
  • the computer device 20 is configured to receive instructions transmitted by the user through the client 30 , run the software development platform according to the instructions, and provide visual information indicating the development interface of the software development platform to the client 30 .
  • the computer device 20 is further configured to generate a call graph indicating a call conflict and provide visual information indicating the call graph to the client 30 .
  • the client 30 is used to display the corresponding development interface and call graph based on the visual information provided by the computer device 20 .
  • the client 30 can be a computer, a personal computer, a cloud host, a portable mobile terminal, a multimedia player, an e-book reader or a wearable device, etc.
  • Computer device 20 may be a server.
  • the server can be one server, or a server cluster composed of several servers, or a cloud computing service center.
  • the software development platform can be provided through the cloud platform.
  • the server can be implemented through the cloud computing service center.
  • a large number of basic resources owned by cloud service providers are deployed in the cloud computing service center. For example, computing resources, storage resources, network resources, etc. are deployed in a cloud computing service center.
  • the cloud computing service center can use this large amount of basic resources to provide a software development platform. Accordingly, the user can access the cloud platform through the client 30 and use the software development platform provided by the cloud platform.
  • the server provides users with the function of a software development platform, which can be abstracted into a cloud platform by the cloud service provider.
  • a cloud service used for program development (hereinafter referred to as program development cloud service).
  • program development cloud service used for program development
  • the cloud platform can use the resources in the cloud computing center to provide users with a software development platform, allowing users to carry out program algorithm development and program debugging through the software development platform.
  • the cloud platform may be a central cloud cloud platform, an edge cloud cloud platform, or a cloud platform including a central cloud and an edge cloud, which are not specifically limited in the embodiments of this application.
  • the software development platform can also be implemented through other resource platforms besides the cloud platform, which is not specifically limited in the embodiments of this application.
  • the server can be implemented through resources in other resource platforms and provide users with a software development platform.
  • the method for visualizing call conflicts provided by the embodiments of the present application can be implemented by running an executable program.
  • the executable program can be independent of the executable program of the software development platform.
  • the software development platform and the method for visualizing call conflicts provided by the embodiments of the present application can be implemented through different applications respectively.
  • the application program of the software development platform and the application program used to implement the visualization method of calling conflicts can be installed in the same computer device or in different computer devices, which are not specifically limited in the embodiments of this application.
  • the executable program may be part of the executable program of the software development platform.
  • the software development platform and the method for visualizing call conflicts provided by the embodiments of the present application can be implemented through the same application program.
  • the function of calling the conflict visualization method provided by the embodiment of the present application can be implemented in the form of a software plug-in.
  • the software development platform may have multiple software plug-ins, one of which is used to implement the function of the visualization method of calling conflicts provided by the embodiment of the present application.
  • the execution timing of the visualization method for calling conflicts can be set according to application requirements.
  • calling conflicting visualization methods can be executed periodically during the life cycle of the software development platform.
  • the conflicting visualization method can be executed when a trigger condition is generated in the software development platform.
  • the trigger condition can be set according to application requirements.
  • the trigger condition can be a change in the software development library, that is, when the software development library in the software development platform is changed, the conflicting visualization method is executed.
  • the embodiments of this application mainly take the visualization method of executing the call conflict when the software development library is changed as an example to explain the implementation process of the visualization method of the call conflict.
  • the computer device can detect whether there are calling conflicts in the software development platform after changing the software development library, including detecting whether there are dependency conflicts and class conflicts with the same name in the software development platform. Call conflict.
  • the call graph including the call conflict is displayed.
  • the user can locate the call conflict based on the call graph, determine the software development library that caused the call conflict, and then locate the dependencies between different versions of the software development library and other related information. Take measures such as replacement or upgrade to eliminate the causes of calling conflicts to avoid calling conflicts during the development process.
  • the computer device can determine the software development library that causes the call conflicts and display recommended software for replacing the target software development library. development library.
  • the user can instruct the computer device to use the recommended software development library to replace the software development library that causes the calling conflict.
  • the computer device can use the recommended software development library to replace the software development library that causes the calling conflict.
  • the implementation process of the method for visualizing call conflicts provided by the embodiments of the present application. This method can be applied to computer equipment. As shown in Figure 4, the implementation process of the visualization method of calling conflicts may include the following steps:
  • Step 401 Obtain the calling conflicts that occur on the software development platform.
  • calling conflicts may occur on software development platforms.
  • calling conflicts include one or more of the following: dependency conflicts caused by incompatibility between software development libraries with dependencies used by the software development platform, and class files with the same name in different software development libraries resulting in a class conflict with the same name.
  • the embodiment of this application takes the call conflicts as dependency conflicts and class conflicts with the same name as an example to illustrate the implementation method of determining the occurrence of call conflicts on the software development platform.
  • the implementation method of determining that a dependency conflict occurs on the software development platform includes: when there are at least two versions of the same software development library in the software development platform, determining that a dependency conflict occurs on the software development platform.
  • the main project can only arbitrate and load one version from at least two versions of the same software development library, while blocking out the others.
  • Version when the class file loaded by calling the software development library is not the expected class file of the project, it may cause the reference function set of the main project to not be completely covered by the loaded class file, which will cause abnormal behavior at build or run time. That is, a dependency conflict occurs. Therefore, the computer device may determine that a dependency conflict occurs in the software development platform when at least two versions of the same software development library exist in the software development platform.
  • dependency conflicts may occur.
  • software development library A2.0 depends on software development library B1.0.
  • software development library A2.0 depends on software Development library B3.0, software development library B3.0 and software development library B2.0 are two versions of the same software development library, which may cause dependency conflicts.
  • the conflict ordered pair refers to the software development library. Assume that n versions of the same software development library appear in a main project. When the i-th version needs to be loaded, it is necessary to detect that other versions in the n versions are In the case of calling, other versions and the i-th version constitute a conflicting ordered pair.
  • the conflicting ordered pairs are ⁇ i,1>, ⁇ i,2>,..., ⁇ i, i-1>, ⁇ i,i+1>,..., ⁇ i,n>.
  • the implementation methods for determining dependency conflicts on the software development platform include: when there are calls to risky methods between class files with the same name in different software development libraries, determining class conflicts with the same name on the software development platform.
  • the existence of risky method calls between two class files means that one of the two class files has a call to the target class method, and the other class file of the two class files does not have a call to the target class method.
  • the execution timing for obtaining call conflicts arising from the software development platform can be determined based on application requirements. For example, during the life cycle of the software development platform, you can periodically detect whether a calling conflict occurs on the software development platform, and when a calling conflict occurs on the software development platform, obtain the calling conflict that occurs on the software development platform.
  • a trigger condition when a trigger condition is generated in the software development platform, it can be detected whether a calling conflict occurs in the software development platform, and when a calling conflict occurs in the software development platform, the calling conflict that occurs in the software development platform can be obtained.
  • the trigger condition can be set according to application requirements.
  • the trigger condition can be a change in the software development library, that is, when the software development library in the software development platform changes, it is detected whether a calling conflict occurs on the software development platform, and when a calling conflict occurs on the software development platform, the occurrence of a calling conflict on the software development platform is obtained.
  • the calling conflict can be a change in the software development library, that is, when the software development library in the software development platform changes, it is detected whether a calling conflict occurs on the software development platform, and when a calling conflict occurs on the software development platform, the occurrence of a calling conflict on the software development platform is obtained. The calling conflict.
  • changes include upgrades and replacements.
  • upgrading refers to upgrading the software development library in the software development platform.
  • Replacement refers to using other software development libraries to replace the software development libraries in the software development platform.
  • the calling relationship between some dependencies may change. These changes may cause calling conflicts in the software development platform. Therefore, through the software development library in the software development platform, When changes are made, the calling conflicts that occur on the software development platform can be obtained, and the calling relationships in the software development platform can be incrementally detected. When the users of the software development platform are not aware of the existence of version conflicts, the software development library can be detected in a timely manner. Calling conflicts caused by changes and visualizing the calling conflicts can help to eliminate the causes of calling conflicts in a timely manner and avoid calling conflicts during the development process.
  • the software development library can be changed automatically or manually.
  • the information indicating the dependency relationship of the software development library can be changed in the dependency file of the software development platform to implement changes to the software development library.
  • the information indicating the dependencies of the software development library such as the Group ID
  • the information indicating the dependencies of the software development library can be modified automatically or manually in dependency files such as Maven's Pom or Gradle.
  • /Artifact ID/Version and other information are modified to implement changes to the software development library in Maven.
  • Group ID and Artifact ID can be collectively referred to as "coordinates", which are used to ensure the uniqueness of the project.
  • Version is used to indicate the version of the software development library. For example, you can change the software development library from version 1.0 to version 2.0 by keeping the Group ID and Artifact ID unchanged in dependency files such as Pom or Gradle and changing the Version from 1.0 to 2.0.
  • Step 402 Obtain the target calling relationship that causes the calling conflict on the software development platform, and determine the target software development library that causes the calling conflict.
  • all calling relationships that may cause a calling conflict on the software development platform can be obtained, and all calling relationships can be used as target calling relationships.
  • the calling subject that causes the calling conflict in the process of determining the software development platform, can be determined, and all possible calling relationships of the calling subject are target calling relationships, or in the main project developed using the software development platform , the calling relationship to the calling subject that causes the calling conflict is the target calling relationship.
  • the calling conflict is a dependency conflict
  • the calling subject is the software development library.
  • the calling subject is a class method.
  • all calling relationships can be determined as candidate calling relationships, and all candidate calling relationships can be screened to obtain filtered candidate calling relationships.
  • the candidate calling relationship is the target calling relationship.
  • the target software development library that causes the call conflicts can be determined, and the software development library to which the content called by the target calling relationship belongs can be determined as Target software development library.
  • determining the target software development library that causes the calling conflict is an optional operation, and you can determine whether to perform this operation based on application requirements. For example, when the application requirements indicate that the target software development library causing the call conflict needs to be presented in the call graph, such as when the software development platform also has a software development library recommended to the user for replacing the target software development library, this operation can be performed.
  • all candidate calling relationships are screened to obtain the implementation process of the filtered target calling relationship, including:
  • Step 4021 Perform conflict evaluation on each candidate calling relationship to obtain an evaluation result of each candidate calling relationship.
  • the evaluation result is used to indicate the probability of a calling conflict caused by the candidate calling relationship.
  • the candidate calling relationship can be conflict evaluated with reference to indicators, and the evaluation results of the candidate calling relationship for each indicator can be obtained.
  • conflict evaluation is performed on a candidate calling relationship with reference to multiple indicators
  • the evaluation results of the candidate calling relationship with respect to the multiple indicators can be represented by a set of evaluation results of the candidate calling relationship with respect to each of the multiple indicators.
  • the indicators used for conflict evaluation of candidate calling relationships include one or more of the following: the number of dependencies between software development libraries introduced by the candidate calling relationships, the number of calls introduced by the candidate calling relationships The number of conflicts and the degree of safety of calling conflicts introduced by candidate calling relationships.
  • the safety degree of the call conflict introduced by the candidate call relationship can be expressed by the safety degree of the software development library that causes the call conflict.
  • the security level is used to indicate the possibility of security vulnerabilities.
  • the evaluation results of the candidate calling relationship relative to these three indicators can be represented by a set of evaluation results of the candidate calling relationship relative to each of the three indicators.
  • the candidate calling relationship when the number of dependencies between software development libraries introduced by the candidate calling relationship is 5, the number of calling conflicts introduced by the candidate calling relationship is 3, and the safety level of the calling conflicts introduced by the candidate calling relationship is 70%, the candidate calling relationship
  • the evaluation results of the relationship for these three indicators can be expressed as: ⁇ 5,3,70% ⁇ .
  • the candidate calling relationship When the number of dependencies between software development libraries introduced by the candidate calling relationship is larger, the dependency paths between the calling subjects in the call chain including the candidate calling relationship will be more complex, and the candidate calling relationship will lead to the probability of calling conflicts. The higher.
  • the calling conflict is a dependency conflict, the calling subject is the software development library.
  • the calling conflict is a class conflict with the same name, call Use the body as a class method.
  • the probability that the candidate calling relationships will cause calling conflicts is higher.
  • the safety level of the call conflict introduced by the candidate calling relationship is lower, the probability of the call conflict caused by the candidate calling relationship is higher.
  • the candidate calling relationship can be conflict evaluated based on the number of dependencies between software development libraries introduced by the candidate calling relationship, the number of calling conflicts introduced by the candidate calling relationship, and the safety level of the calling conflicts introduced by the candidate calling relationship. It should be noted that when evaluating candidate calling relationships for conflict, you can also evaluate candidate calling relationships with reference to other indicators based on application requirements, which will not be listed here.
  • Step 4022 Determine the candidate calling relationship that the evaluation result indicates satisfies the preset conditions as the target calling relationship.
  • the candidate calling relationship can be determined as the target calling relationship.
  • the preset conditions can be determined according to application requirements. For example, for the indicator of the safety degree of call conflicts introduced by candidate call relationships, if the safety degree is less than 60%, it can be considered that it will cause the software development platform to be in an unsafe state, then the preset condition for this indicator is that candidate calls can be made The safety level of calling conflicts introduced by relationships is less than 60%.
  • the execution timing of obtaining the call conflict that occurs on the software development platform can be determined according to the application requirements, and the execution timing of obtaining the target calling relationship that causes the call conflict on the software development platform can also be determined according to the application requirements.
  • the target calling relationship can be obtained immediately after each calling conflict in the software development platform is determined.
  • the target calling relationship generated by the change can also be obtained for each software development library that has changed, and the target calling relationship generated by it can be obtained for each software.
  • the development library displays its corresponding call graph to further improve positioning efficiency and visual effects, thereby improving user experience.
  • the obtained target call relationship may also include information irrelevant to generating the call graph.
  • the information used to represent the target call relationship can also be processed. Yes.
  • the processed target call relationship does not include information irrelevant to generating the call graph.
  • the dependency path before processing can be: [com.huawei.avenuesearch:SmartBlame:0.2.4::priority:0+ com.huawei.avenuesearch.org.tmatesoft.svnkit:svnkit:1.8.14_huawei_20171018::compile priority:45+ com.jcraft:jsch.agentproxy.connector-factory:0.0.7::compile priority:50+ com.jcraft:jsch.agentproxy.usocket-jna:0.0.7::compile priority:52+ net.java.dev.jna:jna:3.4.0::compile priority:-1]
  • the processed dependency path can be: [com.huawei.avenuesearch:SmartBlame:0.2.4com.huawei.avenuesearch.utility:Misc:0.0.52 com.google.code.gson:gson:2.8.2] [com.huawei.avenuesearch:SmartBlame:0.2.4com.huawei.avenuesearch.utility:Misc:0.0.52 org.apache.commons:commons-lang3:3.8] [com.huawei.avenuesearch:SmartBlame:0.2.4com.huawei.avenuesearch.org.eclipse.jgit:org.
  • Step 403 Based on the call chain including the target call relationship, generate a call graph reflecting the call chain.
  • the implementation process of step 403 includes:
  • Step 4031 Based on the structure of the call chain, determine the architecture of the call graph.
  • the entire call chain where the target call relationship is located can be obtained, and the architecture of the call graph is determined based on the call chain.
  • the architecture of the call graph is used to indicate the call subjects involved in the call chain and the dependencies between the call subjects, and the dependency relationship can be expressed as a calling relationship and a called relationship.
  • the call graph can be represented by call paths.
  • the calling path can be represented using a graph including nodes and edges. Nodes can represent the call bodies involved in the call chain. Edges can represent dependencies between calling entities. For example, when the calling conflict includes a dependency conflict, the calling subject may include the software development library being called in the calling chain, and the dependency relationship may include the calling relationship between software development libraries.
  • the calling body may include the class method being called in the calling chain, and the dependency relationship may include the calling relationship between class methods.
  • the calling subject may also include one or more of the following: the software development library and class file to which the class method belongs.
  • the call graph can represent a call chain starting from the root of the dependency tree.
  • a call chain can start from the main project.
  • the format of the call graph can be set according to application requirements.
  • the call graph may be in a scalable vector graphics (SVG) format or a portable network graphics format (PNG).
  • SVG scalable vector graphics
  • PNG portable network graphics format
  • the software development library org.springframework.boot:spring-boot-starter:2.5.3 needs to be called first, and the software development library will continue to call the software development library org.springframework.boot:spring-boot:2.5 .2.
  • the call graph can include the contents of the two call chains, and the architecture of the call graph can be generated based on the structures of the two call chains respectively.
  • the architecture of the call graph can indicate two parallel call paths. One call path involves calls to two call subjects, the other call path involves calls to three call subjects, and the two call paths start from Starting from the same calling starting point, they finally converge to calls to the same calling subject.
  • the calling subject is the software development library.
  • class method SearchSourceBuilder:org.elasticsearch.common.xcontent.XContentBuilder toXConten class method .XContentBuilder:org.elasticsearch.common.xcontent.XContentBuilder field
  • the main project's call path to class methods can be represented by a call chain. Assume that there is a call conflict in the call to the class method json.JsonXContentGenerator:void writeStringField.
  • the structure of the call graph can be generated based on the structure of this call chain.
  • the architecture of the call graph can refer to shows a call path that involves calls to five call subjects.
  • the call body is a class method.
  • Step 4032 Based on the call chain, instantiate elements of the architecture to obtain a call graph.
  • the elements include nodes and edges.
  • the elements of the architecture can be instantiated according to the call subjects in the call chain and the dependencies between the call subjects to obtain the call graph.
  • the content displayed by the call graph includes: the software development library called in the call chain, and the calling relationship between the software development libraries ;
  • the content displayed in the call graph includes: the class methods called in the call chain, and the calling relationship between class methods.
  • the content displayed in the call graph also includes one or more of the following: the software development library and class file to which the class method belongs.
  • the call graph also includes one or more of the software development libraries and class files to which the class method belongs, it can provide more basis for users to locate call conflicts, further improve the efficiency of users in locating call conflicts, and make it easier for users to locate call conflicts. According to actual needs, adjust the software development library to which the class method that causes the calling conflict belongs, so as to avoid the occurrence of calling conflicts.
  • the software development library can be represented by the name of the software development library in the call graph.
  • the software development library org.springframework.boot:spring-boot-starter:2.5.3, in the call graph, "org.springframework.boot:spring-boot-starter:2.5.3" represents the software development library.
  • a class method can be represented in a call graph using the method name, method type, and input parameters of the class method.
  • the representation method of this class method can be called using method body to represent class method.
  • ToXContentToBytes Java.lang.String toString(org.elasticsearch.common.xcontent.ToXContent$-Params)
  • “ToXContentToBytes” represents the method name of the class method
  • "java.lang.String toString” represents the method type of this class
  • the content in parentheses represents the input parameters of this class method. Since class methods include a lot of information, if all the information of a class method is displayed, the display content will be too complicated.
  • the method name, method type and input parameters to represent the class method it is easier for users to view the calling subject in the calling path of the class method. , and determine the class file and software development library to which the calling subject belongs, and then adapt and modify it.
  • the software development library represented by each node in the architecture can be determined based on the dependency relationship between the software development library called by the main project and the call shown in 11. picture.
  • the first node in the call graph represents the main project com.huawei.fossbot:migrate-agent:1.0.0.110
  • the first node in the call path on the left side of the call graph represents the software development library org.springframework .boot:spring-boot-starter:2.5.3
  • the second node in the call path on the left represents the software development library org.springframework.boot:spring-boot:2.5.2, the call path on the right in the call graph
  • the first node represents the software development library om.huaweicloud:spring-boot-starter-huawei:0.2.0-RELEASE
  • the second node in the calling path on the right represents the software development library org.spring framework.boot:spring-boot -test:2.5.
  • the class method represented by each node in the architecture can be determined based on the main project method, the class method it calls and the dependencies between them, and the call graph shown in Figure 12 is obtained.
  • the first node in the call graph represents the method com.huawei.avenuesearch.common.response.PartResult scroll of the main project
  • the second node in the graph represents the class method ToXContentToBytes:java.lang.String toString.
  • the third node represents the class method ToXContentToBytes:java.lang.String toString(org.elasticsearch.common.xcontent.ToXContent$-Params)
  • the fourth node represents the class method SearchSourceBuilder:org.elasticsearch.common. xcontent.XContentBuilder toXConten
  • the fifth node represents
  • the sixth node represents the class method json.Json XContentGenerator:void writeStringField.
  • Step 4033 Optimize the instantiated elements to obtain an optimized call graph, so that the optimized call graph presents elements with different attributes in different ways.
  • the instantiated elements in the call graph can also be optimized to obtain an optimized call graph, thereby optimizing the visual effect of the call graph.
  • an optimized call graph elements with different attributes are rendered differently.
  • the target call relationship and the call relationship without call conflicts are presented in different ways.
  • solid arrows can be used to represent call relationships without call conflicts
  • dotted arrows can be used to represent call relationships without call conflicts.
  • Roles include call origins and call midpoints. Among them, in the call path, all call subjects except the call starting point are call intermediate points. For example, in an optimized call graph, a bold font can be used to represent the software development library that is the starting point of the call, and a normal thickness font can be used to represent the software development library that is the middle point of the call.
  • Roles include call origins and call midpoints. Among them, in the call path, all call subjects except the call starting point are call intermediate points. For example, in an optimized call graph, bold fonts can be used to represent class methods that are the starting point of the call, and normal-weight fonts can be used to represent class methods that are the intermediate points of the call.
  • this step 4033 is an optional execution step, and whether to execute this step can be determined according to application requirements during the process of generating the call graph. For example, if the application requirement requires displaying a call graph with better user experience, the implementation process of step 403 may also include step 4033.
  • Step 404 Display the call graph and display the recommended software development library used to replace the target software development library.
  • the computer device can display the call graph based on the information used to represent the call graph.
  • the call graph displayed by the computer device is as shown in FIG. 11 .
  • the call graph displayed by the computer device is as shown in FIG. 12 .
  • the visualization method of calling conflicts provided by the embodiment of the present application can also obtain the recommended software development library, and the recommended software library is used to replace the target software development library. Then the computer device can also display the recommended software development library, so that the user can use the recommended software development library to replace the target software development library, thereby eliminating the cause of the calling conflict.
  • the computer device can display the recommended software development library in the display interface of the call graph, and prompt the user that the recommended software development library is recommended for the target call relationship. For example, when the calling conflict includes a dependency conflict, it may be prompted that the recommended software development library is for the target software development library that causes the calling conflict.
  • the recommended software development library org.springframework.boot:spring-boot:2.5.6 is displayed in the display interface, and the recommended software development library is used to replace the software development library org.springframework.boot:spring- boot:2.5.2 prompt (as shown by the double-headed arrow in Figure 13).
  • the calling conflict includes a class conflict with the same name
  • there is a target software development library that causes the class conflict with the same name and a prompt is given that the recommended software development library is for the target software development library that causes the calling conflict.
  • the class method json.JsonXContentGenerator:void writeStringField is a risky method that causes class conflicts with the same name.
  • the target software development library to which this risky method belongs is the software development library org.spring framework.boot:spring-boot:2.5.2 , the display interface shows that the recommended software development library org.springframework.boot:spring-boot:2.5.6 is displayed, and the recommended software development library is used to replace the software development library org.springframework.boot:spring-boot:2.5.2. prompt (as shown by the two-way arrow in Figure 14).
  • the computer device can display a button prompting the recommended software development library in the display interface of the call graph.
  • the user views the call graph, if he wants to view the recommended software development library , which can be clicked to instruct the computer device to display recommended software development libraries.
  • displaying the recommended software development library for replacing the target software development library is an optional operation, and you can determine whether to perform this operation based on application requirements. For example, this operation can be performed when the application requirements indicate that the target software development library that causes the call conflict needs to be presented in the call graph, and the software development platform also has a software development library recommended to the user for replacing the target software development library.
  • Step 405 Receive a response operation for the recommended software development library.
  • the user can respond to the recommended software development library, such as instructing the computer device to use the recommended software development library to replace the target software development library, or to refuse to use the recommended software development library to replace the target software development library. Therefore, the computer device can receive the user's response operations to the recommended software development library.
  • Step 406 Execute the operation indicated by the response operation.
  • the operation indicated by the response operation includes: replacing the target software development library with the recommended software development library.
  • the computer device After receiving the user's response operation to the recommended software development library, the computer device can perform the operation indicated by the response operation. For example, when the operation indicated by the response operation is to use the recommended software development library to replace the target software development library, the computer device can use the recommended software development library to replace the target software development library, thereby achieving precise selection of the software development library and avoiding compilation or runtime Due to errors in calling the target software development library, the software development platform can avoid calling conflicts caused by the target software development library.
  • the target call relationship that causes the call conflict to occur on the software development platform can be obtained; based on the call chain including the target call relationship, a call graph reflecting the call chain is generated; and display the call graph.
  • the calling relationships with calling conflicts can be visualized, so that users can locate the calling conflicts based on the call graph, thereby eliminating the causes of the calling conflicts and avoiding the occurrence of calling conflicts during the development process.
  • the sequence of the steps of the method for visualizing conflict calls provided by the embodiments of the present application can be adjusted appropriately, and the steps can also be increased or decreased accordingly according to the situation. Any person familiar with the technical field can easily think of changing methods within the technical scope disclosed in this application, which should be covered by the protection scope of this application, and therefore will not be described again.
  • the method for visualizing call conflicts provided by the embodiments of the present application may not be limited to deploying containers. For example, it may also be used to deploy other virtual instances that need to rely on virtual devices to run, which is not specifically limited in the embodiments of the present application.
  • the calling conflict visualization device 150 includes:
  • the processing module 1501 is used to obtain the target calling relationship that causes calling conflicts on the software development platform;
  • the processing module 1501 is also configured to generate a call graph reflecting the call chain based on the call chain including the target call relationship;
  • Display module 1502 is used to display the call graph.
  • calling conflicts include one or more of the following: dependency conflicts caused by incompatibility between software development libraries with dependencies used by the software development platform, and class files with the same name in different software development libraries caused by the same name. Class conflict.
  • the content displayed in the call graph includes: the software development library being called in the calling chain, and the calling relationship between the software development libraries.
  • a class conflict with the same name occurs on the software development platform.
  • risky method call between two class files it refers to two classes. One class file in the file has a call to the target class method, and the other class file in the two class files does not have a call to the target class method.
  • the content displayed in the call graph includes: the class methods called in the call chain, and the calling relationship between class methods.
  • the class method is represented by the method name, method type and input parameters of the class method.
  • the content displayed by the call graph also includes one or more of the following: the software development library and class file to which the class method belongs.
  • the target calling relationship and the calling relationship without calling conflicts are presented in different ways; and/or, software development libraries with different roles are presented in different ways in the call graph, and the roles include the calling starting point and the calling intermediate point; and/ Or, class methods with different roles are presented differently in the call graph.
  • processing module 1501 is also used to determine the target software development library that causes the calling conflict.
  • the display module 1502 is also used to display the recommended software development library used to replace the target software development library.
  • the visualization device 150 for calling conflicts also includes: an interaction module 1503, configured to receive a response operation to the recommended software development library.
  • the processing module 1501 is also configured to perform operations indicated by the response operation.
  • the operations indicated by the response operation include: replacing the target software development library with the recommended software development library.
  • the processing module 1501 is specifically used to: determine the architecture of the call graph based on the structure of the call chain; instantiate elements of the architecture based on the call chain to obtain a call graph, where the elements include nodes and edges.
  • the processing module 1501 is specifically also used to: optimize the instantiated elements to obtain an optimized call graph, so that the optimized call graph presents elements with different attributes in different ways, where, The target calling relationship and the calling relationship without calling conflicts are presented in different ways, and/or software development libraries with different roles are presented in different ways in the call graph.
  • the roles include the calling starting point and the calling intermediate point, and/or the roles are different.
  • Class methods are presented differently in the call graph, and the software development library includes multiple class methods.
  • the processing module 1501 is specifically used to: obtain all candidate calling relationships that cause calling conflicts on the software development platform; filter all candidate calling relationships to obtain the filtered target calling relationships.
  • the processing module 1501 is specifically configured to: perform conflict evaluation on each candidate calling relationship, and obtain the evaluation result of each candidate calling relationship.
  • the evaluation result is used to indicate the probability of a calling conflict caused by the candidate calling relationship; and convert the evaluation result to Indicates that the candidate calling relationship that satisfies the preset condition is determined as the target calling relationship.
  • the indicators used for conflict evaluation of candidate calling relationships include one or more of the following: the number of dependencies between software development libraries introduced by the candidate calling relationships, the number of calling conflicts introduced by the candidate calling relationships, the number of calling conflicts introduced by the candidate calling relationships, How safe it is to introduce calling conflicts.
  • the processing module 1501 is specifically used to: when the software development library in the software development platform is changed, obtain the The target call relationship caused by the change.
  • changes include upgrades and replacements.
  • processing module 1501 is specifically configured to obtain the target calling relationship for each software development library that has been changed.
  • the acquisition module can obtain the target call relationship that causes the call conflict on the software development platform; the processing module can generate a reflected call based on the call chain including the target call relationship.
  • the call graph of the chain; the display module can display the call graph.
  • FIG 17 is a schematic structural diagram of a computer device provided by an embodiment of the present application.
  • the computer device 1700 includes a processor 1701, a memory 1702, a communication interface 1703 and a bus 1704.
  • the processor 1701, the memory 1702, and the communication interface 1703 implement communication connections between each other through the bus 1704.
  • Processor 1701 may include a general-purpose processor and/or a special-purpose hardware chip.
  • General-purpose processors can include: central processing unit (CPU), microprocessor or graphics processing unit (GPU).
  • the CPU is, for example, a single-core processor (single-CPU) or a multi-core processor (multi-CPU).
  • a dedicated hardware chip is a high-performance processing hardware module.
  • Specialized hardware chips include at least one of a digital signal processor, an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or a network processor (NP) One item.
  • the processor 1701 may also be an integrated circuit chip with signal processing capabilities. During the implementation process, part or all of the functions of the conflict-calling visualization method of this application can be completed by instructions in the form of hardware integrated logic circuits or software in the processor 1701 .
  • the memory 1702 is used to store computer programs, including an operating system 1702a and executable codes (ie, program instructions) 1702b.
  • the memory 1702 is, for example, a read-only memory or other type of static storage device that can store static information and instructions, or a random access memory or other type of dynamic storage device that can store information and instructions, or an electrically erasable programmable memory device.
  • the memory 1702 is used to store outbound port queues, etc.
  • the memory 1702 exists independently, for example, and is connected to the processor 1701 through a bus 1704 . Or the memory 1702 and the processor 1701 are integrated together.
  • the memory 1702 may store executable code.
  • the processor 1701 is used to perform part or all of the functions of the visualization method for calling conflicts provided by the embodiment of the present application.
  • the processor 1701 performs the following process: obtains the target call relationship that causes a call conflict on the software development platform; generates a call graph reflecting the call chain based on the call chain including the target call relationship; and displays the call graph. Please refer to the relevant descriptions in the method embodiments of this application for the implementation method of the processor 1701 executing this process.
  • the memory 1702 may also include an operating system, etc. Other software modules and data required to run the process, etc.
  • the communication interface 1703 uses a transceiver module such as but not limited to a transceiver to implement communication with other devices or communication networks.
  • a transceiver module such as but not limited to a transceiver to implement communication with other devices or communication networks.
  • the communication interface 1703 can be any one or any combination of the following devices: a network interface (such as an Ethernet interface), a wireless network card, and other devices with network access functions.
  • Bus 1704 is any type of communication bus used to interconnect internal components of a computer device (eg, memory 1702, processor 1701, communication interface 1703).
  • a computer device eg, memory 1702, processor 1701, communication interface 1703.
  • system bus For example, system bus.
  • This embodiment of the present application takes as an example the interconnection of the above-mentioned devices inside the computer device through the bus 1704.
  • the above-mentioned devices inside the computer device 1700 may also communicate with each other using other connection methods besides the bus 1704.
  • the above-mentioned devices inside the computer device 1700 are interconnected through internal logical interfaces.
  • the above-mentioned plurality of devices can be respectively arranged on independent chips, or at least part or all of them can be arranged on the same chip. Whether each device is independently installed on different chips or integrated on one or more chips often depends on the needs of product design.
  • the embodiments of this application do not limit the specific implementation forms of the above devices.
  • the descriptions of the processes corresponding to each of the above drawings have different emphases. For parts that are not detailed in a certain process, you can refer to the relevant descriptions of other processes.
  • the above embodiments it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof.
  • software it may be implemented in whole or in part in the form of a computer program product.
  • the computer program product that provides a software development platform includes one or more computer instructions. When these computer program instructions are loaded and executed on a computer device, the process or function of the visualization method for calling conflicts provided by the embodiments of the present application is fully or partially implemented.
  • Computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another.
  • computer instructions may be transmitted over a wired connection from a website, computer, server or data center. (such as coaxial cable, optical fiber, digital subscriber line or wireless (such as infrared, wireless, microwave, etc.) transmission to another website, computer, server or data center.
  • Computer-readable storage media storage provides a software development platform Computer program instructions.
  • Embodiments of the present application also provide a computer-readable storage medium.
  • the computer-readable storage medium may be a non-volatile computer-readable storage medium.
  • the computer-readable storage medium includes program instructions. When the program instructions are stored on a computer device, When running, the computer device is caused to execute the visualization method of calling conflicts as provided by the embodiment of the present application.
  • Embodiments of the present application also provide a computer program product containing instructions.
  • the computer program product When the computer program product is run on a computer, it causes the computer to execute the method for visualizing call conflicts provided by embodiments of the present application.
  • the program can be stored in a computer-readable storage medium.
  • the above-mentioned The storage medium can be read-only memory, magnetic disk or optical disk, etc.
  • the information including but not limited to user equipment information, user personal information, etc.
  • data including but not limited to data used for analysis, stored data, displayed data, etc.
  • signals involved in this application All are authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.
  • the terms “first”, “second” and “third” are only used for descriptive purposes and cannot be understood as indicating. or imply relative importance.
  • the term “at least one” refers to one or more, and the term “plurality” refers to two or more, unless expressly limited otherwise.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

本申请公开了一种调用冲突的可视化方法及装置,属于软件开发技术领域。该方法包括:获取导致软件开发平台出现调用冲突的目标调用关系;基于包括目标调用关系的调用链,生成反映调用链的调用图;显示调用图。本申请能够对存在调用冲突的调用关系进行可视化,以便于用户基于调用图定位调用冲突,进而解除调用冲突出现的原因,避免在开发过程中发生调用冲突。

Description

调用冲突的可视化方法及装置
本申请要求于2022年07月21日提交的申请号为202210864804.0、发明名称为“可视化方法及装置”的中国专利申请的优先权,及于2022年09月09日提交的申请号为202211102945.5、发明名称为“调用冲突的可视化方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本公开中。
技术领域
本申请涉及软件开发技术领域,特别涉及一种调用冲突的可视化方法及装置。
背景技术
软件开发过程中,为了提高软件开发效率、保证软件开发质量,开发者通常会从开源社区向软件开发平台中引入大量的软件开发库(也称三方软件开发库,简称三方库(third-party library)),以通过不同的软件开发库实现不同的功能。软件开发库包括多个类文件,每个类文件包括一种或多种类方法,类方法用于实现对应的功能。在对软件开发库、类文件和类方法中任一者进行调用时,有可能会出现调用冲突,导致软件开发平台出现异常。其中,三方库是由调用软件平台的开发者以外的实体开发和发布的可重用软件组件。
目前,为了便于开发人员能够了解软件开发平台对软件开发库的调用能力,可以对软件开发平台中软件开发库之间的调用关系进行展示。
但是,该展示方案的展示结果无法展示调用关系是否会导致调用冲突,导致对调用冲突进行定位的效率较低。
发明内容
本申请提供了一种调用冲突的可视化方法及装置。本申请能够对存在调用冲突的调用关系进行可视化,以便于用户基于调用图定位调用冲突,进而解除调用冲突出现的原因,避免在开发过程中发生调用冲突。本申请提供的技术方案如下:
第一方面,本申请提供了一种调用冲突的可视化方法。该调用冲突的可视化方法包括:获取导致软件开发平台出现调用冲突的目标调用关系;基于包括目标调用关系的调用链,生成反映调用链的调用图;显示调用图。
通过本申请提供的调用冲突的可视化方法,能够对存在调用冲突的调用关系进行可视化,以便于用户基于调用图定位调用冲突,进而解除调用冲突出现的原因,避免在开发过程中发生调用冲突。
可选的,调用冲突包括以下一种或多种:软件开发平台使用的存在依赖关系的软件开发库之间不兼容导致的依赖冲突,以及,不同软件开发库中名称相同的类文件导致的同名类冲突。
对于依赖冲突,确定软件开发平台出现依赖冲突的实现方式包括:在软件开发平台中存在同一软件开发库的至少两个版本时,软件开发平台出现依赖冲突。
其中,导致软件开发平台出现依赖冲突的情况可以有多种,本申请以以下两种产生情况为例进行举例说明。
在依赖冲突的第一种产生情况中,在更新软件开发平台中的软件开发库,且更新后的软件开发库依赖的软件开发库随之发生变化时,若更新后的软件开发库依赖的软件开发库与软件开发平台原有的软件开发库分别为同一软件开发库的不同版本,则可能会引起依赖冲突。
在依赖冲突的第二种产生情况中,在更新软件开发平台中的软件开发库,且更新后的软件开发库依赖的软件开发库不变化时,若更新后的软件开发库依赖的软件开发库与软件开发平台原有的软件开发库分别为同一软件开发库的不同版本,则可能会引起依赖冲突。
在一种可实现方式中,当调用冲突包括依赖冲突时,调用图显示的内容包括:调用链中被调用的软件开发库,及软件开发库之间的调用关系。并且,在调用图中,软件开发库可以使用软件开发库的名称表示。
对于同名类冲突,确定软件开发平台出现依赖冲突的实现方式包括:在不同软件开发库中名称相同的类文件之间存在风险方法的调用时,确定软件开发平台出现同名类冲突。其中,两个类文件之间存在风险方法的调用是指两个类文件中一个类文件存在对目标类方法的调用,且两个类文件中另一个类文件不存在对目标类方法的调用。
在一种可实现方式中,当调用冲突包括同名类冲突时,调用图显示的内容包括:调用链中被调用的类方法,及类方法之间的调用关系。并且,在调用图中,类方法可以使用类方法的方法名、方法类型和输入参数表示。该类方法的表示方式可以称为采用方法体表示类方法。另外,由于类方法包括较多信息,若展示类方法的全部信息,其展示内容会过于繁杂,通过使用方法名、方法类型和输入参数表示类方法,能够便于用户查看类方法的调用路径中的调用主体,并确定调用主体所属类文件和软件开发库库,进而进行适配与修改。
可选的,调用图显示的内容还包括以下一个或多个:类方法所属的软件开发库和类文件。当调用图还包括类方法所属的软件开发库和类文件中的一个或多个时,能够为用户定位调用冲突提供更多的依据,进一步地提高可用户定位调用冲突的效率,且能够便于用户根据实际的需求对导致调用冲突的类方法所属的软件开发库进行调整,从而避免调用冲突的发生。
在一种可实现方式中,目标调用关系和未出现调用冲突的调用关系可以采用不同方式呈现。通过采用不同的方式呈现目标调用关系和未出现调用冲突的调用关系,能够便于用户快速地识别出现调用冲突的目标调用关系,进一步地提高可用户定位调用冲突的效率。
和/或,角色不同的软件开发库在调用图中的呈现方式不同,角色包括调用起点和调用中间点。其中,在调用路径中,除调用起点外的所有调用主体均为调用中间点。通过采用不同的方式呈现角色不同的软件开发库,能够便于用户了解主项目的整体架构,分析导致调用冲突的原因,提高解除导致调用冲突的原因的效率。
和/或,角色不同的类方法在调用图中的呈现方式不同。其中,在调用路径中,除调用起点外的所有调用主体均为调用中间点。通过采用不同的方式呈现角色不同的类方法,能够便于用户了解主项目的整体架构,分析导致调用冲突的原因,提高解除导致调用冲突的原因的效率。
可选的,该调用冲突的可视化方法还包括:确定引起调用冲突的目标软件开发库;显示用于替换目标软件开发库的推荐软件开发库。通过显示推荐软件开发库,能够便于用户使用该推荐软件开发库替换目标软件开发库,从而解除导致调用冲突的原因。
在确定目标软件开发库的一种实现方式中,在确定目标调用关系后,可以确定该目标调用关系调用的内容所属的软件开发库,并将目标调用关系调用的内容所属的软件开发库确定 为目标软件开发库。
可选的,在显示用于替换目标软件开发库的推荐软件开发库之后,该调用冲突的可视化方法还包括:接收对推荐软件开发库的响应操作;执行响应操作所指示的操作,响应操作所指示的操作包括:使用推荐软件开发库替换目标软件开发库。当响应操作所指示的操作为使用推荐软件开发库替换目标软件开发库时,计算机设备可以使用推荐软件开发库替换目标软件开发库,从而实现对软件开发库的精确选择,避免编译或运行时因调用目标软件开发库出错,进而避免软件开发平台出现因目标软件开发库导致的调用冲突。
在一种可实现方式中,基于包括目标调用关系的调用链,生成反映调用链的调用图,包括:基于调用链的结构,确定调用图的架构;基于调用链,对架构的元素进行实例化,得到调用图,元素包括节点和边。
调用图的架构用于指示调用链涉及的调用主体以及调用主体之间的依赖关系,且依赖关系可以表现为调用关系和被调用关系。在一种实现方式中,调用图可以通过调用路径表示。并且,调用路径可以使用包括节点和边的图表示。节点可以表示调用链涉及的调用主体。边可以表示调用主体之间的依赖关系。例如,当调用冲突包括依赖冲突时,调用主体可以包括调用链中被调用的软件开发库,依赖关系可以包括软件开发库之间的调用关系。又例如,当调用冲突包括同名类冲突时,调用主体可以包括调用链中被调用的类方法,依赖关系可以包括类方法之间的调用关系。并且,当调用冲突包括同名类冲突时,调用主体还可以包括以下一个或多个:类方法所属的软件开发库和类文件。另外,调用图可以表示的调用链可以从依赖树根为起点。例如,调用链可以以主项目为起点。
可选的,在基于调用链,对架构的元素进行实例化,得到调用图之后,基于包括目标调用关系的调用链,生成反映调用链的调用图,还包括:对实例化后的元素进行优化处理,得到经过优化处理的调用图,使得经过优化处理的调用图对不同属性的元素的呈现方式不同,其中,目标调用关系和未出现调用冲突的调用关系采用不同方式呈现,和/或,角色不同的软件开发库在调用图中的呈现方式不同,角色包括调用起点和调用中间点,和/或,角色不同的类方法在调用图中的呈现方式不同,软件开发库包括多个类方法。通过对调用图中实例化后的元素进行优化处理,能够优化调用图的视觉效果。
在获取导致软件开发平台出现调用冲突的目标调用关系的一种实现方式中,在确定软件开发平台出现调用冲突后,可以获取可能导致软件开发平台出现调用冲突的所有调用关系,并将所有调用关系均作为目标调用关系。在一种实现方式中,在确定软件开发平台的过程中能够确定确定引起调用冲突的调用主体,该调用主体所有可能的调用关系为目标调用关系,或者,在使用软件开发平台开发的主项目中,对引起调用冲突的调用主体的调用关系为目标调用关系。示例的,当调用冲突为依赖冲突时,调用主体为软件开发库。当调用冲突为同名类冲突时,调用主体为类方法。
或者,在获取导致软件开发平台出现调用冲突的所有调用关系后,可以将该所有调用关系确定为候选调用关系,并对所有候选调用关系进行筛选,得到经过筛选的候选调用关系,该经过筛选的候选调用关系即为目标调用关系。其中,由于可能导致软件开发平台出现调用冲突的候选调用关系较多,但是不同候选调用关系真正引起调用冲突的概率不同,因此在确定候选调用关系后,可以对候选调用关系进行筛选,并基于经过筛选的候选调用关系显示调用图。这样一来,能够减少需要用户查看的调用图,避免因需要用户查看较多的调用图导致 用户体验较差。并且,通过对候选调用关系进行筛选,能够保证显示的调用图包括的候选调用关系均为具有较高概率引起调用冲突的调用关系,进而有效避免在开发过程中发生调用冲突。
在一种实现方式中,对所有候选调用关系进行筛选,得到经过筛选的目标调用关系,包括:对每个候选调用关系进行冲突评估,得到每个候选调用关系的评估结果,评估结果用于指示候选调用关系导致出现调用冲突的概率;将评估结果指示满足预设条件的候选调用关系确定为目标调用关系。
在一种可实现方式中,可以参考指标对候选调用关系进行冲突评估,得到候选调用关系针对每个指标的评估结果。当参考多个指标对候选调用关系进行冲突评估时,候选调用关系相对于多个指标的评估结果,可以采用候选调用关系相对于多个指标中每个指标的评估结果的集合表示。
可选的,在本申请实施例中,对候选调用关系进行冲突评估使用的指标包括以下一个或多个:候选调用关系引入的软件开发库之间的依赖关系的数量,候选调用关系引入的调用冲突的数量,候选调用关系引入的调用冲突的安全程度。在一种实现方式中,候选调用关系引入的调用冲突的安全程度,可以通过引起调用冲突的软件开发库的安全程度表示。其中,安全程度用于指示出现安全漏洞的可能性。
可选的,获取软件开发平台出现的调用冲突的执行时机可以根据应用需求确定。例如,可以在软件开发平台的生命周期中,周期性地检测软件开发平台是否出现调用冲突,并在软件开发平台出现调用冲突时,获取软件开发平台出现的调用冲突。或者,可以在软件开发平台中产生触发条件时,检测软件开发平台是否出现调用冲突,并在软件开发平台出现调用冲突时,获取软件开发平台出现的调用冲突。该触发条件可以根据应用需求设置。例如,触发条件可以为软件开发库发生变更,即在软件开发平台中的软件开发库发生变更时,检测软件开发平台是否出现调用冲突,并在软件开发平台出现调用冲突时,获取软件开发平台出现的调用冲突。
在一种实现方式中,变更包括升级和替换。其中,升级是指对软件开发平台中的软件开发库进行升级。替换是指使用其他软件开发库替换软件开发平台中的软件开发库。
在软件开发平台中软件开发库发生变更的场景下,可能会导致一些依赖间的调用关系发生变化,这些变化可能会导致软件开发平台出现调用冲突,因此,通过在软件开发平台中软件开发库发生变更时,获取软件开发平台出现的调用冲突,可以对软件开发平台中的调用关系进行增量检测,能够在使用软件开发平台的用户未察觉到存在版本冲突时,及时地检测到因软件开发库的变更导致的调用冲突,并对该调用冲突进行可视化,有助于及时地解除导致调用冲突的原因,避免在开发过程中发生调用冲突。
可选的,当在软件开发库发生变更,执行获取由变更导致的目标调用关系的操作时,还可以针对发生变更的每个软件开发库,分别获取因其产生的目标调用关系,并针对每个软件开发库显示其对应的调用图,以进一步提高定位效率和可视化的视觉效果,从而提高用户体验。
第二方面,本申请提供了一种调用冲突的可视化装置。该调用冲突的可视化装置包括:处理模块,用于获取导致软件开发平台出现调用冲突的目标调用关系;处理模块,还用于基于包括目标调用关系的调用链,生成反映调用链的调用图;显示模块,用于显示调用图。
可选的,调用冲突包括以下一种或多种:软件开发平台使用的存在依赖关系的软件开发库之间不兼容导致的依赖冲突,以及,不同软件开发库中名称相同的类文件导致的同名类冲突。
可选的,在软件开发平台中存在同一软件开发库的至少两个版本时,软件开发平台出现依赖冲突。
可选的,当调用冲突包括依赖冲突时,调用图显示的内容包括:调用链中被调用的软件开发库,及软件开发库之间的调用关系。
可选的,在不同软件开发库中名称相同的类文件之间存在风险方法的调用时,软件开发平台出现同名类冲突,其中,两个类文件之间存在风险方法的调用是指两个类文件中一个类文件存在对目标类方法的调用,且两个类文件中另一个类文件不存在对目标类方法的调用。
可选的,当调用冲突包括同名类冲突时,调用图显示的内容包括:调用链中被调用的类方法,及类方法之间的调用关系。
可选的,类方法采用类方法的方法名、方法类型和输入参数表示。
可选的,调用图显示的内容还包括以下一个或多个:类方法所属的软件开发库和类文件。
可选的,目标调用关系和未出现调用冲突的调用关系采用不同方式呈现;和/或,角色不同的软件开发库在调用图中的呈现方式不同,角色包括调用起点和调用中间点;和/或,角色不同的类方法在调用图中的呈现方式不同。
可选的,处理模块,还用于确定引起调用冲突的目标软件开发库。
相应的,显示模块,还用于显示用于替换目标软件开发库的推荐软件开发库。
可选的,调用冲突的可视化装置还包括:交互模块,用于接收对推荐软件开发库的响应操作。
相应的,处理模块,还用于执行响应操作所指示的操作,响应操作所指示的操作包括:使用推荐软件开发库替换目标软件开发库。
可选的,处理模块,具体用于:基于调用链的结构,确定调用图的架构;基于调用链,对架构的元素进行实例化,得到调用图,元素包括节点和边。
可选的,处理模块,具体还用于:对实例化后的元素进行优化处理,得到经过优化处理的调用图,使得经过优化处理的调用图对不同属性的元素的呈现方式不同,其中,目标调用关系和未出现调用冲突的调用关系采用不同方式呈现,和/或,角色不同的软件开发库在调用图中的呈现方式不同,角色包括调用起点和调用中间点,和/或,角色不同的类方法在调用图中的呈现方式不同,软件开发库包括多个类方法。
可选的,处理模块,具体用于:获取导致软件开发平台出现调用冲突的所有候选调用关系;对所有候选调用关系进行筛选,得到经过筛选的目标调用关系。
可选的,处理模块,具体用于:对每个候选调用关系进行冲突评估,得到每个候选调用关系的评估结果,评估结果用于指示候选调用关系导致出现调用冲突的概率;将评估结果指示满足预设条件的候选调用关系确定为目标调用关系。
可选的,对候选调用关系进行冲突评估使用的指标包括以下一个或多个:候选调用关系引入的软件开发库之间的依赖关系的数量,候选调用关系引入的调用冲突的数量,候选调用关系引入的调用冲突的安全程度。
可选的,处理模块,具体用于:在软件开发平台中软件开发库发生变更时,获取由变更 导致的目标调用关系。
可选的,变更包括升级和替换。
可选的,处理模块,具体用于:针对发生变更的每个软件开发库分别获取目标调用关系。
第三方面,本申请提供了一种计算机设备,包括存储器和处理器,存储器存储有程序指令,处理器运行程序指令以执行本申请第一方面以及其任一种可能的实现方式中提供的方法。
第四方面,本申请提供了一种计算机可读存储介质,该计算机可读存储介质为非易失性计算机可读存储介质,该计算机可读存储介质包括程序指令,当程序指令在计算机设备上运行时,使得计算机设备执行本申请第一方面以及其任一种可能的实现方式中提供的方法。
第五方面,本申请提供了一种包含指令的计算机程序产品,当计算机程序产品在计算机上运行时,使得计算机执行本申请第一方面以及其任一种可能的实现方式中提供的方法。
附图说明
图1是本申请实施例提供的一种软件开发平台出现调用冲突的示意图;
图2是本申请实施例提供的一种调用冲突的可视化方法涉及的应用场景的示意图;
图3是本申请实施例提供的另一种调用冲突的可视化方法涉及的应用场景的示意图;
图4是本申请实施例提供的一种调用冲突的可视化方法的流程图;
图5是本申请实施例提供的一种依赖冲突的产生情况的示意图;
图6是本申请实施例提供的另一种依赖冲突的产生情况的示意图;
图7是本申请实施例提供的一种对所有候选调用关系进行筛选,得到经过筛选的目标调用关系的流程图;
图8是本申请实施例提供的一种基于包括目标调用关系的调用链,生成反映调用链的调用图的流程图;
图9是本申请实施例提供的一种依赖冲突的调用图的架构示意图;
图10是本申请实施例提供的一种同名类冲突的调用图的架构示意图;
图11是本申请实施例提供的一种依赖冲突的调用图的示意图;
图12是本申请实施例提供的一种同名类冲突的调用图的示意图;
图13是本申请实施例提供的一种依赖冲突的调用图中显示有推荐软件开发库的示意图;
图14是本申请实施例提供的一种同名类冲突的调用图中显示有推荐软件开发库的示意图;
图15是本申请实施例提供的一种调用冲突的可视化装置的结构示意图;
图16是本申请实施例提供的另一种调用冲突的可视化装置的结构示意图;
图17是本申请实施例提供的一种计算机设备的结构示意图。
具体实施方式
为使本申请的目的、技术方案和优点更加清楚,下面将结合附图对本申请实施方式作进一步地详细描述。
为便于理解,下面先对本申请实施例涉及的一些相关背景进行简单介绍。
软件开发过程中,为了提高软件开发效率、保证软件开发质量,开发者通常会从开源社区向软件开发平台中引入大量的软件开发库,以通过不同的软件开发库实现不同的功能。软 件开发库包括多个类文件,每个类文件包括一种或多种类方法,类方法用于实现对应的功能。在对软件开发库、类文件和类方法中任一者进行调用时,有可能会出现调用冲突,导致软件开发平台出现异常。
并且,在将软件开发库用于实现主项目(host project)的过程中,还可能会以直接依赖和间接依赖的方式引入不同版本的同一软件开发库。当用于实现业务的主项目需要通过调用多个软件开发库实现时,由于一个软件开发库依赖的软件开发库可能又依赖于其他软件开发库,使得主项目传递依赖于更多的库,这种对软件开发库的密集依赖很容易在实践中导致软件开发库的安装、加载、调用出现错误,进而会导致出现调用冲突。当具有依赖关系的不同软件开发库之间不兼容时,就会导致软件开发平台出现调用冲突,进而导致系统出现异常。这一类调用冲突可称为具有依赖关系的软件开发库之间的不兼容导致的调用冲突,也可以简称为依赖冲突(dependency conflict,DC)。
例如,如图1所示,一个主项目需要调用版本1.0(v1.0)的软件开发库Lib2(即Lib2(v1.0)),且该主项目需要调用软件开发库Lib1,软件开发库Lib1需要依赖于版本2.0(v2.0)的软件开发库Lib2(即Lib2(v2.0))。这样一来,该主项目需要依赖于两个版本的软件开发库Lib2,在构建环境的约束下,主项目只能从两个版本的软件开发库Lib2中仲裁并加载其中一个版本,而遮蔽掉其他版本。当通过调用软件开发库加载的类文件不是主项目的预期类文件时,就会引发构建或运行时刻的异常行为,因此就出现了依赖冲突。
类似地,开发者引入的不同软件开发库中还可能包括具有相同名称的类文件,当两个具有相同名称的类文件中一个类文件包括某类方法,且另一个类文件不包括该类方法时,对该相同名称的类文件的调用也可能出现调用冲突。这一类调用冲突可称为不同软件开发库中具有相同名称的类文件导致的调用冲突,也可以简称为同名类冲突(Same Class Conflict,SCC)。其中,具有相同名称的类文件称为同名类文件。同名类文件中一个类文件包括但另一个类文件不包括的类方法称为同名类文件的风险方法。则同名类冲突可理解为对同名类文件中的风险方法的调用导致的调用冲突。
继续参考图1,软件开发库Lib1和软件开发库Lib2(v1.0)均包括类文件A、类文件B和类文件C,即软件开发库Lib1和软件开发库Lib2(v1.0)包括同名类文件A、同名类文件B和同名类文件C。但是,软件开发库Lib1中的类文件A中存在类方法A1,而软件开发库Lib2(v1.0)中的类文件A不存在该类方法A1,即类方法A1为同名类文件A中的风险方法。在主项目的实现过程中,若主项目调用类方法A1,则可能会引发运行时刻的异常行为,如通过软件开发库Lib2(v1.0)中的类文件A调用类方法A1,则会引发运行时刻的异常行为,导致主项目出现同名类冲突。
需要说明的是,上述依赖冲突和同名类冲突仅为软件开发平台中调用冲突的举例,并不用于限定软件开发平台中可能存在的调用冲突的类型。相应地,本申请实施例提供的调用冲突的可视化方法不仅能够适用于对依赖冲突和同名类冲突进行可视化,还能够对其他类型的调用冲突进行可视化,此处对其他类型的调用冲突不再一一列举。
目前,为了便于用户能够了解软件开发平台对软件开发库的调用能力,可以对软件开发平台中软件开发库之间的调用关系进行展示。
但是,目前展示方案的展示结果无法展示调用关系是否会导致调用冲突,需要人工自行 定位调用冲突,导致对调用冲突进行定位的效率较低。并且,目前在对调用关系进行展示时,展示的是软件开发平台中软件开发库之间的所有调用关系。例如,目前的展示方案展示的是软件开发平台的整个依赖树路径。由于软件开发平台包括的软件开发库较多,其依赖路径庞大错综,导致其可视化结果对定位调用冲突的帮助不大,需要人工自行查找调用冲突。同时,目前还无法对软件开发平台中类文件和类方法的相关调用关系进行展示。所以,在主项目中存在依赖冲突或者同名类冲突等调用冲突时,主项目的程序可能会出现能够通过编译,但是在运行时出现异常甚至报错等导致系统异常的情况。
本申请实施例提供了一种调用冲突的可视化方法。通过该方法能够获取导致软件开发平台出现调用冲突的目标调用关系;基于包括目标调用关系的调用链,生成反映调用链的调用图;并显示调用图。这样一来,能够对存在调用冲突的调用关系进行可视化,以便于用户基于调用图定位调用冲突,进而解除导致调用冲突的原因,避免在开发过程中发生调用冲突。
图2是本申请实施例提供的一种调用冲突的可视化方法涉及的实施环境的结构示意图。如图2所示,该实施环境包括:计算机设备20。该计算机设备20中可以运行有软件开发平台,用户(如开发人员)可以使用软件开发平台进行程序的算法开发、程序调试、及对通过程序实现的业务进行部署上线。
在第一种实现方式中,该计算机设备20用于根据用户的指示运行软件开发平台,向用户展示软件开发平台的开发界面。并且,该计算机设备20还用于生成指示调用冲突的调用图,并向用户展示调用图。在该实现方式中,软件开发平台可以以应用程序安装包的形式,安装在用户的计算机设备20中,供用户使用软件开发平台。此时,计算机设备20可以为终端。该终端可以为计算机、个人电脑、便携式移动终端、多媒体播放器、电子书阅读器或可穿戴式设备等。
在第二种实现方式中,运行软件开发平台和向用户展示软件开发平台的开发界面的设备可以是不同的设备,和/或,运行软件开发平台和向用户展示调用图的设备可以是不同的设备。例如,如图3所示,该实施环境还可以包括客户端30。此时,用户可以通过客户端30与计算机设备20交互。计算机设备20用于接收用户通过客户端30传输的指示,根据该指示运行软件开发平台,并向客户端30提供指示软件开发平台的开发界面的可视化信息。并且,该计算机设备20还用于生成指示调用冲突的调用图,并向客户端30提供指示调用图的可视化信息。客户端30用于基于计算机设备20提供的可视化信息,展示对应的开发界面和调用图。此时,客户端30可以为计算机、个人电脑、云主机、便携式移动终端、多媒体播放器、电子书阅读器或可穿戴式设备等。计算机设备20可以为服务器。且服务器可以是一台服务器,或者由若干台服务器组成的服务器集群,或者是一个云计算服务中心。
对应于第二种实现方式,软件开发平台可以通过云平台提供。此时,服务器可以通过云计算服务中心实现。云计算服务中心中部署有云服务提供商拥有的大量基础资源。例如云计算服务中心中部署有计算资源、存储资源和网络资源等。云计算服务中心可以利用该大量基础资源提供软件开发平台。相应的,用户可以通过客户端30访问云平台,并使用云平台提供的软件开发平台。
此时,服务器为用户提供软件开发平台的功能,可以由云服务提供商在云平台抽象成一 种用于对程序进行开发的云服务(下文称为程序开发云服务)。用户在云平台购买程序开发云服务后,云平台能够利用云计算中心中的资源向用户提供软件开发平台,使得用户通过该软件开发平台进行程序的算法开发和程序调试等。可选地,云平台可以是中心云的云平台、边缘云的云平台或包括中心云和边缘云的云平台,本申请实施例对其不做具体限定。
需要说明的是,在该第二种可实现方式中,该软件开发平台也可以通过除云平台外的其他资源平台实现,本申请实施例对其不做具体限定。此时,服务器可以通过其他资源平台中的资源实现,并向用户提供软件开发平台。
并且,本申请实施例提供的调用冲突的可视化方法可以通过运行可执行程序实现。该可执行程序可以独立于软件开发平台的可执行程序。例如,软件开发平台和本申请实施例提供的调用冲突的可视化方法可以分别通过不同的应用程序实现。此时,软件开发平台的应用程序和用于实现调用冲突的可视化方法的应用程序,可以安装在同一计算机设备中,也可以安装在不同的计算机设备中,本申请实施例对其不做具体限定。或者,该可执行程序可以是软件开发平台的可执行程序的一部分。例如,软件开发平台和本申请实施例提供的调用冲突的可视化方法可以通过同一应用程序实现。并且,在这种情况中,本申请实施例提供的调用冲突的可视化方法的功能可以通过软件插件的方式实现。例如,软件开发平台可以具有多个软件插件,其中一个软件插件用于实现本申请实施例提供的调用冲突的可视化方法的功能。
另外,本申请实施例提供的调用冲突的可视化方法的执行时机可以根据应用需求进行设置。例如,可以在软件开发平台的生命周期中,周期性地执行调用冲突的可视化方法。或者,可以在软件开发平台中产生触发条件时,执行调用冲突的可视化方法。该触发条件可以根据应用需求设置。例如,触发条件可以为软件开发库发生变更,即在软件开发平台中的软件开发库发生变更时,执行调用冲突的可视化方法。在下面的介绍中,本申请实施例主要以在软件开发库发生变更时执行调用冲突的可视化方法为例,对调用冲突的可视化方法的实现过程进行说明。
示例的,用户在软件开发平台中变更软件开发库后,计算机设备可以检测变更软件开发库后的软件开发平台是否会出现调用冲突,包括检测软件开发平台是否出现依赖冲突和同名类冲突等多种调用冲突。在确定软件开发平台会出现调用冲突时,显示包括调用冲突的调用图。在计算机设备显示调用图后,用户可以根据调用图定位调用冲突,确定引起调用冲突的软件开发库,进而定位到该软件开发库的不同版本间的依赖关系等相关信息,通过对软件开发库进行替换或升级等措施,消除引起调用冲突的原因,以避免在开发过程中发生调用冲突。并且,当本申请实施例提供的调用冲突的可视化方法还可以向用户推荐软件开发库时,计算机设备可以确定引起调用冲突的软件开发库,并显示用于替换所述目标软件开发库的推荐软件开发库。此时,用户可以指示计算机设备使用推荐软件开发库替换导致产生调用冲突的软件开发库。相应的,计算机设备可以使用推荐软件开发库替换导致产生调用冲突的软件开发库。
应当理解的是,以上内容是对本申请实施例提供的调用冲突的可视化方法的应用场景的示例性说明,并不构成对于该调用冲突的可视化方法的应用场景的限定,本领域普通技术人员可知,随着业务需求的改变,其应用场景可以根据应用需求进行调整,本申请实施例对其不做一一列举。
下面对本申请实施例提供的调用冲突的可视化方法的实现过程进行说明。该方法可应用于计算机设备。如图4所示,该调用冲突的可视化方法的实现过程可以包括以下步骤:
步骤401、获取软件开发平台出现的调用冲突。
软件开发平台可能会出现多种调用冲突。在一种实现方式中,调用冲突包括以下一种或多种:软件开发平台使用的存在依赖关系的软件开发库之间不兼容导致的依赖冲突,以及,不同软件开发库中名称相同的类文件导致的同名类冲突。
对于不同的调用冲突,由于引起调用冲突的原因不同,因此确定软件开发平台出现调用冲突的实现方式通常不同。本申请实施例以调用冲突分别为依赖冲突和同名类冲突为例,对确定软件开发平台出现调用冲突的实现方式进行举例说明。
对于依赖冲突,确定软件开发平台出现依赖冲突的实现方式包括:在软件开发平台中存在同一软件开发库的至少两个版本时,确定软件开发平台出现依赖冲突。在软件开发平台中存在同一软件开发库的至少两个版本时,在构建环境的约束下,主项目只能从同一软件开发库的至少两个版本中仲裁并加载其中一个版本,而遮蔽掉其他版本,当通过调用软件开发库加载的类文件不是项目的预期类文件时,可能会导致主项目的引用功能集没有被加载的类文件完全覆盖,这样就会引发构建或运行时刻的异常行为,即出现依赖冲突。因此,计算机设备可以在软件开发平台中存在同一软件开发库的至少两个版本时,确定软件开发平台出现依赖冲突。
其中,导致软件开发平台出现依赖冲突的情况可以有多种,本申请实施例以以下两种产生情况为例进行举例说明。
在依赖冲突的第一种产生情况中,在更新软件开发平台中的软件开发库,且更新后的软件开发库依赖的软件开发库随之发生变化时,若更新后的软件开发库依赖的软件开发库与软件开发平台原有的软件开发库分别为同一软件开发库的不同版本,则可能会引起依赖冲突。例如,如图5所示,软件开发库A2.0依赖于软件开发库B1.0,当将软件开发库A1.0变更为软件开发库A2.0时,软件开发库A2.0依赖于软件开发库B3.0,软件开发库B3.0与软件开发库B2.0为同一软件开发库的两个版本,则可能会引起依赖冲突。
在依赖冲突的第二种产生情况中,在更新软件开发平台中的软件开发库,且更新后的软件开发库依赖的软件开发库不变化时,若更新后的软件开发库依赖的软件开发库与软件开发平台原有的软件开发库分别为同一软件开发库的不同版本,则可能会引起依赖冲突。例如,如图6所示,当将软件开发库A1.0变更为软件开发库C2.0时,软件开发库A1.0H和软件开发库C2.0均依赖于软件开发库B1.0,软件开发库B1.0与软件开发库B2.0为同一软件开发库的两个版本,则可能会引起依赖冲突。在该第二种产生情况中,对于更新前和更新后的软件开发库均依赖的软件开发库,虽然其到主项目的调用起点的路径发生了变化,但是由于更新前后冲突有序对未发生变化,因此仍然会引起依赖冲突。例如,对应与图6,更新前的路径为{Host,A:1.0,B1.0},更新后的路径为{Host,C:2.0,B1.0},由于更新前后冲突有序对均为<B2.0,B1.0>,因此仍然会引起依赖冲突。相对的,在第一种产生情况中,更新前不存在冲突有序对<B3.0,B1.0>,经过变更后才出现冲突有序对<B3.0,B1.0>,则冲突有序对的版本发生了变化。
其中,对于依赖冲突,冲突有序对是指对于软件开发库,假设一个主项目中出现同一软件开发库的n个版本,其中需要加载第i个版本时,需要检测n个版本中其他版本被调用的情况,则其他版本与第i个版本就构成了冲突有序对,如冲突有序对分别为<i,1>,<i,2>,…,<i, i-1>,<i,i+1>,…,<i,n>。类似的,对于同名类冲突,假设软件开发库A和软件开发库B中存在的同名类文件,在调用软件开发库A中类文件中的类方法时,需要检测软件开发库B中类文件中的类方法被调用的情况,那么可以得到冲突有序对为<A,B>。
对于同名类冲突,确定软件开发平台出现依赖冲突的实现方式包括:在不同软件开发库中名称相同的类文件之间存在风险方法的调用时,确定软件开发平台出现同名类冲突。其中,两个类文件之间存在风险方法的调用是指两个类文件中一个类文件存在对目标类方法的调用,且两个类文件中另一个类文件不存在对目标类方法的调用。
可选的,获取软件开发平台出现的调用冲突的执行时机可以根据应用需求确定。例如,可以在软件开发平台的生命周期中,周期性地检测软件开发平台是否出现调用冲突,并在软件开发平台出现调用冲突时,获取软件开发平台出现的调用冲突。或者,可以在软件开发平台中产生触发条件时,检测软件开发平台是否出现调用冲突,并在软件开发平台出现调用冲突时,获取软件开发平台出现的调用冲突。该触发条件可以根据应用需求设置。例如,触发条件可以为软件开发库发生变更,即在软件开发平台中的软件开发库发生变更时,检测软件开发平台是否出现调用冲突,并在软件开发平台出现调用冲突时,获取软件开发平台出现的调用冲突。
在一种实现方式中,变更包括升级和替换。其中,升级是指对软件开发平台中的软件开发库进行升级。替换是指使用其他软件开发库替换软件开发平台中的软件开发库。
在软件开发平台中软件开发库发生变更的场景下,可能会导致一些依赖间的调用关系发生变化,这些变化可能会导致软件开发平台出现调用冲突,因此,通过在软件开发平台中软件开发库发生变更时,获取软件开发平台出现的调用冲突,可以对软件开发平台中的调用关系进行增量检测,能够在使用软件开发平台的用户未察觉到存在版本冲突时,及时地检测到因软件开发库的变更导致的调用冲突,并对该调用冲突进行可视化,有助于及时地解除导致调用冲突的原因,避免在开发过程中发生调用冲突。
其中,可以通过自动或手动的方式对软件开发库进行变更。在手动变更软件开发库的一种实现方式中,可以在软件开发平台的依赖文件中,更改指示软件开发库的依赖关系的信息,以实现对软件开发库的变更。例如,在Maven(一种开源项目管理工具)中,可以采用自动或手动的方式,在Maven的Pom或Gradle等依赖文件中,对指示软件开发库的依赖关系的信息进行修改,如对Group ID/Artifact ID/Version等信息进行修改,实现对Maven中软件开发库的变更。其中,Group ID和Artifact ID可被统称为“坐标”,用于保证项目的唯一性。Version用于指示软件开发库的版本。例如,可以通过在Pom或Gradle等依赖文件中,保持Group ID和Artifact ID不变,将Version从1.0修改为2.0,可以实现将软件开发库从1.0版本的软件修改为2.0版本。
步骤402、获取导致软件开发平台出现调用冲突的目标调用关系,并确定引起调用冲突的目标软件开发库。
在确定软件开发平台出现调用冲突后,可以获取可能导致软件开发平台出现调用冲突的所有调用关系,并将所有调用关系均作为目标调用关系。在一种实现方式中,在确定软件开发平台的过程中能够确定确定引起调用冲突的调用主体,该调用主体所有可能的调用关系为目标调用关系,或者,在使用软件开发平台开发的主项目中,对引起调用冲突的调用主体的调用关系为目标调用关系。示例的,当调用冲突为依赖冲突时,调用主体为软件开发库。当 调用冲突为同名类冲突时,调用主体为类方法。
或者,在获取导致软件开发平台出现调用冲突的所有调用关系后,可以将该所有调用关系确定为候选调用关系,并对所有候选调用关系进行筛选,得到经过筛选的候选调用关系,该经过筛选的候选调用关系即为目标调用关系。其中,由于可能导致软件开发平台出现调用冲突的候选调用关系较多,但是不同候选调用关系真正引起调用冲突的概率不同,因此在确定候选调用关系后,可以对候选调用关系进行筛选,并基于经过筛选的候选调用关系显示调用图。这样一来,能够减少需要用户查看的调用图,避免因需要用户查看较多的调用图导致用户体验较差。并且,通过对候选调用关系进行筛选,能够保证显示的调用图包括的候选调用关系均为具有较高概率引起调用冲突的调用关系,进而有效避免在开发过程中发生调用冲突。
可选的,在获取软件开发平台出现的调用冲突后,还可以确定引起调用冲突的目标软件开发库,以便于提示用户该目标软件库会引起调用冲突,使得用户针对该目标软件开发库执行解除导致调用冲突的原因。在确定目标软件开发库的一种实现方式中,在确定目标调用关系后,可以确定该目标调用关系调用的内容所属的软件开发库,并将目标调用关系调用的内容所属的软件开发库确定为目标软件开发库。
需要说明的是,确定引起调用冲突的目标软件开发库是可选执行操作,可以根据应用需求确定是否执行该操作。例如,在应用需求指示需要在调用图中呈现引起调用冲突的目标软件开发库时,如在软件开发平台还具有向用户推荐用于替换目标软件开发库的软件开发库时,可以执行该操作。
在一种实现方式中,如图7所示,对所有候选调用关系进行筛选,得到经过筛选的目标调用关系的实现过程,包括:
步骤4021、对每个候选调用关系进行冲突评估,得到每个候选调用关系的评估结果,评估结果用于指示候选调用关系导致出现调用冲突的概率。
在一种可实现方式中,可以参考指标对候选调用关系进行冲突评估,得到候选调用关系针对每个指标的评估结果。当参考多个指标对候选调用关系进行冲突评估时,候选调用关系相对于多个指标的评估结果,可以采用候选调用关系相对于多个指标中每个指标的评估结果的集合表示。
可选的,在本申请实施例中,对候选调用关系进行冲突评估使用的指标包括以下一个或多个:候选调用关系引入的软件开发库之间的依赖关系的数量,候选调用关系引入的调用冲突的数量,候选调用关系引入的调用冲突的安全程度。在一种实现方式中,候选调用关系引入的调用冲突的安全程度,可以通过引起调用冲突的软件开发库的安全程度表示。其中,安全程度用于指示出现安全漏洞的可能性。此时,候选调用关系相对于这三个指标的评估结果,可以采用候选调用关系相对于这三个指标中每个指标的评估结果的集合表示。例如,当候选调用关系引入的软件开发库之间的依赖关系的数量为5,候选调用关系引入的调用冲突的数量为3,候选调用关系引入的调用冲突的安全程度为70%时,候选调用关系针对这三个指标的评估结果可以表示为:{5,3,70%}。
当候选调用关系引入的软件开发库之间的依赖关系的数量越大时,会导致包括该候选调用关系的调用链中调用主体之间的依赖路径越复杂,候选调用关系导致出现调用冲突的概率越高。当调用冲突为依赖冲突时,调用主体为软件开发库。当调用冲突为同名类冲突时,调 用主体为类方法。当候选调用关系引入的调用冲突的数量越大时,候选调用关系导致出现调用冲突的概率越高。当候选调用关系引入的调用冲突的安全程度越低时,候选调用关系导致出现调用冲突的概率越高。因此,能够根据候选调用关系引入的软件开发库之间的依赖关系的数量、候选调用关系引入的调用冲突的数量、及候选调用关系引入的调用冲突的安全程度,对候选调用关系进行冲突评估。需要说明的是,在对候选调用关系进行冲突评估时,还可以根据应用需求,参考其他指标对候选调用关系进行评估,此处对其不再一一列举。
步骤4022、将评估结果指示满足预设条件的候选调用关系确定为目标调用关系。
当候选调用关系的评估结果满足预设条件时,说明根据应用需求需要显示包括该候选调用关系的调用图。因此,当候选调用关系的评估结果满足预设条件时,可以将该候选调用关系确定为目标调用关系。其中,预设条件可以根据应用需求确定。例如,对于候选调用关系引入的调用冲突的安全程度这一指标,若安全程度小于60%,可以认为其会导致软件开发平台处于不安全的状态,则这一指标的预设条件为可以候选调用关系引入的调用冲突的安全程度小于60%。
根据前面步骤401的描述可知,获取软件开发平台出现的调用冲突的执行时机可以根据应用需求确定,则获取导致软件开发平台出现调用冲突的目标调用关系的执行时机也可以根据应用需求确定。例如,可以在每次确定软件开发平台出现的调用冲突后,立即获取目标调用关系。并且,当在软件开发库发生变更,执行获取由变更导致的目标调用关系的操作时,还可以针对发生变更的每个软件开发库,分别获取因其产生的目标调用关系,并针对每个软件开发库显示其对应的调用图,以进一步提高定位效率和可视化的视觉效果,从而提高用户体验。
需要说明的是,获取到的目标调用关系可能还可包括有对生成调用图无关的信息,则在获取到目标调用关系后,还可以对用于表示目标调用关系的信息进行处理,是的经过处理后的目标调用关系不包括对生成调用图无关的信息。示例的,处理前的依赖路径可以为:
[com.huawei.avenuesearch:SmartBlame:0.2.4::priority:0+
com.huawei.avenuesearch.org.tmatesoft.svnkit:svnkit:1.8.14_huawei_20171018::compile 
priority:45+
com.jcraft:jsch.agentproxy.connector-factory:0.0.7::compile priority:50+
com.jcraft:jsch.agentproxy.usocket-jna:0.0.7::compile priority:52+
net.java.dev.jna:jna:3.4.0::compile priority:-1]
处理后的依赖路径可以为:
[com.huawei.avenuesearch:SmartBlame:0.2.4com.huawei.avenuesearch.utility:Misc:0.0.52 
com.google.code.gson:gson:2.8.2]
[com.huawei.avenuesearch:SmartBlame:0.2.4com.huawei.avenuesearch.utility:Misc:0.0.52 
org.apache.commons:commons-lang3:3.8]
[com.huawei.avenuesearch:SmartBlame:0.2.4com.huawei.avenuesearch.org.eclipse.jgit:org.
eclipse.jgit:4.0.1.201506240215-r-huawei
[com.huawei.avenuesearch:SmartBlame:0.2.4org.owasp.esapi:esapi:2.1.0.1commons-
fileupload:1.3.1commons-
[com.huawei.avenuesearch:SmartBlame:0.2.4org.apache.avro:avro:1.7.7org.xerial.snappy:
snappy-java:1.0.5]
步骤403、基于包括目标调用关系的调用链,生成反映调用链的调用图。
在一种实现方式中,如图8所示,该步骤403的实现过程包括:
步骤4031、基于调用链的结构,确定调用图的架构。
在确定目标调用关系后,可以获取该目标调用关系所在的整个调用链,并基于调用链确定调用图的架构。调用图的架构用于指示调用链涉及的调用主体以及调用主体之间的依赖关系,且依赖关系可以表现为调用关系和被调用关系。在一种实现方式中,调用图可以通过调用路径表示。并且,调用路径可以使用包括节点和边的图表示。节点可以表示调用链涉及的调用主体。边可以表示调用主体之间的依赖关系。例如,当调用冲突包括依赖冲突时,调用主体可以包括调用链中被调用的软件开发库,依赖关系可以包括软件开发库之间的调用关系。又例如,当调用冲突包括同名类冲突时,调用主体可以包括调用链中被调用的类方法,依赖关系可以包括类方法之间的调用关系。并且,当调用冲突包括同名类冲突时,调用主体还可以包括以下一个或多个:类方法所属的软件开发库和类文件。另外,调用图可以表示的调用链可以从依赖树根为起点。例如,调用链可以以主项目为起点。并且,在本申请实施例中,调用图的格式可以根据应用需求进行设置。例如,调用图的格式可以为可缩放的矢量图形(scalable vector graphics,SVG)格式或可移植网络图形格式(portable network graphic format,PNG)。
例如,对于主项目com.huawei.fossbot:migrate-agent:1.0.0.110,其存在两条调用路径。在其中一条调用路径中,需要先调用软件开发库org.springframework.boot:spring-boot-starter:2.5.3,该软件开发库会继续调用软件开发库org.springframework.boot:spring-boot:2.5.2。在另一条调用路径中,需要先调用软件开发库com.huaweicloud:spring-boot-starter-huawei:0.2.0-RELEASE,该软件开发库会继续调用软件开发库org.springframework.boot:spring-boot-test:2.5.2,且该软件开发库会继续调用软件开发库org.springframework.boot:spring-boot:2.5.2。这两条调用路径可以分别采用两条调用链表示。假设对软件开发库org.springframework.boot:spring-boot:2.5.2的调用出现调用冲突,则对该软件开发库org.springframework.boot:spring-boot:2.5.2的调用关系为目标调用关系。由于两条调用链均包括该目标调用关系,调用图中可以包括这两条调用链的内容,则可以分别基于这两条调用链的结构,生成调用图的架构。如图9所示,调用图的架构可以指示并行的两条调用路径,一条调用路径涉及对两个调用主体的调用,另一条调用路径涉及对三个调用主体的调用,且两条调用路径从同一调用起点出发,最终汇聚至对同一调用主体的调用。在该调用图的架构中,调用主体为软件开发库。
又例如,对于主项目的方法com.huawei.avenuesearch.common.response.PartResult scroll,其依次调用了类方法ToXContentToBytes:java.lang.String toString()、类方法ToXContentToBytes:java.lang.String toString(org.elasticsearch.common.xcontent.ToXContent$-Params)、类方法SearchSourceBuilder:org.elasticsearch.common.xcontent.XContentBuilder toXConten、类方法.XContentBuilder:org.elasticsearch.common.xcontent.XContentBuilder field、类方法json.JsonXContentGenerator:void writeStringField。主项目对类方法的调用路径可以采用一条调用链表示。假设对类方法json.JsonXContentGenerator:void writeStringField的调用出现调用冲突,则对该类方法json.JsonXContentGenerator:void writeStringField为目标调用关系,则可以分别基于这条调用链的结构,生成调用图的架构。如图10所示,调用图的架构可以指 示一条调用路径,这条调用路径涉及对五个调用主体的调用。在该调用图的架构中,调用主体为类方法。
步骤4032、基于调用链,对架构的元素进行实例化,得到调用图,元素包括节点和边。
在确定调用图的架构后,可以根据调用链中的调用主体和调用主体之间的依赖关系,对架构的元素进行实例化,以得到调用图。并且,根据步骤4031中对调用主体和依赖关系的描述可知,当调用冲突包括依赖冲突时,调用图显示的内容包括:调用链中被调用的软件开发库,及软件开发库之间的调用关系;当调用冲突包括同名类冲突时,调用图显示的内容包括:调用链中被调用的类方法,及类方法之间的调用关系。可选的,当调用冲突包括同名类冲突时,调用图显示的内容还包括以下一个或多个:类方法所属的软件开发库和类文件。当调用图还包括类方法所属的软件开发库和类文件中的一个或多个时,能够为用户定位调用冲突提供更多的依据,进一步地提高可用户定位调用冲突的效率,且能够便于用户根据实际的需求对导致调用冲突的类方法所属的软件开发库进行调整,从而避免调用冲突的发生。
在一种可实现方式中,在调用图中,软件开发库可以使用软件开发库的名称表示。例如,对于软件开发库org.springframework.boot:spring-boot-starter:2.5.3,在调用图中,“org.springframework.boot:spring-boot-starter:2.5.3”表示该软件开发库。
在一种可实现方式中,在调用图中,类方法可以使用类方法的方法名、方法类型和输入参数表示。该类方法的表示方式可以称为采用方法体表示类方法。例如,对于类方法ToXContentToBytes:java.lang.String toString(org.elasticsearch.common.xcontent.ToXContent$-Params),在调用图中,“ToXContentToBytes”表示该类方法的方法名,“java.lang.String toString”表示该类方法方法类型,括号中的内容表示该类方法的输入参数。由于类方法包括较多信息,若展示类方法的全部信息,其展示内容会过于繁杂,通过使用方法名、方法类型和输入参数表示类方法,能够便于用户查看类方法的调用路径中的调用主体,并确定调用主体所属类文件和软件开发库库,进而进行适配与修改。
例如,对应于图9的调用图的结构,可以根据主项目调用的软件开发库和软件开发库之间的依赖关系,确定架构中每个节点表示的软件开发库,得到如11所示的调用图。如图11所示,调用图中第一个节点表示主项目com.huawei.fossbot:migrate-agent:1.0.0.110,调用图中左边的调用路径中的第一个节点表示软件开发库org.springframework.boot:spring-boot-starter:2.5.3,左边的调用路径中的第二个节点表示软件开发库org.springframework.boot:spring-boot:2.5.2,调用图中右边的调用路径中的第一个节点表示软件开发库om.huaweicloud:spring-boot-starter-huawei:0.2.0-RELEASE,右边的调用路径中的第二个节点表示软件开发库org.spring framework.boot:spring-boot-test:2.5.2,右边的调用路径中的第三个节点表示软件开发库org.springframework.boot:spring-boot:2.5.2,且左边的调用路径中的第二个节点和右边的调用路径中的第三个节点为同一个节点。
例如,对应于图10的调用图的结构,可以根据主项目方法、其调用的类方法及其之间的依赖关系,确定架构中每个节点表示的类方法,得到如12所示的调用图。如图12所示,调调用图中第一个节点表示主项目的方法com.huawei.avenuesearch.common.response.PartResult scroll,调用图中第二个节点表示类方法ToXContentToBytes:java.lang.String toString(),第三个节点表示类方法ToXContentToBytes:java.lang.String toString(org.elasticsearch.common.xcontent.ToXContent$-Params),第四个节点表示类方法SearchSourceBuilder:org.elasticsearch.common. xcontent.XContentBuilder toXConten,第五个节点表示,第六个节点表示类方法json.Json XContentGenerator:void writeStringField。
步骤4033、对实例化后的元素进行优化处理,得到经过优化处理的调用图,使得经过优化处理的调用图对不同属性的元素的呈现方式不同。
在得到调用图后,还可以对调用图中实例化后的元素进行优化处理,得到经过优化处理的调用图,从而优化调用图的视觉效果。在经过优化处理的调用图中,不同属性的元素的呈现方式不同。
在一种可实现方式中,在经过优化处理的调用图中,目标调用关系和未出现调用冲突的调用关系采用不同方式呈现。例如,在经过优化处理的调用图中,可以采用实线箭头表示未出现调用冲突的调用关系,采用虚线箭头表示未出现调用冲突的调用关系。通过采用不同的方式呈现目标调用关系和未出现调用冲突的调用关系,能够便于用户快速地识别出现调用冲突的目标调用关系,进一步地提高可用户定位调用冲突的效率。
和/或,角色不同的软件开发库在调用图中的呈现方式不同。角色包括调用起点和调用中间点。其中,在调用路径中,除调用起点外的所有调用主体均为调用中间点。例如,在经过优化处理的调用图中,可以采用加粗的字体表示作为调用起点的软件开发库,采用正常粗细的字体表示作为调用中间点的软件开发库。通过采用不同的方式呈现角色不同的软件开发库,能够便于用户了解主项目的整体架构,分析导致调用冲突的原因,提高解除导致调用冲突的原因的效率。
和/或,角色不同的类方法在调用图中的呈现方式不同。角色包括调用起点和调用中间点。其中,在调用路径中,除调用起点外的所有调用主体均为调用中间点。例如,在经过优化处理的调用图中,可以采用加粗的字体表示作为调用起点的类方法,采用正常粗细的字体表示作为调用中间点的类方法。通过采用不同的方式呈现角色不同的类方法,能够便于用户了解主项目的整体架构,分析导致调用冲突的原因,提高解除导致调用冲突的原因的效率。
需要说明的是,该步骤4033是可选执行步骤,在生成调用图的过程中可以根据应用需求确定是否执行该步骤。例如,若应用需求要求显示具有较好用户体验的调用图时,步骤403的实现过程还可以包括步骤4033。
步骤404、显示调用图,并显示用于替换目标软件开发库的推荐软件开发库。
在生成调用图后,计算机设备就可以根据用于表示调用图的信息显示调用图。示例的,对应于前述图9和图11的示例,计算机设备显示的调用图如图11所示。对应于前述图10和图12的示例,计算机设备显示的调用图如图12所示。
本申请实施例提供的调用冲突的可视化方法还可以获取推荐软件开发库,该推荐软件库用于替换目标软件开发库。则计算机设备还可以显示推荐软件开发库,以便于用户使用该推荐软件开发库替换目标软件开发库,从而解除导致调用冲突的原因。
在显示推荐软件开发库的一种可实现方式中,计算机设备可以在调用图的显示界面中显示推荐软件开发库,并提示用户该推荐软件开发库是针对目标调用关系推荐的。例如,当调用冲突包括依赖冲突时,可以提示该推荐软件开发库是针对导致调用冲突的目标软件开发库的。如图13所示,显示界面中显示有推荐软件开发库org.springframework.boot:spring-boot:2.5.6,并显示有使用该推荐软件开发库替换软件开发库org.springframework.boot:spring-boot:2.5.2的提示(如图13中双向箭头所示)。当调用冲突包括同名类冲突时,可以在调用 图中引起该同名类冲突的目标软件开发库,并在提示该推荐软件开发库是针对导致调用冲突的目标软件开发库的。如图14所示,类方法json.JsonXContentGenerator:void writeStringField是引起同名类冲突的风险方法,该风险方法所属的目标软件开发库为软件开发库org.spring framework.boot:spring-boot:2.5.2,显示界面中显示有推荐软件开发库org.springframework.boot:spring-boot:2.5.6,并显示有使用该推荐软件开发库替换软件开发库org.springframework.boot:spring-boot:2.5.2的提示(如图14中双向箭头所示)。
在显示推荐软件开发库的一种可实现方式中,计算机设备可以在调用图的显示界面中,显示提示有推荐软件开发库的按钮,当用户查看调用图时,若其想查看推荐软件开发库,可以点击该按钮,以指示计算机设备显示推荐软件开发库。
需要说明的是,显示用于替换目标软件开发库的推荐软件开发库是可选执行操作,可以根据应用需求确定是否执行该操作。例如,在应用需求指示需要在调用图中呈现引起调用冲突的目标软件开发库,且软件开发平台还具有向用户推荐用于替换目标软件开发库的软件开发库时,可以执行该操作。
步骤405、接收对推荐软件开发库的响应操作。
在计算机设备显示推荐软件开发库后,用户可以针对推荐软件开发库进行响应,如指示计算机设备使用推荐软件开发库替换目标软件开发库,或者拒绝使用推荐软件开发库替换目标软件开发库。因此,计算机设备可以接收用户对推荐软件开发库的响应操作。
步骤406、执行响应操作所指示的操作,响应操作所指示的操作包括:使用推荐软件开发库替换目标软件开发库。
计算机设备接收用户对推荐软件开发库的响应操作后,可以执行响应操作所指示的操作。例如,响应操作所指示的操作为使用推荐软件开发库替换目标软件开发库时,计算机设备可以使用推荐软件开发库替换目标软件开发库,从而实现对软件开发库的精确选择,避免编译或运行时因调用目标软件开发库出错,进而避免软件开发平台出现因目标软件开发库导致的调用冲突。
综上所述,在本申请实施例提供的调用冲突的可视化方法中,能够获取导致软件开发平台出现调用冲突的目标调用关系;基于包括目标调用关系的调用链,生成反映调用链的调用图;并显示调用图。这样一来,能够对存在调用冲突的调用关系进行可视化,以便于用户基于调用图定位调用冲突,进而解除调用冲突出现的原因,避免在开发过程中发生调用冲突。
需要说明的是,本申请实施例提供的调用冲突的可视化方法的步骤先后顺序可以进行适当调整,步骤也可以根据情况进行相应增减。任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化的方法,都应涵盖在本申请的保护范围之内,因此不再赘述。并且,本申请实施例提供的调用冲突的可视化方法也可以不限于部署容器,例如,还可以用于部署需要依赖虚拟设备运行的其他虚拟实例,本申请实施例对其不做具体限定。
本申请提供了一种调用冲突的可视化装置。如图15所示,该调用冲突的可视化装置150包括:
处理模块1501,用于获取导致软件开发平台出现调用冲突的目标调用关系;
处理模块1501,还用于基于包括目标调用关系的调用链,生成反映调用链的调用图;
显示模块1502,用于显示调用图。
可选的,调用冲突包括以下一种或多种:软件开发平台使用的存在依赖关系的软件开发库之间不兼容导致的依赖冲突,以及,不同软件开发库中名称相同的类文件导致的同名类冲突。
可选的,在软件开发平台中存在同一软件开发库的至少两个版本时,软件开发平台出现依赖冲突。
可选的,当调用冲突包括依赖冲突时,调用图显示的内容包括:调用链中被调用的软件开发库,及软件开发库之间的调用关系。
可选的,在不同软件开发库中名称相同的类文件之间存在风险方法的调用时,软件开发平台出现同名类冲突,其中,两个类文件之间存在风险方法的调用是指两个类文件中一个类文件存在对目标类方法的调用,且两个类文件中另一个类文件不存在对目标类方法的调用。
可选的,当调用冲突包括同名类冲突时,调用图显示的内容包括:调用链中被调用的类方法,及类方法之间的调用关系。
可选的,类方法采用类方法的方法名、方法类型和输入参数表示。
可选的,调用图显示的内容还包括以下一个或多个:类方法所属的软件开发库和类文件。
可选的,目标调用关系和未出现调用冲突的调用关系采用不同方式呈现;和/或,角色不同的软件开发库在调用图中的呈现方式不同,角色包括调用起点和调用中间点;和/或,角色不同的类方法在调用图中的呈现方式不同。
可选的,处理模块1501,还用于确定引起调用冲突的目标软件开发库。
相应的,显示模块1502,还用于显示用于替换目标软件开发库的推荐软件开发库。
可选的,如图16所示,调用冲突的可视化装置150还包括:交互模块1503,用于接收对推荐软件开发库的响应操作。
相应的,处理模块1501,还用于执行响应操作所指示的操作,响应操作所指示的操作包括:使用推荐软件开发库替换目标软件开发库。
可选的,处理模块1501,具体用于:基于调用链的结构,确定调用图的架构;基于调用链,对架构的元素进行实例化,得到调用图,元素包括节点和边。
可选的,处理模块1501,具体还用于:对实例化后的元素进行优化处理,得到经过优化处理的调用图,使得经过优化处理的调用图对不同属性的元素的呈现方式不同,其中,目标调用关系和未出现调用冲突的调用关系采用不同方式呈现,和/或,角色不同的软件开发库在调用图中的呈现方式不同,角色包括调用起点和调用中间点,和/或,角色不同的类方法在调用图中的呈现方式不同,软件开发库包括多个类方法。
可选的,处理模块1501,具体用于:获取导致软件开发平台出现调用冲突的所有候选调用关系;对所有候选调用关系进行筛选,得到经过筛选的目标调用关系。
可选的,处理模块1501,具体用于:对每个候选调用关系进行冲突评估,得到每个候选调用关系的评估结果,评估结果用于指示候选调用关系导致出现调用冲突的概率;将评估结果指示满足预设条件的候选调用关系确定为目标调用关系。
可选的,对候选调用关系进行冲突评估使用的指标包括以下一个或多个:候选调用关系引入的软件开发库之间的依赖关系的数量,候选调用关系引入的调用冲突的数量,候选调用关系引入的调用冲突的安全程度。
可选的,处理模块1501,具体用于:在软件开发平台中软件开发库发生变更时,获取由 变更导致的目标调用关系。
可选的,变更包括升级和替换。
可选的,处理模块1501,具体用于:针对发生变更的每个软件开发库分别获取目标调用关系。
综上所述,在本申请实施例提供的调用冲突的可视化装置中,获取模块能够获取导致软件开发平台出现调用冲突的目标调用关系;处理模块能够基于包括目标调用关系的调用链,生成反映调用链的调用图;显示模块能够显示调用图。这样一来,能够对存在调用冲突的调用关系进行可视化,以便于用户基于调用图定位调用冲突,进而解除调用冲突出现的原因,避免在开发过程中发生调用冲突。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的装置和模块的具体工作过程,可以参考前述方法实施例中的对应内容,在此不再赘述。
本申请实施例提供了一种计算机设备。该计算机设备能够实现本申请实施例提供的调用冲突的可视化方法中的部分或全部功能。图17是本申请实施例提供的一种计算机设备的结构示意图。如图17所示,该计算机设备1700包括处理器1701、存储器1702、通信接口1703和总线1704。其中,处理器1701、存储器1702、通信接口1703通过总线1704实现彼此之间的通信连接。
处理器1701可以包括通用处理器和/或专用硬件芯片。通用处理器可以包括:中央处理器(central processing unit,CPU)、微处理器或图形处理器(graphics processing unit,GPU)。CPU例如是一个单核处理器(single-CPU),又如是一个多核处理器(multi-CPU)。专用硬件芯片是一个高性能处理的硬件模块。专用硬件芯片包括数字信号处理器、专用集成电路(application-specific integrated circuit,ASIC)、现场可编程逻辑门阵列(field-programmable gate array,FPGA)或者网络处理器(network processer,NP)中的至少一项。处理器1701还可以是一种集成电路芯片,具有信号的处理能力。在实现过程中,本申请的调用冲突的可视化方法的部分或全部功能,可以通过处理器1701中的硬件的集成逻辑电路或者软件形式的指令完成。
存储器1702用于存储计算机程序,计算机程序包括操作系统1702a和可执行代码(即程序指令)1702b。存储器1702例如是只读存储器或可存储静态信息和指令的其它类型的静态存储设备,又如是随机存取存储器或者可存储信息和指令的其它类型的动态存储设备,又如是电可擦可编程只读存储器、只读光盘或其它光盘存储、光碟存储(包括压缩光碟、激光碟、光碟、数字通用光碟、蓝光光碟等)、磁盘存储介质或者其它磁存储设备,或者是能够用于携带或存储具有指令或数据结构形式的期望的可执行代码并能够由计算机存取的任何其它介质,但不限于此。例如存储器1702用于存放出端口队列等。存储器1702例如是独立存在,并通过总线1704与处理器1701相连接。或者存储器1702和处理器1701集成在一起。存储器1702可以存储可执行代码,当存储器1702中存储的可执行代码被处理器1701执行时,处理器1701用于执行本申请实施例提供的调用冲突的可视化方法的部分或全部功能。例如,处理器1701执行以下过程:获取导致软件开发平台出现调用冲突的目标调用关系;基于包括目标调用关系的调用链,生成反映调用链的调用图;显示调用图。且处理器1701执行该过程的实现方式请相应参考本申请方法实施例中的相关描述。存储器1702中还可以包括操作系统等 其他运行进程所需的软件模块和数据等。
通信接口1703使用例如但不限于收发器一类的收发模块,来实现与其他设备或通信网络之间的通信。例如,通信接口1703可以是以下器件的任一种或任一种组合:网络接口(如以太网接口)、无线网卡等具有网络接入功能的器件。
总线1704是任何类型的,用于实现计算机设备的内部器件(例如,存储器1702、处理器1701、通信接口1703)互连的通信总线。例如系统总线。本申请实施例以计算机设备内部的上述器件通过总线1704互连为例说明,可选地,计算机设备1700内部的上述器件还可以采用除了总线1704之外的其他连接方式彼此通信连接。例如,计算机设备1700内部的上述器件通过内部的逻辑接口互连。
需要说明的是,上述多个器件可以分别设置在彼此独立的芯片上,也可以至少部分的或者全部的设置在同一块芯片上。将各个器件独立设置在不同的芯片上,还是整合设置在一个或者多个芯片上,往往取决于产品设计的需要。本申请实施例对上述器件的具体实现形式不做限定。且上述各个附图对应的流程的描述各有侧重,某个流程中没有详述的部分,可以参见其他流程的相关描述。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。提供软件开发平台的计算机程序产品包括一个或多个计算机指令,在计算机设备上加载和执行这些计算机程序指令时,全部或部分地实现本申请实施例提供的调用冲突的可视化方法的流程或功能。
并且,计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。计算机可读存储介质存储有提供软件开发平台的计算机程序指令。
本申请实施例还提供了一种计算机可读存储介质,该计算机可读存储介质可以为非易失性计算机可读存储介质,该计算机可读存储介质包括程序指令,当程序指令在计算机设备上运行时,使得计算机设备执行如本申请实施例提供的调用冲突的可视化方法。
本申请实施例还提供了一种包含指令的计算机程序产品,当计算机程序产品在计算机上运行时,使得计算机执行本申请实施例提供的调用冲突的可视化方法。
本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,的程序可以存储于一种计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。
需要说明的是,本申请所涉及的信息(包括但不限于用户设备信息、用户个人信息等)、数据(包括但不限于用于分析的数据、存储的数据、展示的数据等)以及信号,均为经用户授权或者经过各方充分授权的,且相关数据的收集、使用和处理需要遵守相关国家和地区的相关法律法规和标准。
在本申请实施例中,术语“第一”、“第二”和“第三”仅用于描述目的,而不能理解为指示 或暗示相对重要性。术语“至少一个”是指一个或多个,术语“多个”指两个或两个以上,除非另有明确的限定。
本申请中术语“和/或”,仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,本文中字符“/”,一般表示前后关联对象是一种“或”的关系。
以上所述仅为本申请的可选实施例,并不用以限制本申请,凡在本申请的构思和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。

Claims (23)

  1. 一种调用冲突的可视化方法,其特征在于,所述方法包括:
    获取导致软件开发平台出现调用冲突的目标调用关系;
    基于包括所述目标调用关系的调用链,生成反映所述调用链的调用图;
    显示所述调用图。
  2. 根据权利要求1所述的方法,其特征在于,所述调用冲突包括以下一种或多种:所述软件开发平台使用的存在依赖关系的软件开发库之间不兼容导致的依赖冲突,以及,不同软件开发库中名称相同的类文件导致的同名类冲突。
  3. 根据权利要求2所述的方法,其特征在于,在所述软件开发平台中存在同一软件开发库的至少两个版本时,所述软件开发平台出现所述依赖冲突。
  4. 根据权利要求2或3所述的方法,其特征在于,当所述调用冲突包括所述依赖冲突时,所述调用图显示的内容包括:所述调用链中被调用的软件开发库,及所述软件开发库之间的调用关系。
  5. 根据权利要求2所述的方法,其特征在于,在不同软件开发库中名称相同的类文件之间存在风险方法的调用时,所述软件开发平台出现所述同名类冲突,其中,两个类文件之间存在风险方法的调用是指所述两个类文件中一个类文件存在对目标类方法的调用,且所述两个类文件中另一个类文件不存在对所述目标类方法的调用。
  6. 根据权利要求2或5所述的方法,其特征在于,当所述调用冲突包括所述同名类冲突时,所述调用图显示的内容包括:所述调用链中被调用的类方法,及所述类方法之间的调用关系。
  7. 根据权利要求6所述的方法,其特征在于,所述类方法采用所述类方法的方法名、方法类型和输入参数表示。
  8. 根据权利要求6所述的方法,其特征在于,所述调用图显示的内容还包括以下一个或多个:所述类方法所属的软件开发库和类文件。
  9. 根据权利要求4或6所述的方法,其特征在于,
    所述目标调用关系和未出现调用冲突的调用关系采用不同方式呈现;
    和/或,角色不同的软件开发库在所述调用图中的呈现方式不同,所述角色包括调用起点和调用中间点;
    和/或,角色不同的类方法在所述调用图中的呈现方式不同。
  10. 根据权利要求1至9任一所述的方法,其特征在于,所述方法还包括:
    确定引起所述调用冲突的目标软件开发库;
    显示用于替换所述目标软件开发库的推荐软件开发库。
  11. 根据权利要求10所述的方法,其特征在于,在所述显示用于替换所述目标软件开发库的推荐软件开发库之后,所述方法还包括:
    接收对所述推荐软件开发库的响应操作;
    执行所述响应操作所指示的操作,所述响应操作所指示的操作包括:使用所述推荐软件开发库替换所述目标软件开发库。
  12. 根据权利要求1至11任一所述的方法,其特征在于,所述基于包括所述目标调用关系的调用链,生成反映所述调用链的调用图,包括:
    基于所述调用链的结构,确定所述调用图的架构;
    基于所述调用链,对所述架构的元素进行实例化,得到所述调用图,所述元素包括节点和边。
  13. 根据权利要求12所述的方法,其特征在于,在所述基于所述调用链,对所述架构的元素进行实例化,得到所述调用图之后,所述基于包括所述目标调用关系的调用链,生成反映所述调用链的调用图,还包括:
    对实例化后的元素进行优化处理,得到经过优化处理的调用图,使得经过优化处理的调用图对不同属性的元素的呈现方式不同,其中,所述目标调用关系和未出现调用冲突的调用关系采用不同方式呈现,和/或,角色不同的软件开发库在所述调用图中的呈现方式不同,所述角色包括调用起点和调用中间点,和/或,角色不同的类方法在所述调用图中的呈现方式不同,所述软件开发库包括多个类方法。
  14. 根据权利要求1至13任一所述的方法,其特征在于,所述获取导致软件开发平台出现调用冲突的目标调用关系,包括:
    获取导致所述软件开发平台出现调用冲突的所有候选调用关系;
    对所述所有候选调用关系进行筛选,得到经过筛选的所述目标调用关系。
  15. 根据权利要求14所述的方法,其特征在于,所述对所述所有候选调用关系进行筛选,得到经过筛选的所述目标调用关系,包括:
    对每个候选调用关系进行冲突评估,得到每个候选调用关系的评估结果,所述评估结果用于指示所述候选调用关系导致出现调用冲突的概率;
    将评估结果指示满足预设条件的候选调用关系确定为所述目标调用关系。
  16. 根据权利要求15所述的方法,其特征在于,对所述候选调用关系进行冲突评估使用的指标包括以下一个或多个:所述候选调用关系引入的软件开发库之间的依赖关系的数量,所述候选调用关系引入的调用冲突的数量,所述候选调用关系引入的调用冲突的安全程度。
  17. 根据权利要求1至16任一所述的方法,其特征在于,在所述软件开发平台中软件开发库发生变更时,获取由所述变更导致的所述目标调用关系。
  18. 根据权利要求17所述的方法,其特征在于,所述变更包括升级和替换。
  19. 根据权利要求17或18所述的方法,其特征在于,所述获取由所述变更导致的所述目标调用关系,包括:
    针对发生变更的每个软件开发库分别获取所述目标调用关系。
  20. 一种调用冲突的可视化装置,其特征在于,所述装置包括:
    处理模块,用于获取导致软件开发平台出现调用冲突的目标调用关系;
    所述处理模块,还用于基于包括所述目标调用关系的调用链,生成反映所述调用链的调用图;
    显示模块,用于显示所述调用图。
  21. 一种计算机设备,其特征在于,包括存储器和处理器,所述存储器存储有程序指令,所述处理器运行所述程序指令以执行权利要求1至19任一所述的方法。
  22. 一种计算机可读存储介质,其特征在于,包括程序指令,当所述程序指令在计算机设备上运行时,使得所述计算机设备执行如权利要求1至19任一所述的方法。
  23. 一种计算机程序产品,其特征在于,当所述计算机程序产品在计算机上运行时,使得所述计算机执行如权利要求1至19任一所述的方法。
PCT/CN2023/085916 2022-07-21 2023-04-03 调用冲突的可视化方法及装置 WO2024016729A1 (zh)

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN202210864804.0 2022-07-21
CN202210864804 2022-07-21
CN202211102945.5 2022-09-09
CN202211102945.5A CN117472419A (zh) 2022-07-21 2022-09-09 调用冲突的可视化方法及装置

Publications (1)

Publication Number Publication Date
WO2024016729A1 true WO2024016729A1 (zh) 2024-01-25

Family

ID=89616939

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/085916 WO2024016729A1 (zh) 2022-07-21 2023-04-03 调用冲突的可视化方法及装置

Country Status (1)

Country Link
WO (1) WO2024016729A1 (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110825377A (zh) * 2018-08-07 2020-02-21 北京国双科技有限公司 一种依赖冲突分析方法及装置
CN111736848A (zh) * 2020-06-15 2020-10-02 北京奇艺世纪科技有限公司 包冲突定位方法、装置、电子设备及可读存储介质
CN112799937A (zh) * 2021-01-13 2021-05-14 东北大学 基于GitHub自动化检测Maven项目中依赖冲突问题的方法
CN113778450A (zh) * 2020-07-10 2021-12-10 北京沃东天骏信息技术有限公司 依赖冲突的处理方法、装置、设备及存储介质

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110825377A (zh) * 2018-08-07 2020-02-21 北京国双科技有限公司 一种依赖冲突分析方法及装置
CN111736848A (zh) * 2020-06-15 2020-10-02 北京奇艺世纪科技有限公司 包冲突定位方法、装置、电子设备及可读存储介质
CN113778450A (zh) * 2020-07-10 2021-12-10 北京沃东天骏信息技术有限公司 依赖冲突的处理方法、装置、设备及存储介质
CN112799937A (zh) * 2021-01-13 2021-05-14 东北大学 基于GitHub自动化检测Maven项目中依赖冲突问题的方法

Similar Documents

Publication Publication Date Title
US10606739B2 (en) Automated program code analysis and reporting
US9524226B2 (en) System and method for display of software quality
US11086619B2 (en) Code analytics and publication platform
US8516443B2 (en) Context-sensitive analysis framework using value flows
US9811325B2 (en) Systems and methods for dynamically replacing code objects for code pushdown
US10671510B1 (en) Techniques for evaluating collected build metrics during a software build process
US11675575B2 (en) Checking source code validity at time of code update
US8935705B2 (en) Execution of highly concurrent processing tasks based on the updated dependency data structure at run-time
US9038185B2 (en) Execution of multiple execution paths
US9965257B2 (en) Automatic configuration of project system from project capabilities
US10514898B2 (en) Method and system to develop, deploy, test, and manage platform-independent software
CN110955409B (zh) 在云平台上创建资源的方法和装置
CN110196809B (zh) 接口测试方法及装置
US11836072B2 (en) Risk-based root cause identification methods and related autobuild systems
CN112148594A (zh) 一种脚本测试方法、装置、电子设备及存储介质
WO2024016729A1 (zh) 调用冲突的可视化方法及装置
US10922210B2 (en) Automatic software behavior identification using execution record
US9710360B2 (en) Optimizing error parsing in an integrated development environment
CN117472419A (zh) 调用冲突的可视化方法及装置
WO2022127263A1 (zh) 一种代码处理方法以及相关设备
US20240103853A1 (en) Code maintenance system
WO2024040930A1 (zh) 一种软件部署架构的管理方法以及相关设备
US11392482B2 (en) Data breakpoints on certain kinds of functions
CN112527658A (zh) 单元测试的测试用例处理方法及装置
CN114817058A (zh) 并发风险检测方法、装置、电子设备及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23841802

Country of ref document: EP

Kind code of ref document: A1