Dynamic updating method, device and equipment for java program, medium and product

By using the class knowledge graph and class loader decision tree in Java applications to find and load the latest version of the target class file, the problem of restarting when Java application is updated is solved, and the requirements of dynamic updates and grayscale releases are realized.

CN120215996AActive Publication Date: 2025-06-27HANGZHOU NEWGRAND TECHNOLOGY CO LTD
View PDF 14 Cites 0 Cited by

Patent Information

Application Number
CN202510695412.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-28
Publication Date
2025-06-27
Estimated Expiration
2045-05-28

AI Technical Summary

Technical Problem

When Java application updates, the existing technology requires restarting the program, which cannot meet the business needs in scenarios such as grayscale release and dynamic update.

Method used

By obtaining the class loader information associated with the latest version of the target class file in the class knowledge graph, if it does not exist, the associated class loader is found in the class loader decision tree, and the target class file is loaded through the class loader.

Benefits of technology

It realizes dynamic update of Java programs, avoids the restart process, and meets the needs of scenarios such as grayscale release and dynamic update.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120215996A_ABST
    Figure CN120215996A_ABST
Patent Text Reader

Abstract

The invention discloses a java program dynamic updating method and device, equipment, a medium and a product. The java program dynamic updating method comprises the steps that in response to the fact that a target class file is called, information of a class loader associated with the latest version of the target class file is obtained in a class knowledge graph; the class knowledge graph comprises class files and class knowledge information associated with the class files, and the class knowledge information comprises paths where the class files are located and information of class loaders associated with the paths; under the condition that the information of the class loader associated with the latest version of the target class file does not exist in the class knowledge graph, searching the class loader associated with the target class file in the class loader decision tree to serve as a target class loader; the class loader decision tree is constructed based on the execution sequence of the user-defined class loaders and the default loading system of the current application program; and loading the target class file through the target class loader. According to the technical scheme, the dynamic updating requirement of the application program can be met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and particularly to a method, device, equipment, medium and product for dynamically updating a Java program. Background Art

[0002] During the running of a Java application, it is often necessary to call the class objects of a Java program. This requires loading the class files associated with the class objects into the virtual machine in advance when the program starts.

[0003] In some cases, it is necessary to update the running program. After the update, the current running program needs to be restarted to complete the loading of the updated class files. This program update method cannot meet the actual business requirements in scenarios such as gray release, program debugging, and dynamic update. Summary of the Invention

[0004] The present invention provides a method, device, equipment, medium and product for dynamically updating a Java program to solve the problem that the program needs to be restarted during program update and cannot meet the business requirements in scenarios such as gray release and dynamic update.

[0005] According to one aspect of the present invention, there is provided a method for dynamically updating a Java program, including:

[0006] In response to a target class file being called, obtaining information on the class loader associated with the latest version of the target class file in a class knowledge graph; the class knowledge graph includes class files and class knowledge information associated with the class files, and the class knowledge information includes the path where the class file is located and information on the class loader associated with the path;

[0007] In the case where there is no information on the class loader associated with the latest version of the target class file in the class knowledge graph, searching for the class loader associated with the target class file in a class loader decision tree as the target class loader; the class loader decision tree is constructed based on the execution order of custom class loaders and the default loading system of the current application program;

[0008] Loading the target class file through the target class loader.

[0009] According to another aspect of the present invention, there is provided a device for dynamically updating a Java program, including:

[0010] A knowledge graph query module for, in response to a target class file being called, obtaining information on the class loader associated with the latest version of the target class file in a class knowledge graph; the class knowledge graph includes class files and class knowledge information associated with the class files, and the class knowledge information includes the path where the class file is located and information on the class loader associated with the path;

[0011] A class loader determination module is used to find the class loader associated with the target class file as the target class loader in the class loader decision tree when there is no information about the class loader associated with the latest version of the target class file in the class knowledge graph; the class loader decision tree is constructed based on the execution order of custom class loaders and the default loading system of the current application;

[0012] A class file loading module is used to load the target class file through the target class loader.

[0013] According to another aspect of the present invention, an electronic device is provided, and the electronic device includes:

[0014] At least one processor; and

[0015] A memory communicatively connected to the at least one processor; wherein,

[0016] 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 java program dynamic update method according to any embodiment of the present invention.

[0017] According to another aspect of the present invention, a computer-readable storage medium is provided, and the computer-readable storage medium stores computer instructions for causing a processor to implement the java program dynamic update method according to any embodiment of the present invention when executed.

[0018] According to another aspect of the present invention, a computer program product is provided, including a computer program that implements the java program dynamic update method according to any embodiment of the present disclosure when executed by a processor.

[0019] The technical solution of the embodiment of the present invention, in response to the target class file being called, obtains the information of the class loader associated with the latest version of the target class file in the class knowledge graph. When there is no information about the class loader associated with the latest version of the target class file in the class knowledge graph, finds the class loader associated with the target class file as the target class loader in the class loader decision tree, and finally loads the target class file through the target class loader. When the target class file is updated, routes from the class loader decision tree to find the class loader associated with the target class file, realizing the dynamic update of the application program.

[0020] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present invention, nor is it used to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. Description of the Drawings

[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.

[0022] Figure 1 is a flowchart of a method for dynamically updating a Java program according to Embodiment 1 of the present invention;

[0023] Figure 2a is a flowchart of a method for dynamically updating a Java program according to Embodiment 2 of the present invention;

[0024] Figure 2b is a schematic structural diagram of a class loader decision tree according to Embodiment 2 of the present invention;

[0025] Figure 3 is a schematic structural diagram of a device for dynamically updating a Java program according to Embodiment 3 of the present invention;

[0026] Figure 4 is a schematic structural diagram of an electronic device for implementing the method for dynamically updating a Java program in the embodiments of the present invention. Specific Embodiments

[0027] In order to enable those skilled in the art to better understand the solutions of the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some of the embodiments of the present invention, rather than all of them. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0028] 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 do not necessarily need to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances 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 "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.

[0029] Embodiment 1

[0030] Figure 1 The flowchart of a method for dynamically updating a Java program provided in Embodiment 1 of the present invention is applicable to the situation where a class file in a Java application program is updated and the updated class file is dynamically loaded through a class knowledge graph and a class loader decision tree. This method can be executed by a Java program dynamic update device, which can be implemented in the form of hardware and / or software and can be configured in various general computing devices. As Figure 1 shown, the method includes:

[0031] S110. In response to the target class file being called, obtain information about the class loader associated with the latest version of the target class file in the class knowledge graph; the class knowledge graph includes class files and class knowledge information associated with the class files, and the class knowledge information includes the path where the class file is located and the information about the class loader associated with the path.

[0032] A class knowledge graph is a language network that describes the relationship between class resources and class knowledge information associated with class resources in a structured form. Among them, class resources can be class files or jar packages in a Java program, and a jar package contains at least one class file. Class knowledge information includes the file size, location path, creation time of class resources, and information about the class loader associated with the location path, etc.

[0033] Exemplarily, the class knowledge graph includes class files, as well as information about the file size, location path, and class loader associated with the location path associated with the class files. The class knowledge graph can also include jar packages, as well as information about the file package size, location path, and class loader associated with the location path associated with the jar packages.

[0034] To ensure the accuracy of the class knowledge graph, a monitoring mechanism (watch mechanism) can be set for class resources. When it is detected that a class resource is updated, the class knowledge graph is updated accordingly, and the updated class knowledge information and version are stored correspondingly. The granularity of the monitoring mechanism can be set according to requirements. For example, it can be set to the class file granularity or the jar package granularity.

[0035] In the embodiments of the present invention, during the running of a program, when a target class file is called, first, class knowledge information associated with the called target class file is queried in the class knowledge graph. Information about the class loader associated with the latest version of the target class file is queried in the class knowledge information. If the information about the class loader associated with the latest version of the target class file is found, it indicates that the latest version of the target class file has been loaded, and no update has occurred between the current call and the previous call of the target class file. If the information about the class loader associated with the latest version of the target class file is not found in the class knowledge graph, it indicates that the latest version of the target class file has not been loaded, and an update has occurred between the current call and the previous call of the target class file.

[0036] Optionally, in the embodiments of the present invention, it further includes:

[0037] Based on the class loading path in the Java configuration file, determine the path, file size, and creation time of each class resource;

[0038] Build a class knowledge graph based on the path, file size, and creation time of the class resource;

[0039] The class knowledge graph includes class knowledge information associated with class resources in the application program, and the class knowledge information includes the size, path, and creation time of the class resource.

[0040] In this optional embodiment, before the program runs, the developer creates a Java configuration file in the current program working directory, configures the class loading path and the execution order of the custom class loader in the configuration file. If the configuration file is not configured, the parameter default settings are made through the class path of the main class by default, and at the same time, according to the class loading path, search upward to determine the jar class library path of the application program.

[0041] Build a resource scheduler in the application program, and when the main class of the program runs, set the current class loader as the resource scheduler to load class resources.

[0042] During the initialization process of the application program, based on the class loading path in the Java configuration file, determine the path, file size, and creation time of each class resource, and then build a class knowledge graph based on the path, file size, and creation time of the class resource. Among them, the class knowledge graph includes class knowledge information associated with class resources in the application program, and the class knowledge information includes the size, path, and creation time of the class resource.

[0043] Optionally, the embodiments of the present invention further include:

[0044] Add a listening mechanism to the class resources in the application. When it is detected that the class resources are updated, update the class knowledge information of the class resources in the class knowledge graph and record the updated version of the class resources.

[0045] The class resources are class files or jar packages; the class knowledge information includes the file size, update time, location path of the class resources, and the information of the class loader associated with the location path.

[0046] In this optional embodiment, in order to ensure the accuracy of the class knowledge information in the class knowledge graph and realize the dynamic update of the application, a listening mechanism is added to the class resources in the application. When it is detected that the class resources are updated, the class knowledge information of the class resources in the class knowledge graph is updated, and the updated version of the class resources is recorded. Specifically, when the class resources are deleted, the deleted class resources can be pruned in the class knowledge graph; when the class resources are modified, the class knowledge information associated with the modified class resources can be updated in the class knowledge graph. The class resource version is incremented by 1 after each update.

[0047] Among them, the class resources are class files or jar packages; the class knowledge information includes the file size, update time, location path of the class resources, and the information of the class loader associated with the location path. The granularity of the listening mechanism can be set according to actual needs. For example, it can be set to the class file granularity or the jar package granularity.

[0048] It should be noted that the information of the class loader associated with the location path is stored in the class knowledge graph when the class resources are initially loaded. By adding a listening mechanism to the class resources, the version of the class knowledge graph can be updated in a timely manner when the class resources are updated, serving as the data basis for the dynamic update of the application.

[0049] S120. In the case where there is no information of the class loader associated with the latest version of the target class file in the class knowledge graph, search for the class loader associated with the target class file in the class loader decision tree as the target class loader; the class loader decision tree is constructed based on the execution order of the custom class loaders and the default loading system of the current application.

[0050] The class loader decision tree is a tree structure constructed based on the execution order of the custom class loaders and the default loading system of the current application, used to describe the priority and delegation logic of class loading. Among them, the execution order of the custom class loaders is written by the developer in the java configuration file in advance, including at least one custom class loader and the execution order of the custom class loaders. The default loading system of the current application is the default loading system that matches the program type of the current application.

[0051] In an embodiment of the present invention, when there is no information about the class loader associated with the latest version of the target class file in the class knowledge graph, it indicates that the latest version of the target class file has been updated and has not been loaded after the update. At this time, the class loader associated with the target class file can be found in the class loader decision tree as the target class loader. Specifically, routing can be performed from the leaf nodes in the class loader decision tree, and version instances of each class loader can be created during the routing process until the class loader associated with the target class file is found as the target loader. Among them, the class loader associated with the target class file is the class loader associated with the path where the target class file is located, and is used to load the class files under the path where the target class file is located.

[0052] In addition, the information for determining the target class loader can be supplemented to the class knowledge graph, so that when the target class file is called subsequently, the information about the class loader associated with the latest version of the target class file can be directly found from the class knowledge graph, realizing fast loading and calling of class files.

[0053] S130. Load the target class file through the target class loader.

[0054] In an embodiment of the present invention, after determining the target class loader, the target class loader is set as the resource scheduler to load the target class file and complete the call of the target class file.

[0055] The technical solution of the embodiment of the present invention, in response to the call of the target class file, obtains the information about the class loader associated with the latest version of the target class file in the class knowledge graph. When there is no information about the class loader associated with the latest version of the target class file in the class knowledge graph, the class loader associated with the target class file is found in the class loader decision tree as the target class loader, and finally the target class file is loaded through the target class loader. When the target class file is updated, routing is performed in the class loader decision tree to find the class loader associated with the target class file, realizing dynamic update of the application program.

[0056] Embodiment 2

[0057] Figure 2a It is a flowchart of a method for dynamically updating a Java program provided by Embodiment 2 of the present invention. This embodiment is further refined on the basis of the above embodiment, providing the specific steps for finding the class loader associated with the target class file as the target class loader in the class loader decision tree, and the specific steps before obtaining the information about the class loader associated with the latest version of the target class file in the class knowledge graph. As Figure 2a shown, the method includes:

[0058] S210. Obtain the execution order of the custom class loader in the Java configuration file.

[0059] A Java configuration file is a configuration file created by a developer in the working directory of the current program before the program runs. It includes the class loading path and the execution order of custom class loaders. If the configuration file is not configured, the parameter default settings are made through the class path of the main class by default, and at the same time, according to the class loading path, search upward to determine the jar class library path of the application program.

[0060] In the embodiment of the present invention, in the resource routing management during the initialization of the application program, first obtain the execution order of the custom class loader in the Java configuration file, including custom class loader A, custom class loader B, and the execution order of the custom class loader.

[0061] S220. Determine the default class loading system associated with the program type according to the program type of the current application program.

[0062] The types of application programs can include stand-alone programs and web programs, etc. Different types of application programs correspond to different default class loading systems.

[0063] In the embodiment of the present invention, it is necessary to determine the default class loading system associated with the program type according to the program type of the current application program. For example, in the default class loading system of a web program, the class loaders can be arranged in the execution order as follows: application class loader AppClassLoader, extension class loader ExtClassLoder, and bootstrap class loader BootstrapClassLoder.

[0064] S230. Construct a class loader decision tree according to the execution order of the custom class loader and the default loading system.

[0065] In the embodiment of the present invention, a class loader decision tree is constructed according to the execution order of the custom class loader and the default loading system. Specifically, as Figure 2b shown, a class loader decision tree is constructed according to the execution order of the custom class loader and the default loading system. Among them, the execution order of the custom class loader precedes the class loaders in the default loading system. By establishing a class loader decision tree, when loading class files subsequently, the class files can be loaded in the order in the decision tree, improving the efficiency of class file loading.

[0066] Optionally, the embodiment of the present invention further includes:

[0067] Add a monitoring mechanism to the class resources in the application program. When it is detected that the class resources are updated, update the class knowledge information of the class resources in the class knowledge graph and record the updated version of the class resources;

[0068] A class resource is a class file or a JAR package; class knowledge information includes the file size, update time, location path of the class resource, and information about the class loader associated with the location path.

[0069] S240. In response to the target class file being called, obtain information about the class loader associated with the latest version of the target class file in the class knowledge graph; the class knowledge graph includes class files and class knowledge information associated with the class files, and the class knowledge information includes the location path of the class file and information about the class loader associated with the path.

[0070] S250. In the case where there is no information about the class loader associated with the latest version of the target class file in the class knowledge graph, route starting from the leaf node of the class loader decision tree, and query the class loader associated with the target class file as the target class loader; the class loader decision tree is constructed based on the execution order of custom class loaders and the default loading system of the current application.

[0071] In an embodiment of the present invention, in the case where there is no information about the class loader associated with the latest version of the target class file in the class knowledge graph, it is necessary to route starting from the leaf node of the class loader decision tree, and query the class loader associated with the target class file as the target class loader. Each class loader in the class loader decision tree corresponds to one or more class loading paths.

[0072] S260. Associatively store the information of the target class loader and the location path of the target class file in the class knowledge graph as the class knowledge information of the latest version of the target class file.

[0073] In an embodiment of the present invention, after determining the target class loader in the class loader decision tree, further associatively store the information of the target class loader and the location path of the target class file in the class knowledge graph as the class knowledge information of the latest version of the target class file. When the target class file is called subsequently, the corresponding class loader can be directly obtained from the class knowledge graph for class resource scheduling.

[0074] Optionally, an embodiment of the present invention further includes:

[0075] In the case where the target class file is not included in the class knowledge graph, obtain the call point of the target class file, and search in the class knowledge graph for the target version of the class loader of the class file associated with the call point;

[0076] In the class loader decision tree, obtain candidate class loaders that are the same as and less than the target version, and determine the target class loader among the candidate class loaders.

[0077] In this optional embodiment, when looking up the knowledge information of the target class file called in the class knowledge graph, it is also possible that the target file is not included in the class knowledge graph. This situation may occur when the target class file has been deleted in the latest program changes. At this time, it is necessary to obtain the call point of the target class file and look up the target version of the class loader of the class file associated with the call point in the class knowledge graph. Further, in the class loader decision tree, obtain candidate class loaders that are the same as and less than the target version, and determine the target class loader among the candidate class loaders.

[0078] In a specific example, when class file A with version number 4 calls class file B with version number 5, it is necessary to look up the class knowledge information associated with class file B with version number 5 in the class knowledge graph. At this time, if class file B does not appear in the class knowledge graph, it indicates that class file B was deleted during the 5th update, and the class knowledge graph will be pruned to delete class file B and its associated class knowledge information. At this time, it is necessary to obtain the reference path for loading class file B in the application program and determine the call point based on the reference path. At this time, class file A that calls class file B can be used as the call point. Further, look up the knowledge information of class file A with version number 4 in the class knowledge graph, obtain the information of the class loader associated with class file A with version number 4 in the knowledge information, and use the version of the obtained class loader as the target version, that is, the target version is 4 at this time. Finally, in the class loader decision tree, obtain candidate class loaders that are the same as and less than the target version, and determine the class loader associated with class file B among the candidate class loaders as the target class loader.

[0079] Optionally, it further includes:

[0080] In the case where there is no information about the class loader associated with the latest version of the target class file in the class knowledge graph, look up the progressive release policy in the preset java configuration file;

[0081] If the java configuration file contains a progressive release policy, probe the class knowledge graph at a set time interval;

[0082] In the case where the file size and update time of the target class file are the same as those of the historical version of the target class file, unload the class knowledge information associated with the latest version of the target class file in the class knowledge graph, and unload the information of the class loader associated with the latest version of the target class file in the class loader decision tree.

[0083] In this optional embodiment, in the case where there is no information about the class loader associated with the latest version of the target class file in the class knowledge graph, it is also necessary to search for the progressive release strategy in the preset Java configuration file. If the Java configuration file contains a progressive release strategy, such as blue-green release or canary release, etc., it indicates that the new version of the application is in the progressive release stage at this time, and version rollback may occur. At this time, it is necessary to detect the class knowledge graph at a set time period. When the file size and update time of the target class file are the same as those of the historical version of the target class file, it is considered that version rollback has occurred. At this time, in the class knowledge graph, the class knowledge information associated with the latest version of the target class file is unloaded, and in the class loader decision tree, the information about the class loader associated with the latest version of the target class file is unloaded, so that when the subsequent application runs, the class file is called according to the previous version that has been rolled back. By continuously scanning the class knowledge graph during the progressive release process, when version rollback occurs, the knowledge information of class resources in the class knowledge graph can be changed in a timely manner, and the information in the class loader decision tree can be unloaded, which can ensure dynamic update while meeting the requirements of version rollback in the progressive release process.

[0084] Optionally, in the case where the progressive release strategy in the Java configuration file is canary release, it further includes:

[0085] Record the loading quantities of the class loaders associated with the latest version of the target class file and the previous version of the latest version.

[0086] When the ratio of the loading quantities of the class loaders associated with the latest version and the previous version reaches the target ratio, the canary release strategy is exited.

[0087] In this optional embodiment, if the progressive release strategy configured in the Java configuration file is canary release, it indicates that the release link at this time gradually opens the new version of the application according to a certain ratio. At this time, record the loading quantities of the class loaders associated with the latest version of the target class file, such as version 5, and the previous version of the latest version, version 4. When the ratio of the loading quantities of the class loaders associated with the latest version and the previous version reaches the target ratio. For example, 5:5, then the canary release strategy is exited, and the subsequent full new version is released. During this period, if version rollback occurs, the relevant information of the class knowledge graph and the class loader decision tree is rolled back.

[0088] When the application update exceeds the set duration and no version rollback occurs, it is regarded as a successful release, and the class loaders of the historical versions in the class loader decision tree are automatically unloaded, and the knowledge information of the class resources in the class knowledge graph is written.

[0089] In the above case, if the class file cannot be found in the class knowledge graph, it is determined as an abnormal mode. It is necessary to obtain the call path of the class file to determine the call point, and then obtain the path where the call point is located in the class knowledge graph. The path is associated with the class loader and the target class library to which the call point belongs. Further, increment the version of the class loader associated with the call point by 1, and trigger the target class library to which the call point belongs, and mount the latest version of the class loader associated with all class files under the target class library. Finally, trigger the loading of the class file in the target class library using the latest version of the mounted class loader to complete the loading of the class file, which serves as the basis for class resources during the subsequent operation of the application program.

[0090] In a specific example, class file A loads class file B, and class file B does not exist in the class knowledge graph. Then, obtain the path where class file A is located in the class knowledge graph. The path is associated with the class loader and the target class library to which class file A belongs. Further, increment the version of the class loader associated with class file A by 1 (for example, update from the initial version 4 to version 5), and trigger the target class library to which class file A belongs, and mount the latest version of the class loader (the class loader of version 5) associated with the resources under the target class library. Finally, trigger the loading of the class file in the class library using the latest version of the class loader to load the class file into memory.

[0091] S270. Load the target class file through the target class loader.

[0092] The technical solution of the embodiment of the present invention, in response to the target class file being called, obtains the information of the class loader associated with the latest version of the target class file in the class knowledge graph. In the case where the information of the class loader associated with the latest version of the target class file does not exist in the class knowledge graph, route from the leaf node of the class loader decision tree, query the class loader associated with the target class file as the target class loader, and store the information of the target class loader and the path where the target class file is located in the class knowledge graph in an associated manner as the class knowledge information of the latest version of the target class file, so as to complete the loading of the latest version of the target class file and realize the dynamic update of the application program.

[0093] Embodiment III

[0094] Figure 3 It is a schematic structural diagram of a dynamic update device for a java program provided by Embodiment III of the present invention. As Figure 3 shown, the device includes:

[0095] A knowledge graph query module 310, configured to obtain, in response to the target class file being called, the information of the class loader associated with the latest version of the target class file in the class knowledge graph; the class knowledge graph includes class files and class knowledge information associated with the class files, and the class knowledge information includes the path where the class file is located and the information of the class loader associated with the path.

[0096] The first type of class loader determination module 320 is used to find the class loader associated with the target class file as the target class loader in the class loader decision tree when there is no information about the class loader associated with the latest version of the target class file in the class knowledge graph; the class loader decision tree is constructed based on the execution order of custom class loaders and the default loading system of the current application;

[0097] The class file loading module 330 is used to load the target class file through the target class loader.

[0098] The technical solution of the embodiment of the present invention, in response to the target class file being called, obtains the information of the class loader associated with the latest version of the target class file in the class knowledge graph. When there is no information about the class loader associated with the latest version of the target class file in the class knowledge graph, finds the class loader associated with the target class file as the target class loader in the class loader decision tree, and finally loads the target class file through the target class loader. When the target class file is updated, routes from the class loader decision tree to find the class loader associated with the target class file, realizing the dynamic update of the application program.

[0099] Optionally, the first type of class loader determination module 320 is specifically used for:

[0100] Route from the leaf node of the class loader decision tree to query the class loader associated with the target class file as the target class loader;

[0101] Associate and store the information of the target class loader with the path where the target class file is located in the class knowledge graph as the class knowledge information of the latest version of the target class file.

[0102] Optionally, the java program dynamic update device further includes:

[0103] The release policy reading module is used to find the progressive release policy in the preset java configuration file when there is no information about the class loader associated with the latest version of the target class file in the class knowledge graph;

[0104] The knowledge graph detection module is used to detect the class knowledge graph at a set time period if the progressive release policy is included in the java configuration file;

[0105] A version rollback module, which is used to unload the class knowledge information associated with the latest version of the target class file in the class knowledge graph and unload the information of the class loader associated with the latest version of the target class file in the class loader decision tree when the file size and update time of the target class file are the same as those of the historical version of the target class file.

[0106] Optionally, the Java program dynamic update device further includes:

[0107] A target version determination module, which is used to obtain the call point of the target class file and find the target version of the class loader of the class file associated with the call point in the class knowledge graph when the class knowledge graph does not contain the target class file.

[0108] A second class loader determination module, which is used to obtain candidate class loaders that are the same as and less than the target version in the class loader decision tree and determine the target class loader among the candidate class loaders.

[0109] Optionally, the Java program dynamic update device further includes:

[0110] A class resource monitoring module, which is used to add a monitoring mechanism to the class resources in the application program, update the class knowledge information of the class resources in the class knowledge graph when the class resources are monitored to be updated, and record the updated class resource version.

[0111] The class resources are class files or jar packages; the class knowledge information includes the file size, update time, location path of the class resources, and the information of the class loader associated with the location path.

[0112] Optionally, the Java program dynamic update device further includes:

[0113] An execution order determination module, which is used to obtain the execution order of the custom class loader in the Java configuration file before obtaining the information of the class loader associated with the latest version of the target class file in the class knowledge graph.

[0114] A default class loading system determination module, which is used to determine the default class loading system associated with the program type according to the program type of the current application program.

[0115] A class loader decision tree construction module, which is used to construct a class loader decision tree according to the execution order of the custom class loader and the default loading system.

[0116] Optionally, the Java program dynamic update device further includes:

[0117] A loading quantity recording module, configured to record the loading quantity of the class loader associated with the previous version of the latest version and the latest version of the target class file when there is a canary release progressive release policy in the java configuration file;

[0118] A release exit module, configured to exit the canary release policy when the ratio of the loading quantity of the class loaders associated with the latest version and the previous version reaches a target ratio.

[0119] The java program dynamic update device provided by the embodiments of the present invention can execute the java program dynamic update method provided by any embodiment of the present invention, and has function modules and beneficial effects corresponding to the execution method.

[0120] In the technical solution of the present invention, the collected information is information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure, and application of relevant data, etc., all comply with the relevant laws, regulations, and standards of relevant countries and regions, take necessary confidentiality measures, do not violate public order and good customs, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0121] Embodiment 4

[0122] According to an embodiment of the present invention, the present invention further provides an electronic device, a readable storage medium, and a computer program product.

[0123] Figure 4 FIG. shows a schematic structural diagram of an electronic device 10 that can be used to implement the embodiments of the present invention. The electronic device is intended to represent various forms of digital computers, such as, laptop computers, desktop computers, workstations, personal digital assistants, applicators, blade applicators, 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 claimed herein.

[0124] Such as Figure 4As shown, the electronic device 10 includes at least one processor 11 and a memory communicatively connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc. The memory stores a computer program executable by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0125] Multiple components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disc, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0126] The processor 11 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 11 include but are not limited to a central processing unit (CPU), a graphics processing unit (GPU), various dedicated 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 11 executes the various methods and processes described above, such as the java program dynamic update method.

[0127] In some embodiments, the java program dynamic update method can be implemented as a computer program tangibly embodied in a computer-readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the java program dynamic update method described above can be executed. Alternatively, in other embodiments, the processor 11 can be configured to execute the java program dynamic update method by any other appropriate means (e.g., by means of firmware).

[0128] The various embodiments of the systems and techniques described above in this specification can be implemented in digital electronic circuitry, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on a chip (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: being implemented in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be a special-purpose or general-purpose programmable processor that receives data and instructions from, and transmits data and instructions to, a storage system, at least one input device, and at least one output device.

[0129] The computer programs for implementing the methods of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions / operations specified in the flowchart and / or block diagram to be implemented. The computer programs can be executed entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.

[0130] In the context of the present invention, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer-readable storage medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. Alternatively, the computer-readable storage medium can be a machine-readable signal medium. More specific examples of the machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

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

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

[0133] The computing system can include a client and an applicator. The client and the applicator are generally remote from each other and typically interact through a communication network. The relationship between the client and the applicator is created by computer programs running on respective computers and having a client-applicator relationship with each other. The applicator can be a cloud applicator, also known as a cloud computing applicator or a cloud host, which is a host product in the cloud computing application system and solves the defects of difficult management and weak business scalability existing in traditional physical hosts and VPS applications.

[0134] The embodiments of the present application also disclose a computer program product, which includes a computer program that, when executed by a processor, implements the java program dynamic update method provided in any embodiment of the present application. This program product and the java program dynamic update methods disclosed in the embodiments of the present application belong to the same inventive concept, and thus will not be elaborated herein.

[0135] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps recited in the present invention can be executed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved, and no limitation is imposed herein.

[0136] The above specific embodiments do not constitute a limitation on the protection scope of the present invention. Those skilled in the art should understand that various modifications, combinations, sub - combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.

Claims

1. A method for dynamically updating a Java program, characterized in that Including: In response to the target class file being called, obtaining information about the class loader associated with the latest version of the target class file in the class knowledge graph; the class knowledge graph includes class files and class knowledge information associated with the class files, and the class knowledge information includes the path where the class file is located and information about the class loader associated with the path; In the case where there is no information about the class loader associated with the latest version of the target class file in the class knowledge graph, searching for the class loader associated with the target class file in the class loader decision tree as the target class loader; the class loader decision tree is constructed based on the execution order of custom class loaders and the default loading system of the current application; Loading the target class file through the target class loader.

2. The java program dynamic update method according to claim 1, wherein The searching for the class loader associated with the target class file in the class loader decision tree as the target class loader includes: Routing from the leaf node of the class loader decision tree to query the class loader associated with the target class file as the target class loader; Associating and storing the information of the target class loader with the path where the target class file is located in the class knowledge graph as the class knowledge information of the latest version of the target class file.

3. The java program dynamic update method according to claim 2, wherein Also including: In the case where there is no information about the class loader associated with the latest version of the target class file in the class knowledge graph, searching for a progressive release policy in a preset java configuration file; If the java configuration file contains a progressive release policy, probing the class knowledge graph at a set time period; In the case where the file size and update time of the target class file are the same as those of the historical version of the target class file, unloading the class knowledge information associated with the latest version of the target class file in the class knowledge graph, and unloading the information about the class loader associated with the latest version of the target class file in the class loader decision tree.

4. The dynamic update method of the java program according to claim 1, characterized in that Also including: In the case where the target class file is not included in the class knowledge graph, obtaining the call point of the target class file and searching for the target version of the class loader of the class file associated with the call point in the class knowledge graph; In the class loader decision tree, obtaining candidate class loaders that are the same as and less than the target version, and determining the target class loader from the candidate class loaders.

5. The java program dynamic update method according to claim 1, characterized in that Also including: Adding a monitoring mechanism to the class resources in the application, and when it is detected that the class resources are updated, updating the class knowledge information of the class resources in the class knowledge graph and recording the updated version of the class resources; The class resources are class files or jar packages; the class knowledge information includes the file size, update time, path where the class resources are located, and information about the class loader associated with the path.

6. The java program dynamic update method according to claim 1, wherein Before obtaining the information about the class loader associated with the latest version of the target class file in the class knowledge graph, it also includes: Obtaining the execution order of custom class loaders in the java configuration file; Determining the default class loading system associated with the program type according to the program type of the current application; Construct a class loader decision tree according to the execution order of the custom class loader and the default loading system.

7. The dynamic update method for Java program according to claim 3, characterized in that When there is a canary release progressive publishing strategy in the Java configuration file, it further includes: Record the latest version of the target class file and the loading quantity of the class loader associated with the previous version of the latest version. When the ratio of the loading quantities of the class loaders associated with the latest version and the previous version reaches the target ratio, exit the canary release strategy.

8. A dynamic update device for a Java program, characterized in that It includes: A knowledge graph query module, configured to, in response to the target class file being called, obtain information about the class loader associated with the latest version of the target class file in the class knowledge graph; the class knowledge graph includes class files and class knowledge information associated with the class files, and the class knowledge information includes the path where the class file is located and information about the class loader associated with the path. A first class loader determination module, configured to, when there is no information about the class loader associated with the latest version of the target class file in the class knowledge graph, find the class loader associated with the target class file in the class loader decision tree as the target class loader; the class loader decision tree is constructed based on the execution order of the custom class loader and the default loading system of the current application. A class file loading module, configured to load the target class file through the target class loader.

9. An electronic device, characterized in that, The electronic 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 when the computer program is executed by the at least one processor, the at least one processor is enabled to execute the Java program dynamic update method according to any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing a processor to implement the Java program dynamic update method according to any one of claims 1-7 when executed.

11. A computer program product, characterized in that, The computer program product includes a computer program that implements the Java program dynamic update method according to any one of claims 1-7 when executed by a processor.

Citation Information

Patent Citations

  • Hot-load method and device and information system

    CN102819438A

  • Hot updating method and apparatus

    CN107179925A

  • Method and device for realizing application hot deployment

    CN110716720A

  • Application program upgrading method, system and device and computer storage medium

    CN111625256A

  • Application program updating method, device, equipment and computer storage medium

    CN112130888A