A component version upgrade method, device, equipment and medium

CN118567699BActive Publication Date: 2024-11-05HANGZHOU NEWGRAND TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411046666.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-01
Publication Date
2024-11-05
Estimated Expiration
2044-08-01

AI Technical Summary

Technical Problem

[0004]但是,由于各组件的应用程序编程接口发生变化,需要对大量组件进行修改和测试,人为操作准确率和效率较低

Benefits of technology

[0028] According to another aspect of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium stores computer instructions. The computer instructions are used to implement the component version upgrade method of any embodiment of the present invention when executed by a processor.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118567699B_ABST
    Figure CN118567699B_ABST
Patent Text Reader

Abstract

The present invention discloses a component version upgrade method, device, equipment and medium. The method comprises: obtaining a target component to be upgraded and a target version number of the target component of a target application, generating an update dependency configuration of the target component, and updating a node corresponding to the target component; generating an update call code of the target component according to the target component and the target version number; obtaining update information of at least one update dependency class according to the update call code of the target component; comparing the update information of each update dependency class with the corresponding adapter class of the target component, obtaining a class comparison result of each update dependency class, and detecting whether to update the corresponding adapter class of the target component; detecting the difference between the update call code and the target call code of the target component, and determining the difference type, and detecting whether to update the target call code of the target component. The technical solution of the embodiment of the present invention improves the accuracy of component version upgrade.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a component version upgrade method, device, equipment and medium. Background Art

[0002] Java is the most popular application development language, and related open source business components are emerging in an endless stream. All Java-based open source business components are managed through project management tool software. In the process of applying open source framework components, framework vulnerabilities will be exposed. If they are exploited by hackers, major accidents such as data leakage will occur. Therefore, it is necessary to monitor the vulnerabilities of the application system and upgrade the components of the application system with vulnerabilities.

[0003] Currently, when components of an application system are upgraded to the latest version of the components, the components of the application system are upgraded through manual operations.

[0004] However, due to changes in the application programming interfaces of various components, a large number of components need to be modified and tested, and the accuracy and efficiency of manual operations are low. Summary of the invention

[0005] The present invention provides a component version upgrade method, device, equipment and medium, which improve the accuracy of component version upgrade while taking into account hardware requirements and ensure the performance of component version upgrade.

[0006] According to one aspect of the present invention, a component version upgrade method is provided, the method comprising:

[0007] Obtain the target component to be upgraded of the target application and the target version number of the target component;

[0008] Generate the update dependency configuration of the target component according to the target component and the target version number, and update the node corresponding to the target component in the project file of the target application;

[0009] Generate the update calling code of the target component according to the target component and the target version number;

[0010] According to the update calling code of the target component, obtaining update information of at least one update dependent class;

[0011] Compare the update information of each update dependency class with the corresponding adapter class of the target component to obtain a class comparison result of each update dependency class;

[0012] According to the class comparison results of each update dependent class, detect whether to update the corresponding adapter class of the target component;

[0013] Detecting differences between the update call code and the target call code of the target component, and determining the type of the difference;

[0014] Based on the difference and the difference type, detect whether to update the target calling code of the target component.

[0015] According to another aspect of the present invention, a component version upgrade device is provided, the device comprising:

[0016] A component information acquisition module is used to acquire the target component to be upgraded of the target application and the target version number of the target component;

[0017] A node update module is used to generate an update dependency configuration of a target component according to the target component and the target version number, and to update the node corresponding to the target component in the project file of the target application;

[0018] A code generation module, used to generate an update calling code of a target component according to a target component and a target version number;

[0019] An update information acquisition module, used to acquire update information of at least one update dependency class according to an update calling code of a target component;

[0020] A comparison result acquisition module, used to compare the update information of each update dependency class with the corresponding adapter class of the target component to obtain a class comparison result of each update dependency class;

[0021] An update detection module, used to detect whether to update the corresponding adapter class of the target component according to the class comparison result of each update dependency class;

[0022] A type determination module, used to detect the difference between the update call code and the target call code of the target component, and determine the type of the difference;

[0023] The update detection module is used to detect whether to update the target calling code of the target component according to the difference and the difference type.

[0024] According to another aspect of the present invention, a component version upgrade device is provided, the component version upgrade device comprising:

[0025] at least one processor; and

[0026] a memory communicatively connected to at least one processor; wherein,

[0027] The memory stores a computer program that can be executed by at least one processor. The computer program is executed by at least one processor so that the at least one processor can execute the component version upgrade method of any embodiment of the present invention.

[0028] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the component version upgrade method of any embodiment of the present invention when executed.

[0029] The technical solution of the embodiment of the present invention obtains the target component to be upgraded of the target application and the target version number of the target component, generates the update dependency configuration of the target component, generates the update calling code of the target component according to the target component and the target version number, obtains the update information of at least one update dependency class, compares the update information of each update dependency class with the corresponding adapter class of the target component, obtains the class comparison result of each update dependency class, detects whether to update the corresponding adapter class of the target component, implements fine-grained class update, refines the operation of component version upgrade, improves the accuracy of component version upgrade, detects the difference between the update calling code and the target calling code of the target component through multi-dimensional data, determines the difference type, detects whether to update the target calling code of the target component, can judge whether to update according to different difference types, and implements the corresponding update operation, can implement differentiated update, and reduces manual operation in the update, reduces the labor cost of the update, and improves the efficiency of the component version upgrade.

[0030] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0032] Figure 1 is a flowchart of a component version upgrade method provided according to Embodiment 1 of the present invention;

[0033] Figure 2 is a flowchart of a component version upgrade method provided according to Embodiment 2 of the present invention;

[0034] Figure 3 is a flowchart of a component version upgrade method provided according to Embodiment 2 of the present invention;

[0035] Figure 4 is a structural diagram of a component version upgrade device provided according to an embodiment of the present invention;

[0036] Figure 5 It is a structural diagram of a component version upgrade device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0037] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

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

[0039] Embodiment 1

[0040] Figure 1 The present invention provides a flowchart of a component version upgrade method provided in the first embodiment of the present invention. The present invention can be applied to the case of component version upgrade, and the method can be executed by a component version upgrade device, which can be implemented in the form of hardware and / or software, and can be configured in a component version upgrade device.

[0041] See also Figure 1 The component version upgrade method shown includes:

[0042] S101. Obtain a target component to be upgraded of a target application and a target version number of the target component.

[0043] The component is used to implement a specific function and can be integrated into the target application. The target component is usually a component whose functions are provided by a third party. For example, the target application is a document editing application, and the target component can be a formula editing component. The target version number can be an identifier of the version to be upgraded corresponding to the target component.

[0044] Specifically, an automated script can be built through an integrated development environment (IntelliJ IDEA, IDEA), and the addition and upgrade of components of the project management tool software (maven) can be managed through the automated script to achieve the upgrade of the maven components in the project management tool software. The target application includes at least one component. At least one component can be upgraded, so the target application corresponds to at least one target component, and one target component corresponds to a target version number. Obtain the target component to be upgraded of the target application and the target version number of the target component. The target component and the target version number can be specified by the user or automatically identified in the upgraded component library.

[0045] In one example, the target component to be upgraded of the target application is log4j, and the target version number of the target component is 2.18.1.

[0046] The upgrade mechanism of each component can be preset. When a target component is detected to have a lot of update data, it indicates that the component has many vulnerabilities. The component can be automatically monitored and the developer can be warned when the target component needs to be upgraded. The developer can then decide whether to update the target component. The last upgrade time of the target component can be obtained. If the time interval between each component upgrade is long, it indicates that there may be a major update in the component upgrade. The time between the last upgrade time and the current time can be determined. When the time is longer than the preset time threshold, the developer is warned to upgrade with caution.

[0047] An upgrade process version library can be established, and a version upgrade model can be established based on the frequency of component upgrades and the span between component upgrade versions. If the frequency of component upgrades is relatively high, the component will be automatically used as a monitor, indicating that the component has many vulnerabilities, and the developer will be automatically warned to replace it.

[0048] S102: Generate an update dependency configuration of the target component according to the target component and the target version number, and update a node corresponding to the target component in a project file of the target application.

[0049] Among them, updating dependency configuration can be used to describe the configuration data corresponding to the target component and the target version number. The project file can be a project object model file corresponding to the project management tool Maven. Nodes are set in the project file, and one component corresponds to one node. Different nodes store configuration data of different components, and a node is also configured with the relationship between the node and other nodes.

[0050] Specifically, the update dependency configuration of the target component is generated according to the target component and the target version number. The generation method includes but is not limited to: large language model, back propagation neural network, convolutional neural network, recurrent neural network, generative adversarial neural network, graph neural network or long short-term memory network, etc., and the embodiment of the present invention does not limit this. In the project file of the target application, find whether it contains update dependency configuration information. If not, a node corresponding to the target component is automatically added to the project file, which is equivalent to integrating the function of the component in the application. Therefore, when the target component needs to be upgraded and there is a node corresponding to the target component in the project file of the target application, it is necessary to modify the node corresponding to the target component; when the target component needs to be upgraded and there is no node corresponding to the target component in the project file of the target application, it is necessary to create a new node corresponding to the target component. Among them, modifying the node corresponding to the target component can be to delete the established node and create a new node corresponding to the update dependency configuration.

[0051] In one example, the target component is log4j, and the target version number of log4j is 2.18.1. According to the target component and the target version number, it can be used as the input data of the large language model. The preset input template (prompt) of the large language model is: "XX YY's Maven dependency". The data at the positions of XX and YY can be replaced. XX can be replaced by the target component, and YY can be replaced by the target version number. For example, the input data of the large language model can be the Maven dependency of log4j 2.18.1. The update dependency configuration of the target component log4j is generated through the large language model. The update dependency configuration is <artifactid> log4j< / artifactid> <version> 2.18.1< / version> . Find the executable project file, find the updated dependency configuration information that does not contain Maven in the project file, and automatically insert the dependency subordinate node into the dependencies node, that is, insert the node corresponding to the target component to be added into the project file. The large language model returns the information of the dependency node to complete the node update.

[0052] S103: Generate an update calling code for the target component according to the target component and the target version number.

[0053] The update calling code may be a code for calling a target component of a target version number.

[0054] The target component and the target version number can be input into the large speech model to obtain the update calling code. Specifically, the preset prompt of the large language model is: "Update calling code for component XX and version number YY". According to the fusion of the prompt of the target component and the target version number with the large language model, by replacing the identifier of the target component with XX and the target version number with YY, the update calling code for calling the code in the executable file corresponding to the target component can be generated by the large language model.

[0055] In an example, the target component is log4j, the target version number of log4j is 2.18.1, and the input data for generating the large language model is: the update calling code of log4j 2.18.1. The update calling code of the target component log4j is obtained through the large language model.

[0056] S104: Obtain update information of at least one update-dependent class according to the update calling code of the target component.

[0057] The updated dependency class may refer to the dependency class that needs to be updated in the target component. The target component includes at least one dependency class. The update information may refer to the data updated by the updated dependency class relative to the current dependency class of the target component.

[0058] Specifically, according to the update calling code of the target component, the update information of the update dependency class included in the update calling code can be obtained, the function header of the current dependency class of the target component and the function header of the update dependency class can be traversed, and the function header of the current dependency class of the target component and the function header of the corresponding update dependency class can be compared to obtain the difference between the function header of the current dependency class of the target component and the function header of the update dependency class, and determine the update information of the update dependency class. The traversal method includes but is not limited to: depth-first traversal or breadth-first traversal, etc., and the embodiment of the present invention does not limit this.

[0059] In an example, the update call code of the target component is:

[0060] class t test0(a,b,c)

[0061] class t test1(a, b, c)

[0062] The current dependency class of the target component is class t test0 (a, b, c). By depth-first traversing the function header of the current dependency class of the target component and the function header of the updated dependency class, the function header of the current dependency class of the target component is compared with the function header of its corresponding updated dependency class, and the difference between the function header of the current dependency class of the target component and the function header of the updated dependency class is class t test1 (a, b, c). The update information of the updated dependency class t is obtained as classt test1 (a, b, c).

[0063] S105 . Compare the update information of each update-dependent class with the corresponding adapter class of the target component to obtain a class comparison result of each update-dependent class.

[0064] The adapter class corresponds to the dependency class included in the target component one by one. The adapter class may refer to the inheritance of the dependency class included in the target component, and the adapter class implements the corresponding function of the corresponding dependency class. The class comparison result may be the comparison result of the update information of the updated dependency class and the data contained in the corresponding adapter class of the target component.

[0065] The update information includes at least one of the following: class name, method name and parameter name. Specifically, the update information includes: class name, method name and parameter name. Comparing the update information of each update-dependent class with the corresponding adapter class of the target component is equivalent to comparing the class name, method name and parameter name in the update information of the update-dependent class with the class name, method name and parameter name in the corresponding adapter class of the corresponding target component. Obtain data that is inconsistent with the update information of each update-dependent class and the corresponding adapter class of the target component. The acquisition method includes but is not limited to: brute force matching algorithm, optimized string matching algorithm or multi-pattern matching algorithm, etc., and the embodiment of the present invention does not limit this, and obtains the class comparison result of each update-dependent class.

[0066] In one example, the update information of the update dependency class is class t test (a, b, c). The update information of the update dependency class is compared with the corresponding adapter class class t test (a, b) of the target component, and the class comparison result of the update dependency class is that the class identifier is the same, the method identifier is the same, and the parameter identifier is different.

[0067] S106. According to the class comparison result of each update dependent class, detect whether to update the corresponding adapter class of the target component.

[0068] Specifically, based on the class comparison results of each update dependent class, the comparison results of the class identifier, the comparison results of the method identifier and the comparison results of the parameter identifier are obtained, and it can be detected whether to update the corresponding adapter class of the target component based on the comparison results of each identifier. For example, it is possible to detect whether to update the corresponding adapter class of the target component based on different types of identifiers and different numbers of identifiers. Exemplarily, the input class comparison results can be identified through a large language model to obtain a judgment result on whether to update.

[0069] In one example, the class comparison result of updating the dependent class is that the class identifiers are the same, the method identifiers are the same, and the parameter identifiers are different. Through the large language model detection, the detection result is that the adapter class class t test (a, b) of the target component needs to be updated.

[0070] S107: Detect the difference between the update calling code and the target calling code of the target component, and determine the difference type.

[0071] The target calling code may be a code for calling a target component of a current version number (a version number that has not been updated). The difference may be different data between the update calling code and the target calling code of the target component. The difference type may be a data type of the difference between the update calling code and the target calling code of the target component.

[0072] Specifically, the difference type may include method addition or method deletion. Obtain the target calling code of the target component, compare the update calling code with the target calling code through a string matching algorithm, obtain inconsistent data between the update calling code and the target calling code, obtain the difference between the update calling code and the target calling code, identify the difference between the update calling code and the target calling code of the target component, and determine the difference type.

[0073] In one example, the update call codes are test1(a, b, c) and test2(a, b), and the target call code of the target component is test1(a, b, c). The difference between the update call code and the target call code of the target component is detected by the neural network as test2(a, b), and the difference type is determined to be method addition.

[0074] S108. Detect whether to update the target calling code of the target component according to the difference and the difference type.

[0075] Specifically, whether to update the target calling code of the target component can be detected based on the difference and the difference type, and whether to update the target calling code of the target component can be detected based on the difference type and the amount of difference data. An update condition can be preset. If the update data result obtained by analyzing the difference and the difference type meets the update condition, it indicates that the target calling code of the target component needs to be updated. If the update data result obtained by analyzing the difference and the difference type does not meet the update condition, it indicates that the target calling code of the target component does not need to be updated. The update condition can be a threshold value of the amount of data that is greater than the difference between the update calling code and the target calling code of the target component.

[0076] In one example, the preset update condition is that the difference parameters are greater than 2, and the difference type is method addition. The update call codes are test1 (a, b, c) and test2 (a, b), and the target call code of the target component is test1 (a, b, c). The difference between the update call code and the target call code of the target component is test2 (a, b), and the difference type is method addition. According to the difference and difference type, it is detected that the difference parameters are greater than 2, and the difference type is method addition, and the target call code of the target component is updated.

[0077] When determining the update, a corresponding update method is determined according to the difference and the difference type, and the target calling code is updated using the corresponding update method. Exemplarily, the target calling code is replaced with the updated calling code.

[0078] The technical solution of the embodiment of the present invention obtains the target component to be upgraded of the target application and the target version number of the target component, generates the update dependency configuration of the target component, generates the update calling code of the target component according to the target component and the target version number, obtains the update information of at least one update dependency class, compares the update information of each update dependency class with the corresponding adapter class of the target component, obtains the class comparison result of each update dependency class, detects whether to update the corresponding adapter class of the target component, implements fine-grained class update, refines the operation of component version upgrade, improves the accuracy of component version upgrade, detects the difference between the update calling code and the target calling code of the target component through multi-dimensional data, determines the difference type, detects whether to update the target calling code of the target component, can judge whether to update according to different difference types, and implements the corresponding update operation, can implement differentiated update, and reduces manual operation in the update, reduces the labor cost of the update, and improves the efficiency of the component version upgrade.

[0079] Optionally, the update information includes: class name, method name and parameter name; the class comparison results include class identification comparison results, method identification comparison results and parameter identification comparison results; based on the class comparison results of each update dependency class, detect whether to update the corresponding adapter class of the target component, including: based on the class comparison results of each update dependency class, detect the number of identification changes of each update dependency class; based on the number of identification changes of each update dependency class, determine the change type of each update dependency class; for each update dependency class, when the change type of the update dependency class is a minor change, according to the update calling code of the update dependency class, adjust the parameters in the adapter class corresponding to the update dependency class; for each update dependency class, when the change type of the update dependency class is a medium change, according to the update calling code of the update dependency class, generate a new adapter class and replace the adapter class corresponding to the update dependency class; for each update dependency class, when the change type of the update dependency class is a major change, generate the decompiled code of the target component, and repair the compiled code according to the current version vulnerability of the update dependency class.

[0080] Among them, the class name can be the identifier of the object set with shared data and data processing methods. The method name can be the identifier of the function of the data processing method. The parameter name can be the parameter identifier of the parameter contained in the function header of the data processing method. The class identifier comparison result can be the result of comparing the identifier of the update dependency class with the identifier of the corresponding adapter class of the target component. The method identifier comparison result can be the result of comparing the identifier of the function of the update dependency class with the identifier of the function of the corresponding adapter class of the target component. The parameter identifier comparison result can be the result of comparing the parameter contained in the function header of the update dependency class with the class name of the corresponding adapter class of the target component. The number of identifier changes can be the number of identifiers that have changed by comparing the class name, method name and parameter name of the update dependency class with the class name, method name and parameter name of the corresponding adapter class of the target component. The change type can be the type of the number of identifier changes. The decompiled code can be the code generated by decompiling the update dependency class.

[0081] Specifically, the update information includes: class name, method name and parameter name; the class comparison result includes class identification comparison result, method identification comparison result and parameter identification comparison result. Usually the identification comparison result may include unchanged, deleted, modified and added. According to the class identification comparison result, the identification of the changed class and the number of changed classes are determined; according to the method identification comparison result, the identification of the changed function and the number of changed functions are determined; according to the parameter identification comparison result, the identification of the changed parameter and the number of changed parameters are determined. Corresponding detection conditions can be configured for each change type. A detection condition is configured with a change identification type range and a change quantity threshold. The change identification and the change quantity corresponding to an update-dependent class are detected, and the detection conditions of each change type are used for detection to determine the change type of the update-dependent class.

[0082] For each update dependency class, when the change type of the update dependency class is a minor change, it indicates that the number of identification changes is small. The difference between the update information of the update dependency class and the target call code can be compared through a matching algorithm. According to the update call code of the update dependency class, the parameters in the adapter class corresponding to the update dependency class are adjusted. For each update dependency class, when the change type of the update dependency class is a medium change, it indicates that the number of identification changes is within the preset medium identification change number. The difference between the update information of the update dependency class and the target call code can be compared through a matching algorithm. According to the update call code of the update dependency class, a new adapter class is generated and the adapter class corresponding to the update dependency class is replaced. Code replacement can be performed by creating a code replacement function. For each update dependency class, when the change type of the update dependency class is a major change, the decompiled code of the target component is generated, and the compiled code is repaired according to the current version vulnerability of the update dependency class. The repair method can be queried through a large language model. Exemplarily, the detection condition of the change type of a minor change may be that the changed identifier is a parameter identifier, and the number of changes is less than a preset first quantity threshold; the detection condition of the change type of a medium identifier change may be that the changed identifier includes at least one of a parameter identifier, a class identifier, and a method identifier, the number of changes is less than a preset second quantity threshold, or there is a method identifier deletion; the detection condition of the change type of a major change may be that the changed identifier includes at least one of a parameter identifier, a class identifier, and a method identifier, the number of changed class identifiers is greater than a third threshold, or there is a serious vulnerability, etc. In addition, there are other situations, which are not exhaustive and can be set as needed.

[0083] In one example, the corresponding adapter class of the target component is class t test (a, b). The update information of the update dependency class is class t test (a, b, c). The class comparison result of the update dependency class is that the class identifier is the same, the method identifier is the same, and the parameter identifier is different. According to the class comparison result of each update dependency class, the number of changes in the identifier of each update dependency class is detected to be 1. The data range of the preset identifier change number is [0,3], [4,10]. The change type corresponding to [0,3] is a minor change, and the change type corresponding to [4,10] is a medium change. The number of changes in the identifier of the update dependency class is 1. According to the number of changes in the identifier of the update dependency class, it is determined that the change type of the update dependency class is a minor change. The update information of the update dependency class is compared with the target call code through a matching algorithm to obtain the difference between the two. According to the update call code of the update dependency class, the parameters in the adapter class corresponding to the update dependency class are adjusted.

[0084] By determining the change type of each update dependency class according to the number of changes in the identification of each update dependency class, when the change type of the update dependency class is a minor change, adjusting the parameters in the adapter class corresponding to the update dependency class according to the update calling code of the update dependency class, when the change type of the update dependency class is a medium change, generating a new adapter class according to the update calling code of the update dependency class, and replacing the adapter class corresponding to the update dependency class, when the change type of the update dependency class is a major change, generating the decompiled code of the target component, and repairing the compiled code according to the current version vulnerability of the update dependency class, executing different update dependency class processing methods for different update dependency class change types, refining the component version upgrade operation, and improving the accuracy of component version upgrade.

[0085] Optionally, based on the differences and difference types, detect whether to update the target calling code of the target component, including: when the difference type is method deletion, extracting update method parameters in the update calling code; classifying each update method parameter to obtain the parameter type of each update method parameter; in the update calling code, establishing corresponding variables for update method parameters whose parameter types are non-calling variables, and assigning the parameter values ​​of the update method parameters of the non-calling variables to the corresponding variables; replacing and inserting the corresponding variables at the position of the update method parameters of the non-calling variables; in the update calling code, adding reference codes of the package identifier and class identifier corresponding to each adapter class to obtain new code, and replacing the target calling code of the target component.

[0086] When the difference type is method deletion, determine to update the target call code of the target component. Wherein, method deletion can be to update the call code by comparing the update call code with the target call code of the target component, thereby reducing the difference type of the data processing method. The update method parameter can be the parameter corresponding to the function header in the update call code. The parameter type can be the type of the update method parameter. The parameter type can include non-call variables and call variables. Wherein, non-call variables can include variables with fixed values ​​and / or variables whose values ​​can be obtained from the configuration file. The call variables can include: variables provided externally such as variables of the call chain and / or variables with values ​​obtained by calling the database, and the parameter type of the variable can be judged according to whether the network address is set and whether the value is obtained by calling the interface. The reference code can be a code that references a package identifier and a class identifier, and the package identifier can refer to the identifier of the data packet corresponding to the adapter class, and the class identifier can refer to the identifier of the class included in the adapter class, and the adapter class can refer to all adapter classes after the update.

[0087] Specifically, when the difference type is method deletion, determine to update the target calling code of the target component. Extract the update method parameters in the update calling code, classify each update method parameter, and obtain the parameter type of each update method parameter. In the update calling code, find the update method parameters whose parameter type is a non-calling variable, establish corresponding variables for the update method parameters whose parameter type is a non-calling variable, and assign the parameter values ​​of the update method parameters of the non-calling variable to the corresponding variables, replace the corresponding variables and insert them into the position of the update method parameters of the non-calling variable, in the update calling code, add the reference code of the package identifier and class identifier corresponding to each adapter class, obtain the new code, and replace the target calling code of the target component.

[0088] In one example, the update call code is test1 (a, b※c), and the target call code of the target component is test1 (a, b※c) and test2 (d, e※f). The difference between the update call code and the target call code of the target component is test2 (d, e※f), and the difference type is method deletion, which determines that the target call code of the target component is updated. Extract the update method parameters a and b※c in the update call code; classify the parameters of each update method, and get the parameter type of a as a non-call variable, and b※c as a call variable; in the update call code, create a variable n for a, and assign the parameter value of a to n; replace n with a; in the update call code, add the reference code of the package identifier and class identifier corresponding to each adapter class to get the new code, and replace the target call code of the target component.

[0089] When the difference type is method deletion, the update method parameters are extracted in the update calling code, and the update method parameters are classified to obtain the parameter type of each update method parameter. In the update calling code, corresponding variables are established for the update method parameters whose parameter types are non-calling variables, and the parameter values ​​of the update method parameters of the non-calling variables are assigned to the corresponding variables, and the corresponding variables are replaced and inserted into the position of the update method parameters of the non-calling variables. In the update calling code, reference codes of the package identifier and class identifier corresponding to each adapter class are added to obtain new codes, and the target calling code of the target component is replaced to realize fine-grained class updates, refine the operation of component version upgrades, and execute different target calling code processing methods for different difference types, refine component upgrade operations, and improve the accuracy of component upgrades.

[0090] Optionally, based on the difference and the difference type, detect whether to update the target calling code of the target component, including: when the difference type is method addition, generate alternative code for calling the target calling code of the target component based on at least one newly added parameter in the difference; in the alternative code, assign each newly added parameter to null; use the same input in the alternative code and the target calling code respectively to obtain the output of the alternative code and the output of the target calling code; compare the output of the alternative code with the output of the target calling code to obtain a unit test result; when the unit test results are consistent, do not update the target calling code of the target component; when the unit test results are inconsistent , detect whether each newly added parameter has a target parameter with the same intention; when there is no target parameter with the same intention, in the target calling code, generate the update method parameter corresponding to each newly added parameter according to the parameter type of each newly added parameter; in the target calling code, establish a corresponding variable for the update method parameter whose parameter type is a non-calling variable, assign the parameter value of the update method parameter of the non-calling variable to the corresponding variable, and replace and insert the corresponding variable at the position of the update method parameter of the non-calling variable; when there is a target parameter with the same intention, use the variable of the target parameter in the update calling code to replace the newly added parameter, and replace the target calling code.

[0091] Among them, the method addition can be compared with the target calling code, and the updating calling code adds the type of data processing method. The alternative code can be a new code generated by encapsulating the target calling code, and the target calling code is called in the alternative code to inherit the function of the target calling code. The unit test result can be used to test whether the functions of the alternative code and the target calling code are consistent, specifically to test whether the output result of the alternative code is consistent with the output result of the target calling code under the same input. The target parameter with the same intention as the newly added parameter can refer to the function of the newly added parameter being the same as the function of the target parameter, for example, as the input of the same function, performing the same processing, or being in the same call chain node, etc. The update method parameter passing can be an externally provided parameter in the update calling code. Non-call variables can refer to parameters specified by internal transmission, for example, non-call parameters are not externally provided parameters.

[0092] Specifically, when the difference type is method addition, the difference includes at least one newly added function, and one newly added function includes at least one newly added parameter. According to at least one newly added parameter in the difference, an alternative code for calling the target calling code is generated, specifically, the parameter setting of the alternative code includes all newly added parameters, and in the alternative code, each newly added parameter is assigned to null, and the output of the alternative code and the output of the target calling code are obtained by using the same input in the alternative code and the target calling code, and the output of the alternative code and the output of the target calling code are compared to obtain the unit test result. When the unit test result is consistent, it indicates that the parameters added after the update have no change to the original function function, so that the functions implemented by the target calling code and the updated calling code are essentially the same, and the target calling code of the target component is not updated. When the unit test result is inconsistent, the target calling code of the target component needs to be updated to detect whether each newly added parameter has the same intended target parameter. It can be detected whether the newly added parameters have the same intended target parameters based on the knowledge graph generated by the parameters. When the newly added parameters do not have the same intended target parameters, in the target calling code, according to the parameter type of each newly added parameter, the updated method parameter corresponding to each newly added parameter is generated. Different parameter types correspond to different parameter update methods. In the target calling code, corresponding variables are established for the update method parameters whose parameter types are non-calling variables, and the parameter values ​​of the update method parameters of the non-calling variables are assigned to the corresponding variables, and the corresponding variables are replaced and inserted into the position of the update method parameters of the non-calling variables. When there are target parameters with the same intention, the variables of the target parameters are used to replace the newly added parameters in the update calling code, which is equivalent to replacing the newly added parameters with the variables of the target parameters in the target calling code.

[0093] Compare the output of the candidate code with the output of the target calling code to get the unit test result. You can create a unit test class (mock program) to automatically execute unit tests. You can run the mock program to call the target calling code and the candidate code to process the same input, and check whether the output of the candidate code is the same as the output of the target calling code. If the output of the candidate code is the same as the output of the target calling code, it means that the candidate code and the target calling code have the same intention. If the output of the candidate code is different from the output of the target calling code, it means that the candidate code and the target calling code do not have the same intention.

[0094] In one example, the update calling code is test1 (a, b ※ c), and the target calling code of the target component is test1 (a). The difference between the update calling code and the target calling code of the target component is b ※ c, and the difference type is method addition. Based on the newly added parameters b ※ c in the difference, an alternative code for calling the target calling code of the target component is generated. In the alternative code, each newly added parameter is assigned a value of null. The same input data is input into the alternative code and the target calling code respectively, and the output of the alternative code is 3 and the output of the target calling code is 3. The output of the alternative code 3 is compared with the output of the target calling code 3, and the unit test results are consistent, indicating that the parameters added after the update have no change to the original function function, so the functions implemented by the target calling code and the update calling code are essentially the same, and the target calling code of the target component is not updated.

[0095] By generating an alternative code for the target calling code of the target component according to at least one newly added parameter in the difference when the difference type is method addition, in the alternative code, assigning each newly added parameter to be empty, using the same input in the alternative code and the target calling code respectively, obtaining the output of the alternative code and the output of the target calling code, comparing the output of the alternative code with the output of the target calling code to obtain a unit test result, and when the unit test results are consistent, not updating the target calling code of the target component, and when the unit test results are inconsistent, detecting whether each newly added parameter has the target parameter with the same intention, and when there is no target parameter with the same intention, in the target calling code, checking whether each newly added parameter has the target parameter with the same intention, and when the target calling code does not have the target parameter with the same intention, The parameter type of the number is generated, and the update method parameters corresponding to the newly added parameters are generated. In the target calling code, corresponding variables are established for the update method parameters whose parameter types are non-calling variables, and the parameter values ​​of the update method parameters of the non-calling variables are assigned to the corresponding variables, and the corresponding variables are replaced and inserted into the position of the update method parameters of the non-calling variables. When there are target parameters with the same intention, the variables of the target parameters are used in the update calling code to replace the newly added parameters, and the target calling code is replaced. Different parameter replacement methods are executed for different parameters, which can realize differentiated parameter replacement, refine the parameter replacement method, improve the accuracy of component upgrades, and do not require manual operation, thereby reducing labor costs.

[0096] Optionally, detect whether each newly added parameter has a target parameter with the same intention, including: querying in the project code whether there is a target parameter with the same parameter type as each newly added parameter; and / or obtaining an upgrade data packet of the target component and a current data packet of the target component; detecting the upgrade data packet and the current data packet of the target component to detect whether each newly added parameter has a target parameter with the same call chain.

[0097] The project code may be the code contained in the project file. The upgrade data package may be a data package used to upgrade the target component, which is usually downloaded from the service system of the target component. The current data package may be a data package of the target component with the current version number. The call chain may be used to describe the call relationship between elements such as classes and / or parameters in a component.

[0098] Specifically, in the project code, it is queried whether there are target parameters of the same parameter type as the newly added parameters, and the query method includes but is not limited to: sequential search algorithm, binary search algorithm or hash search algorithm, etc. And / or the upgrade data packet of the target component and the current data packet of the target component are obtained, and the upgrade data packet of the target component and the current data packet are detected, and whether there are target parameters of the same call chain for each newly added parameter, and the detection method can be a neural network or a knowledge graph, etc.

[0099] In one example, in the project code, a sequential search algorithm is used to query the target parameters that have the same parameter type as each newly added parameter. The upgrade data packet of the target component imports numpy, and the current data packet of the target component imports numpy, detect that the upgrade data packet of the target component is the same as the current data packet, the newly added parameter 1 in the upgrade data packet can be called by function 1, and the parameter in the current data packet can be called by function 1, and the target parameter with the same call chain is detected as parameter 1 through a neural network.

[0100] By querying in the project code whether there are target parameters with the same parameter type as each newly added parameter, and / or obtaining the upgrade data packet of the target component and the current data packet of the target component, detecting the upgrade data packet and the current data packet of the target component, and detecting whether each newly added parameter has the target parameter of the same call chain, the detection result of detecting whether each newly added parameter has the target parameter of the same call chain can be obtained, and then the update method can be selected, so that data update is more accurate and the accuracy of component update is improved.

[0101] Embodiment 2

[0102] Figure 2 and Figure 3A flowchart of a component version upgrade method provided for the second embodiment of the present invention. Based on the above embodiment, the embodiment of the present invention concretizes "obtaining the target component to be upgraded of the target application and the target version number of the target component" as "before obtaining the target component to be upgraded of the target application and the target version number of the target component, it also includes: obtaining the target component to be automatically upgraded and the current version number; generating the current dependency configuration of the target component according to the target component and the current version number, and updating the node corresponding to the target component in the project file of the target application; generating the first call code of the target component according to the target component and the target version number; obtaining the current information of at least one current dependent class according to the first call code of the target component; creating the adapter class corresponding to each current dependent class in the project file according to the current information of each dependent class, and the adapter class corresponding to the current dependent class inherits the current dependent class; establishing the corresponding relationship between the project file and the current information of each current dependent class in the project file; extracting the current method parameter in the first call code, and adjusting the first call code according to the current method parameter to obtain the second call code; in the second call code, adding the reference code of the package identifier and class identifier corresponding to each current adapter class to obtain the target call code of the target component", further improving the accuracy of component version upgrade. It should be noted that for the parts not described in detail in the embodiments of the present invention, reference may be made to the descriptions of other embodiments.

[0103] See also Figure 2 and Figure 3 The component version upgrade method shown in the figure is: Figure 2 After step S210 is completed, execute Figure 3 Step S211 in the embodiment comprises:

[0104] S201. Obtain the target component that needs to be automatically upgraded and the current version number.

[0105] The embodiments of the present invention are applicable to the scenario where the data associated with the target component needs to be modified before the target component is automatically upgraded. Specifically, the target component that needs to be automatically upgraded and the current version number corresponding to the target component can be obtained by user-specified method or automatic scanning method. The current version number may refer to the identifier of the version that the target component should currently be in. The current version number is not necessarily the latest version number. For example, the automatic scanning method can parse the component library configured by mirror through the settings.xml file path configured by idea Maven, obtain all indexes (index) of the component library, automatically scan the version upgrade data of the pom.xml file, and obtain the target component that needs to be automatically upgraded and the current version number. The user-specified method can be that the user specifies the Maven component to be upgraded and its current version number by mouse selection or keyboard input.

[0106] In one example, after idea is started, it obtains the settings.xml file path of the idea's Maven component configuration, parses the component library path of the mirror configuration, and crawls the names and versions of all components through a web crawler, and performs localized caching or adds new versions; when the user needs to add a Maven component, the intelligent component interface is obtained through the shortcut key alt+M, the name of the Maven component to be added is entered in the intelligent component, and the Maven component version number is selected to obtain the target component that needs to be automatically upgraded, which is log4j and the current version number 2.17.1.

[0107] S202: Generate a current dependency configuration of the target component according to the target component and the current version number, and update a node corresponding to the target component in a project file of the target application.

[0108] The current dependency configuration may be configuration information corresponding to the current version number of the target component.

[0109] Specifically, the current dependency configuration of the target component is generated according to the target component and the current version number. The generation method includes but is not limited to: large language model, back propagation neural network, convolutional neural network, recurrent neural network, generative adversarial neural network, graph neural network or long short-term memory network, etc., and the embodiment of the present invention does not limit this. In the project file of the target application, find whether it contains the current dependency configuration information. If not, a node corresponding to the target component is automatically added to the project file, which is equivalent to integrating the function of the component in the application. Therefore, when the target component needs to be upgraded and the node corresponding to the target component exists in the project file of the target application, the node corresponding to the target component needs to be modified; when the target component needs to be upgraded and the node corresponding to the target component does not exist in the project file of the target application, a new node corresponding to the target component needs to be created. Among them, modifying the node corresponding to the target component can be to delete the established node and create a new node corresponding to the current dependency configuration.

[0110] In one example, the target component is log4j, and the target version number of log4j is 2.17.1. According to the target component and the target version number, it can be used as the input data of the large language model. The preset input template (prompt) of the large language model is: "XX YY's Maven dependency". The data at the positions of XX and YY can be replaced. XX can be replaced by the target component, and YY can be replaced by the target version number. For example, the input data of the large language model can be the Maven dependency of log4j 2.17.1. The current dependency configuration of the target component log4j is generated through the large language model. The current dependency configuration is <artifactid> log4j< / artifactid> <version> 2.17.1< / version>. Search for the pom.xml file in the executable project file collection, and find the current dependency configuration information that does not contain Maven in the file. Then automatically insert the dependency subordinate node into the dependencies node, that is, insert the executable file corresponding to the target component to be added into the project file. The large language model returns the information of the dependency node to complete the node update.

[0111] S203: Generate a first calling code of the target component according to the target component and the current version number.

[0112] The first calling code may be a code for calling the code in the executable file corresponding to the current version number of the target component. Specifically, the method name of the first calling code is a preset method name.

[0113] Specifically, the prompt of the preset large language model is: "XX YY's first calling code". According to the fusion of the target component and the current version number with the prompt of the large language model, by replacing the target component with XX and the current version number with YY, the first calling code corresponding to the target component can be generated through the large language model.

[0114] In an example, the target component is log4j, the current version number of log4j is 2.17.1, and the input data for generating the large language model is: the updated calling code of log4j 2.17.1. The first calling code of the target component log4j is obtained through the large language model.

[0115] S204. According to the first calling code of the target component, obtain current information of at least one current dependent class.

[0116] The first calling code includes the class name of the current dependent class of the target component. Specifically, the first calling code includes a reference code, and the reference code includes the class names of all dependent classes included in the target component. In addition, the reference code also includes all data packets included in the target component. The current dependent class may refer to the dependent class in the first calling code. The target component includes at least one dependent class. The current information may be data of the current dependent class of the target component.

[0117] Specifically, according to the first calling code of the target component, the current information of the current dependency class included in the first calling code can be obtained, and the acquisition method includes but is not limited to: neural network, depth-first traversal or breadth-first traversal, etc., which is not limited by the embodiment of the present invention.

[0118] In one example, according to the first calling code of the target component log4j, the current information of the target component log4j is obtained as test (a, b, c) through neural network recognition.

[0119] S205. Create an adapter class corresponding to each current dependent class in the project file according to the current information of each dependent class. The adapter class corresponding to the current dependent class inherits the current dependent class.

[0120] The adapter class corresponds to the dependency class included in the target component one by one. The adapter class may refer to the inheritance of the dependency class included in the target component, and the adapter class implements the corresponding function of the corresponding dependency class.

[0121] Specifically, according to the current information of each dependent class, an adapter class corresponding to each current dependent class is created in the project file. According to the import data corresponding to the first calling code, the data package name and class name to be loaded are obtained. According to the class name, the bytecode corresponding to the class name is queried from the data package to obtain the data package corresponding to the class name. The bytecode corresponding to the class name is parsed to obtain the public method included in the class name. According to the class name and the conditional constructor (wapper), a new adapter class is created under the current project. The new adapter class corresponds to the current dependent class one by one, and the adapter class inherits the original current dependent class. The class name and method name of the original current dependent class are obtained, and a method with the same class name and method name as the original current dependent class is generated in the new adapter class. However, the generated method only includes the method name and parameter name, and there is no method body. A method body is created for the newly generated adapter class, and the method name of the original current dependent class is called. The method body can be created in the following way: calling the current dependent class and passing in the parameters required by the current dependent class.

[0122] In an example, for example, in the adapter class, re-call the original class name with super.

[0123] The adapter class super.test(a,b) created for the current dependent class test(a,b),

[0124] The method body of the adapter class is: test(a,b)

[0125] In addition, you need to create corresponding metadata in the directory. Specifically, create an XX target folder in the resource file, and establish corresponding metadata information in the target folder. The metadata information includes the corresponding information between pom.xml and the adapter class wapper, the corresponding relationship between pom.xml and the package name, and the corresponding relationship between pom.xml and the class name.

[0126] S206: Establish a correspondence between the project file and the current information of each current dependent class in the project file.

[0127] The corresponding relationship may be mapping data between the project file and the current information of each current dependency class. One project file corresponds to the current information of at least one current dependency class, and one current dependency class corresponds to one current information.

[0128] Specifically, a project file may correspond to at least one current dependency class, and a current class may correspond one-to-one to its current information. The identifiers of each project file and each current dependency class may be identified through a large language model, and the correspondence between the project file and the current information of each current dependency class may be established in the project file based on the correspondence between the identifiers.

[0129] In an example, the identifier of the project file is class t, the identifier of the current dependent class 1 is class t, the identifier of the current dependent class 2 is class d, and a correspondence between the project file and the current information of the current dependent class 1 is established in the project file.

[0130] S207. Extract the current method parameters from the first calling code, and adjust the first calling code according to the current method parameters to obtain a second calling code.

[0131] The current method parameter may be a parameter of the current dependent class contained in the first calling code. The second calling code may be a code after the parameters of the first calling code are adjusted.

[0132] Specifically, extract the current method parameters in the first calling code, classify the current method parameters, obtain the parameter type of each current method parameter, and according to the parameter type of the current method parameter, establish corresponding variables for the method parameters whose parameter types are non-calling variables in the first calling code, and assign the parameter values ​​of the method parameters of the non-calling variables to the corresponding variables; replace and insert the corresponding variables at the position of the method parameters of the non-calling variables to obtain the second calling code. The generation method of the first calling code is the same as the method for updating the target calling code when the difference type is method deletion. The method parameters of the calling variables can be parameters that depend on external configuration, such as network addresses or ports. The method parameters of the calling variables can directly perform variable replacement, or no variable replacement is performed. The first calling code that replaces the method parameters of the non-calling variables is determined as the second calling code.

[0133] In an example, the first calling code is test1 (a, b), and the current method parameters a and b are extracted in the first calling code; the current method parameters are classified to obtain the parameter type of a as a non-calling variable, and b as a calling variable; in the first calling code, a variable n is created for a, and the parameter value of a is assigned to n; n is replaced in the position of a, and the new code obtained is the second calling code.

[0134] S208. In the second calling code, add the reference code of the package identifier and class identifier corresponding to each current adapter class to obtain the target calling code of the target component.

[0135] Specifically, the second calling code is identified, and the package identifier and class identifier to be added corresponding to the second calling code are obtained. The reference code of the package identifier and class identifier corresponding to each current adapter class can be generated through a large language model, and the reference code is added to the second calling code to obtain the target calling code of the target component.

[0136] In an example, the second calling code is identified, and the package identifier org and class identifier hutool to be added corresponding to the second calling code are obtained. The reference code of the package identifier and class identifier corresponding to each current adapter class can be generated through a large language model. For example, the reference code is import org. hutool. The reference code is added to the second calling code to obtain the target calling code of the target component.

[0137] S209: Obtain the target component to be upgraded of the target application and the target version number of the target component.

[0138] S210: Generate an update dependency configuration of the target component according to the target component and the target version number, and update a node corresponding to the target component in a project file of the target application.

[0139] S211. Generate an update calling code for the target component according to the target component and the target version number.

[0140] S212. Obtain update information of at least one update-dependent class according to the update calling code of the target component.

[0141] S213: Compare the update information of each update-dependent class with the corresponding adapter class of the target component to obtain a class comparison result of each update-dependent class.

[0142] S214: Detect whether to update the corresponding adapter class of the target component according to the class comparison result of each update dependent class.

[0143] S215: Detect the difference between the update calling code and the target calling code of the target component, and determine the difference type.

[0144] S216. Detect whether to update the target calling code of the target component according to the difference and the difference type.

[0145] The technical solution of the embodiment of the present invention obtains the target component that needs to be automatically upgraded and the current version number, generates the current dependency configuration of the target component according to the target component and the current version number, and updates the node corresponding to the target component in the project file of the target application, generates the first calling code of the target component according to the target component and the target version number, obtains the current information of at least one current dependent class according to the first calling code of the target component, and creates an adapter class corresponding to each current dependent class in the project file according to the current information of each dependent class. The adapter class corresponding to the current dependent class inherits the current dependent class and can upgrade the original class. Not only can the functions of the original class be used, but new functions can also be added, thereby improving the diversity of functions. The class code can be reused, saving storage resources. A correspondence between the project file and the current information of each current dependent class is established in the project file, the current method parameters are extracted in the first calling code, and the first calling code is adjusted according to the current method parameters to obtain the second calling code, and in the second calling code, the reference code of the package identifier and class identifier corresponding to each current adapter class is added to obtain the target calling code of the target component. By adding the reference code of the package identifier and class identifier, a mapping relationship between the package identifier, the class identifier and the target component can be established, thereby avoiding errors in component upgrade content and improving the accuracy of component upgrade.

[0146] Optionally, after obtaining the target calling code of the target component, it also includes: inputting the same input into the first calling code and the target calling code respectively to obtain the output of the first calling code and the output of the target calling code; when the output of the first calling code and the output of the target calling code are consistent, determining that the target calling code is correct.

[0147] Specifically, the same input is input into the first calling code and the target calling code respectively to obtain the output of the first calling code and the output of the target calling code. When the output of the first calling code is consistent with the output of the target calling code, it is determined that the calculation result of the first calling code is the same as the target calling code, and the target calling code is determined to be correct.

[0148] In one example, a=1, b=2 are input into the first calling code and the target calling code, and the output of the first calling code is 3, and the output of the target calling code is 3. The output of the first calling code is consistent with the output of the target calling code, and it is determined that the target calling code is correct.

[0149] By inputting the same input into the first calling code and the target calling code respectively, the output of the first calling code and the output of the target calling code are obtained. When the output of the first calling code and the output of the target calling code are consistent, it is determined that the target calling code is correct, which is convenient for testing whether the functions of the first calling code and the target calling code are the same, and the accuracy of the target calling code can be detected, thereby improving the accuracy of component upgrades.

[0150] Embodiment 3

[0151] Figure 4 This is a schematic diagram of a component version upgrade device provided in Embodiment 3 of the present invention. The embodiment of the present invention is applicable to the case of component version upgrade, the device can execute the component version upgrade method, the device can be implemented in the form of hardware and / or software, and the device can be configured in a component version upgrade device.

[0152] See also Figure 4 The component version upgrade device shown includes: a component information acquisition module 401, a node update module 402, a code generation module 403, an update information acquisition module 404, a comparison result acquisition module 405, an adapter detection module 406, a type determination module 407 and an update detection module 408.

[0153] The component information acquisition module 401 is used to acquire the target component to be upgraded of the target application and the target version number of the target component;

[0154] The node update module 402 is used to generate an update dependency configuration of the target component according to the target component and the target version number, and update the node corresponding to the target component in the project file of the target application;

[0155] The code generation module 403 is used to generate the update calling code of the target component according to the target component and the target version number;

[0156] An update information acquisition module 404, configured to acquire update information of at least one update dependent class according to an update calling code of a target component;

[0157] A comparison result acquisition module 405 is used to compare the update information of each update dependency class with the corresponding adapter class of the target component to obtain a class comparison result of each update dependency class;

[0158] The adapter detection module 406 is used to detect whether to update the corresponding adapter class of the target component according to the class comparison result of each update dependent class;

[0159] A type determination module 407, used to detect the difference between the update call code and the target call code of the target component, and determine the type of the difference;

[0160] The update detection module 408 is used to detect whether to update the target calling code of the target component according to the difference and the difference type.

[0161] The technical solution of the embodiment of the present invention obtains the target component to be upgraded of the target application and the target version number of the target component, generates the update dependency configuration of the target component, generates the update calling code of the target component according to the target component and the target version number, obtains the update information of at least one update dependency class, compares the update information of each update dependency class with the corresponding adapter class of the target component, obtains the class comparison result of each update dependency class, detects whether to update the corresponding adapter class of the target component, implements fine-grained class update, refines the operation of component version upgrade, improves the accuracy of component version upgrade, detects the difference between the update calling code and the target calling code of the target component through multi-dimensional data, determines the difference type, detects whether to update the target calling code of the target component, can judge whether to update according to different difference types, and implements the corresponding update operation, can implement differentiated update, and reduces manual operation in the update, reduces the labor cost of the update, and improves the efficiency of the component version upgrade.

[0162] Optionally, the adapter detection module 406 is specifically configured to:

[0163] The update information includes: class name, method name and parameter name; the class comparison result includes class identification comparison result, method identification comparison result and parameter identification comparison result; according to the class comparison result of each update dependent class, the number of identification changes of each update dependent class is detected;

[0164] Determine the change type of each update dependency class according to the number of changes in the identification of each update dependency class;

[0165] For each update dependency class, when the change type of the update dependency class is a minor change, according to the update calling code of the update dependency class, adjust the parameters in the adapter class corresponding to the update dependency class;

[0166] For each update dependency class, when the change type of the update dependency class is a medium change, a new adapter class is generated according to the update call code of the update dependency class, and the adapter class corresponding to the update dependency class is replaced;

[0167] For each update dependency class, when the change type of the update dependency class is a major change, a decompiled code of the target component is generated, and the compiled code is repaired according to the current version vulnerability of the update dependency class.

[0168] Optionally, the update detection module 408 is specifically used to:

[0169] When the difference type is method deletion, extract the update method parameters in the update call code;

[0170] Classify the parameters passed by each update method to obtain the parameter type of each update method;

[0171] In the update calling code, create corresponding variables for the update method whose parameter type is non-calling variables, and assign the parameter value of the update method of non-calling variables to the corresponding variables;

[0172] Replace and insert the corresponding variable into the position where the update method of the non-calling variable passes the parameter;

[0173] In the update calling code, add the reference code of the package identifier and class identifier corresponding to each adapter class to obtain the new code, and replace the target calling code of the target component.

[0174] Optionally, the update detection module 408 includes:

[0175] A code calling unit, for generating an alternative code for a target calling code of a calling target component according to at least one newly added parameter in the difference when the difference type is a method addition;

[0176] A parameter assignment unit, used to assign each newly added parameter to null in the alternative code;

[0177] An output data acquisition unit, used to obtain the output of the candidate code and the output of the target calling code by using the same input respectively;

[0178] A test result acquisition unit, used to compare the output of the candidate code with the output of the target calling code to obtain a unit test result;

[0179] A first code operation unit, configured to not update a target calling code of a target component when the unit test results are consistent;

[0180] The second code operation unit is used to detect whether each newly added parameter has a target parameter with the same intention when the unit test result is inconsistent;

[0181] A method generation unit, used for generating, in the target calling code, an update method parameter transmission corresponding to each newly added parameter according to the parameter type of each newly added parameter when there is no target parameter with the same intention;

[0182] A data insertion unit is used to establish a corresponding variable for the update method parameter of the non-calling variable in the target calling code, assign the parameter value of the update method parameter of the non-calling variable to the corresponding variable, and replace and insert the corresponding variable at the position of the update method parameter of the non-calling variable;

[0183] The code replacement unit is used to replace the newly added parameters with the variables of the target parameters in the update calling code when there are target parameters with the same intention, and replace the target calling code.

[0184] Optionally, the second code operation unit is specifically used to:

[0185] In the project code, check whether there is a target parameter with the same parameter type as each newly added parameter; and / or

[0186] Obtain the upgrade data package of the target component and the current data package of the target component;

[0187] Check the upgrade data package and current data package of the target component, and check whether each newly added parameter has the target parameter of the same call chain.

[0188] Optionally, the component version upgrading device further includes:

[0189] A target information acquisition module is used to acquire a target component to be automatically upgraded and a current version number before acquiring a target component to be upgraded of a target application and a target version number of the target component;

[0190] A node update module is used to generate the current dependency configuration of the target component according to the target component and the current version number, and update the node corresponding to the target component in the project file of the target application;

[0191] A calling code generation module, used to generate a first calling code of a target component according to the target component and the current version number;

[0192] A current information acquisition module, used to acquire current information of at least one current dependent class according to a first calling code of a target component;

[0193] The class creation module is used to create the adapter class corresponding to each current dependent class in the project file according to the current information of each dependent class. The adapter class corresponding to the current dependent class inherits the current dependent class.

[0194] A relationship building module is used to establish a corresponding relationship between the project file and the current information of each current dependent class in the project file;

[0195] A code adjustment module is used to extract the current method parameters in the first calling code, and adjust the first calling code according to the current method parameters to obtain a second calling code;

[0196] The identification adding module is used to add the reference code of the package identification and class identification corresponding to each current adapter class in the second calling code to obtain the target calling code of the target component.

[0197] Optionally, the component version upgrading device further includes:

[0198] An output information acquisition module is used to input the same input into the first calling code and the target calling code respectively after obtaining the target calling code of the target component, so as to obtain the output of the first calling code and the output of the target calling code;

[0199] The code determination module is used to determine that the target calling code is correct when the output of the first calling code is consistent with the output of the target calling code.

[0200] In the technical solution of the embodiment of the present invention, the acquisition, storage and application of the target components involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0201] Embodiment 4

[0202] Figure 5 A schematic diagram of a component version upgrade device 500 that can be used to implement an embodiment of the present invention is shown. The component version upgrade device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0203] like Figure 5 As shown, the component version upgrade device 500 includes at least one processor 501, and a memory connected to the at least one processor 501, such as a read-only memory (ROM) 502, a random access memory (RAM) 503, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 501 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 502 or the computer program loaded from the storage unit 508 to the random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the component version upgrade device 500 can also be stored. The processor 501, the ROM 502, and the RAM 503 are connected to each other through a bus 504. The input / output (I / O) interface 505 is also connected to the bus 504.

[0204] Multiple components in the component version upgrade device 500 are connected to the I / O interface 505, including: an input unit 506, such as a keyboard, a mouse, etc.; an output unit 507, such as various types of displays, speakers, etc.; a storage unit 508, such as a disk, an optical disk, etc.; and a communication unit 509, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 509 allows the component version upgrade device 500 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0205] The processor 501 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 501 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 501 executes the various methods and processes described above, such as a component version upgrade method.

[0206] In some embodiments, the component version upgrade method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 508. In some embodiments, part or all of the computer program may be loaded and / or installed on the component version upgrade device 500 via the ROM 502 and / or the communication unit 509. When the computer program is loaded into the RAM 503 and executed by the processor 501, one or more steps of the component version upgrade method described above may be performed. Alternatively, in other embodiments, the processor 501 may be configured to execute the component version upgrade method in any other appropriate manner (e.g., by means of firmware).

[0207] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0208] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0209] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0210] To provide interaction with a user, the systems and techniques described herein may be implemented on a component version upgrade device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which a user can provide input to the component version upgrade device. Other types of devices may also be used to provide interaction with a user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0211] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0212] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS (Virtual Private Server) services.

[0213] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0214] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A component version upgrade method, characterized in that: The method comprises: Obtaining a target component to be upgraded of a target application and a target version number of the target component; Generate an update dependency configuration of the target component according to the target component and the target version number, and update a node corresponding to the target component in the project file of the target application; Generate an update calling code for the target component according to the target component and the target version number; Acquire update information of at least one update-dependent class according to the update calling code of the target component; Compare the update information of each update-dependent class with the corresponding adapter class of the target component to obtain a class comparison result of each update-dependent class; According to the class comparison result of each update dependent class, detecting whether to update the corresponding adapter class of the target component; Detecting a difference between the update calling code and the target calling code of the target component, and determining a difference type; According to the difference and the difference type, detecting whether to update the target calling code of the target component; The update information includes: class name, method name and parameter name; the class comparison result includes class identification comparison result, method identification comparison result and parameter identification comparison result; The step of detecting whether to update the corresponding adapter class of the target component according to the class comparison result of each update dependent class includes: According to the class comparison result of each update-dependent class, detecting the number of changes in the identification of each update-dependent class; Determining the change type of each update dependency class according to the number of changes in the identification of each update dependency class; For each of the update dependency classes, when the change type of the update dependency class is a minor change, adjusting the parameters in the adapter class corresponding to the update dependency class according to the update calling code of the update dependency class; For each of the update dependency classes, when the change type of the update dependency class is a medium change, a new adapter class is generated according to the update calling code of the update dependency class, and the adapter class corresponding to the update dependency class is replaced; For each of the update dependency classes, when the change type of the update dependency class is a major change, a decompiled code of the target component is generated, and the compiled code is repaired according to a current version vulnerability of the update dependency class.

2. The method according to claim 1, characterized in that The detecting whether to update the target calling code of the target component according to the difference and the difference type includes: When the difference type is method deletion, extracting update method parameters in the update calling code; Classifying the parameters passed by each of the update methods to obtain the parameter type of each of the update methods; In the update calling code, a corresponding variable is established for the update method parameter passing whose parameter type is a non-calling variable, and the parameter value of the update method parameter passing of the non-calling variable is assigned to the corresponding variable; The corresponding variable is replaced and inserted into the position where the update method of the non-calling variable passes the parameter; In the update calling code, reference information of the package identifier and class identifier corresponding to each adapter class is added to obtain a new code, and the target calling code of the target component is replaced.

3. The method according to claim 1, characterized in that The detecting whether to update the target calling code of the target component according to the difference and the difference type includes: When the difference type is method addition, generating an alternative code for a target calling code for calling the target component according to at least one newly added parameter in the difference; In the alternative code, each of the newly added parameters is assigned a value of null; Using the same input to the candidate code and the target calling code respectively, to obtain the output of the candidate code and the output of the target calling code; Compare the output of the candidate code with the output of the target calling code to obtain a unit test result; When the unit test results are consistent, the target calling code of the target component is not updated; When the unit test results are inconsistent, detecting whether each of the newly added parameters has a target parameter with the same intention; When the newly added parameter does not have a target parameter with the same intention, in the target calling code, an update method parameter corresponding to the newly added parameter is generated according to the parameter type of the newly added parameter; In the target calling code, a corresponding variable is established for the update method parameter passing of the non-calling variable whose parameter type is a non-calling variable, and the parameter value of the update method parameter passing of the non-calling variable is assigned to the corresponding variable, and the corresponding variable is replaced and inserted into the position of the update method parameter passing of the non-calling variable; When the newly added parameter has a target parameter with the same intention, the newly added parameter is replaced by a variable of the target parameter in the update calling code, and the target calling code is replaced.

4. The method according to claim 3, characterized in that Detecting whether each of the newly added parameters has a target parameter with the same intent includes: In the project code, query whether there is a target parameter of the same parameter type as each of the newly added parameters; and / or Acquire an upgrade data packet of the target component and a current data packet of the target component; The upgraded data packet of the target component and the current data packet are detected, and whether each of the newly added parameters has a target parameter of the same call chain.

5. The method according to claim 1, characterized in that Before obtaining the target component to be upgraded of the target application and the target version number of the target component, the method further includes: Obtain the target component that needs to be automatically upgraded and the current version number; Generate a current dependency configuration of the target component according to the target component and the current version number, and update a node corresponding to the target component in a project file of the target application; Generate a first calling code of the target component according to the target component and the current version number; According to the first calling code of the target component, obtaining current information of at least one current dependent class; According to the current information of each dependent class, an adapter class corresponding to each current dependent class is created in the project file, and the adapter class corresponding to the current dependent class inherits the current dependent class; Establishing a correspondence between the project file and the current information of each of the current dependent classes in the project file; Extracting the current method parameter from the first calling code, and adjusting the first calling code according to the current method parameter to obtain a second calling code; In the second calling code, reference codes of the package identifier and class identifier corresponding to each current adapter class are added to obtain the target calling code of the target component.

6. The method according to claim 5, characterized in that After obtaining the target calling code of the target component, it also includes: Input the same input into the first calling code and the target calling code respectively, to obtain the output of the first calling code and the output of the target calling code; When the output of the first calling code is consistent with the output of the target calling code, it is determined that the target calling code is correct.

7. A component version upgrade device, characterized in that: The device comprises: A component information acquisition module, used to acquire a target component to be upgraded of a target application and a target version number of the target component; A node update module, used to generate an update dependency configuration of the target component according to the target component and the target version number, and update a node corresponding to the target component in a project file of the target application; A code generation module, used to generate an update calling code of the target component according to the target component and the target version number; An update information acquisition module, used to acquire update information of at least one update dependency class according to the update calling code of the target component; A comparison result acquisition module, used for comparing the update information of each update-dependent class with the corresponding adapter class of the target component to obtain a class comparison result of each update-dependent class; An adapter detection module, used to detect whether to update the corresponding adapter class of the target component according to the class comparison result of each update dependent class; A type determination module, used to detect the difference between the update calling code and the target calling code of the target component, and determine the type of the difference; An update detection module, used for detecting whether to update the target calling code of the target component according to the difference and the difference type; The adapter detection module is specifically used for: The update information includes: class name, method name and parameter name; the class comparison result includes class identification comparison result, method identification comparison result and parameter identification comparison result; according to the class comparison result of each update dependent class, the number of identification changes of each update dependent class is detected; Determine the change type of each update dependency class according to the number of changes in the identification of each update dependency class; For each update dependency class, when the change type of the update dependency class is a minor change, according to the update calling code of the update dependency class, adjust the parameters in the adapter class corresponding to the update dependency class; For each update dependency class, when the change type of the update dependency class is a medium change, a new adapter class is generated according to the update call code of the update dependency class, and the adapter class corresponding to the update dependency class is replaced; For each update dependency class, when the change type of the update dependency class is a major change, a decompiled code of the target component is generated, and the compiled code is repaired according to the current version vulnerability of the update dependency class.

8. A component version upgrade device, characterized in that: The component version upgrade device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the component version upgrade method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the component version upgrade method according to any one of claims 1 to 6 when executed.