Dynamic function enhancement method based on application program

By listening to events and calling local plug-ins with JVM Tool Interface, the bytecode is dynamically adjusted, which solves the problem of high coupling of program enhancement methods in the existing technology, realizes independent development and deployment, and supports the functional enhancement of multi-objective programs. Improves application performance and applicability.

CN119201060AActive Publication Date: 2024-12-27北京东方通软件有限公司 +2
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411226252.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-03
Publication Date
2024-12-27
Estimated Expiration
2044-09-03

AI Technical Summary

Technical Problem

In the existing technology, the program enhancement method has problems such as strong invasiveness, high coupling, single scenarios and one-to-one engineering, which leads to the high coupling between the code of the enhanced part and the target program, which cannot be independently developed and deployed, and has a narrow scope of application. It is not possible to serve multiple target programs.

Method used

By listening to preset key events, obtaining event trigger information, using JVM Tool Interface to call local plug-ins, dynamically adjust the original bytecode, generate the modified target bytecode, and implement functions through custom callback methods and joint decoder Dynamic enhancement of logic allows agents to be dynamically associated with target programs at runtime, implement independent development and deployment, and supports functional enhancement of multiple target programs.

Benefits of technology

It realizes independent development and deployment of agents, reduces physical binding requirements during deployment, enhances flexible reuse of some codes, has a wider range of applicable scenarios, supports the enhancement of functions of multiple target programs, and improves the performance of applications and users. Experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119201060A_ABST
    Figure CN119201060A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of program enhancement, and provides a function dynamic enhancement method based on an application program, which comprises the following steps: when a target program runs, monitoring whether a preset key event exists or not; when the preset key event exists, event triggering information is obtained; according to the event triggering information, a local plug-in is called through a JVM Tool interface; and dynamically adjusting the original byte code according to the local plug-in. According to the method, under the condition that source codes of the target application program are not modified, the target application program is endowed with the capacity of dynamically adding a new function or modifying an existing function, the method is applied to the application program of the java language, and independent development, independence and flexible reuse can be achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of program enhancement, and in particular to a function dynamic enhancement method based on an application program. Background Art

[0002] At present, applications in terminal devices need to be continuously updated and enhanced. However, most of the enhanced application functions are repeated and abstract requirements, such as real-time monitoring of some indicators (number of requests, response time) for applications, dynamic flow control for applications, etc. These requirements are real non-business requirements for each application system. Customers mostly focus on the realization of their own business functions in daily development, but after going online, they find that such non-business requirements are crucial to the stability and reliability of the system. However, the program enhancement method in the existing technology can be dynamically attached to the customer application to provide such common non-business functions.

[0003] Although traditional bytecode enhancement or code proxy methods do not make direct hard-coded modifications to target methods and target classes, they still require that the enhanced code and the target program physically belong to the same project, which results in the following deficiencies:

[0004] Highly invasive: The intrusion into the target program is high. The enhanced code must be written in the target program. If the source code of the target program cannot be obtained, the enhancement technology cannot be used.

[0005] High coupling degree: If the traditional bytecode enhancement technology is separated from the target program and runs independently, it will not be able to associate with the target program, and thus cannot modify the bytecode of the target program, resulting in the inability to enhance its functions.

[0006] Single scenario: Traditional bytecode enhancement technology requires static coding of enhancement functions to be completed in the original project in advance, and must be physically bound to the source code, so it is only applicable to the case where the source code has been obtained or compiled. However, since the source code can be obtained, it can be modified directly on the source code, so the scope of application is narrow and the scenarios are limited.

[0007] One-to-one engineering: The technical characteristics of traditional bytecode enhancement technology determine that the enhanced code and the target program must be one-to-one, that is, the enhanced code can only serve one target program. If other target programs also need the capabilities provided by the enhanced code, the code engineering needs to be rewritten.

[0008] The fundamental reason why traditional technology has the above-mentioned drawbacks is that the degree of coupling between the enhanced part code and the target program is too high. Summary of the invention

[0009] The present invention provides a function dynamic enhancement method based on an application program, which is used to solve the problem that the coupling degree between the enhanced part code and the target program is too high.

[0010] In a first aspect, the present invention provides a method for dynamically enhancing functions based on an application program, comprising:

[0011] When the target program is running, monitor whether there are preset key events;

[0012] When there is a preset key event, obtain event trigger information;

[0013] Based on the event trigger information, the local plug-in is called through the JVM Tool Interface;

[0014] The original bytecode is dynamically adjusted according to the local plug-in.

[0015] In combination with the first aspect, the key event corresponds to a unique callback method, wherein the callback method is loaded into the main program by a custom registration method, and the callback method runs before the main program of the target program.

[0016] In combination with the first aspect, the JVM Tool Interface includes a first interface and a second interface, wherein the first interface is used to connect to a local plug-in, and the second interface is connected to a JVM of a target program;

[0017] Local plug-ins are agent programs used to enhance the running functions of target programs;

[0018] JVM Tool Interface is loaded by JVM as a dynamic link library.

[0019] In combination with the first aspect, the JVM Tool Interface further includes a ClassFileLoadHook event, wherein when the ClassFileLoadHook event is triggered, the current time is used as the modification time for modifying the target program bytecode.

[0020] In combination with the first aspect, the dynamic adjustment of the original bytecode includes:

[0021] Get the modified bytecode of the local plugin;

[0022] The modified bytecode and the original bytecode are merged to generate a modified target bytecode.

[0023] In combination with the first aspect, after dynamically adjusting the original bytecode, the method further includes:

[0024] Setting a functional logic test, wherein the functional logic test includes a plurality of triggers, wherein the triggers are set based on the functional logic of the target program;

[0025] Obtaining the dynamically adjusted target bytecode as input code for functional logic testing of the target program;

[0026] Based on the input code, obtain the first trigger result of the functional logic test and generate a Webshell file with execution parameters;

[0027] The Webshell file is input into the gain function, the output result is recorded, and when the output result of the gain function is positive, a first response is returned, wherein the first response is used to characterize the enhanced execution function of the dynamically adjusted application program.

[0028] In combination with the first aspect, the merging of the modified bytecode and the original bytecode further includes:

[0029] Generate a Token sequence based on the original bytecode;

[0030] Based on the preset attention mechanism gating, determine the source code features of each token position in the token sequence;

[0031] Perform SAT analysis on the modified bytecode to determine the enhanced features;

[0032] The enhanced features and source code are also fused through the joint decoder to determine the core logic of the target bytecode and generate a text summary of the core logic, where:

[0033] When the result of the text summary output by the joint decoder is a positive number, it means that dynamic adjustment can be performed;

[0034] When the result of the text summary output by the joint decoder is a negative number, it means that the local plug-in corresponding to the current modified bytecode cannot be dynamically adjusted.

[0035] In combination with the first aspect, the preset key event also includes:

[0036] The preset key event and the code fragment associated with the original bytecode are grouped as a monitoring group;

[0037] One or more call buffers are set according to the monitoring group, and the local plug-in is cached in the call buffer, wherein the one or more call buffers are set in a local server of the target program;

[0038] When a preset key event is monitored, a target call buffer in the local server with the highest correlation with the preset key event is determined, and the target call buffer is used as the highest priority call buffer, and:

[0039] In response to the registration information of the local plug-in corresponding to the target buffer, and according to the registration information, an enhancement target for dynamically enhancing the target program is determined.

[0040] In combination with the first aspect, the calling of the local plug-in also meets the following conditions:

[0041] In response to the event triggering information, the first interface of the JVM Tool Interface is configured to be in an available state, and the original bytecode of the target program is configured to be in an insertable state;

[0042] In response to the target plug-in in the local plug-in, the modified bytecode in the target plug-in is configured to be in an authenticated state.

[0043] In combination with the first aspect, the callback method is set by the following steps:

[0044] Switch the main program to the trusted registration mode, and define the callback method corresponding to each preset key event according to the preset key event.

[0045] The beneficial effects of the present invention are:

[0046] Independent development: When writing an agent program, you do not need to worry about its own location. You can write, run, and debug it independently. It also does not care about the location of the target program. Even when writing an agent program, the target program has not been created yet, and you can still do the coding.

[0047] Independent deployment: During the deployment phase, the proxy program and the target program are physically separated and do not need to be in the same project. As long as the two programs are directly connected to each other through the network, they can be automatically and dynamically associated when the program is running. This solves the problem of strong physical binding during deployment. This design makes the enhanced code more flexible and applicable to a wider range of scenarios.

[0048] Flexible reuse: The existing technology that requires a one-to-one strong coupling between the proxy service and the target service is abandoned, and the proxy program is optimized to serve multiple target programs at the same time. The principle of achieving this effect is to let the target service actively find the proxy program, that is, when the target program is started, the address of the proxy program is passed as a startup parameter to the target program, and dynamically linked at runtime. In this way, a code with a common enhanced part can provide services for multiple sets of target services at the same time.

[0049] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description and the accompanying drawings.

[0050] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:

[0052] Figure 1 A method flow chart of a method for dynamically enhancing functions based on an application program in an embodiment of the present invention;

[0053] Figure 2 is a fusion flow chart for fusing modified bytecode and original bytecode in an embodiment of the present invention;

[0054] Figure 3 This is a code diagram for actual implementation of dynamic enhancement of an application in an embodiment of the present invention. DETAILED DESCRIPTION

[0055] The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.

[0056] like Figure 1 and Figure 3 As shown, this embodiment provides a method for dynamically enhancing functions based on an application program, including:

[0057] When the target program is running, monitor whether there are preset key events; specifically, some common key events can be set, such as window closing, user clicking a button, etc. When these key events occur, the program will automatically trigger the corresponding operation.

[0058] When there is a preset key event, the event trigger information is obtained; specifically, the system log or error message when the key event occurs can be captured and converted into a readable format. This information will be used for subsequent dynamic enhancement operations.

[0059] According to the event trigger information, the local plug-in is called through the JVM Tool Interface; specifically, a local plug-in can be written, which can perform specific operations according to the event trigger information. This plug-in can be loaded into the Java Virtual Machine (JVM) of the target program so that it can be quickly called at runtime.

[0060] The original bytecode is dynamically adjusted based on the local plug-in. Specifically, the code in the plug-in can be embedded into the bytecode of the target program and replace the original bytecode at runtime. This allows dynamic modification of the target program without recompiling and deploying the application.

[0061] The principle of the above technical solution is:

[0062] In the actual implementation process, the present invention uses the extended interface (JVM ToolInterface) exposed by JVM, so that developers can register custom callback methods in key events such as program startup and class loading, and the callback method customized by the developer will be performed before the main program of the target program, ensuring that the JVM of the target program perceives that this startup needs to be enhanced by an external program. When an event occurs, the JVM Tool Interface calls and implements the registered callback method, which is the enhanced function logic written by the developer himself, and the JVM ToolInterface is loaded by the JVM in the form of a dynamic link library. At the same time, since the JVM Tool Interface is a two-way interface, one end is connected to the agent program customized by the developer, and the other end is connected to the JVM of the target program, so the local program developed by the developer himself can communicate with the JVM of the target program. Through the above mechanism, the enhanced function written by the developer himself is given the ability to communicate with the target program when key and specific events are executed. At the same time, it is also necessary to realize dynamic modification of the loaded class bytecode to ultimately achieve the effect of enhancing the target program.

[0063] The beneficial effects of the above technical solution are:

[0064] Independent development: When writing an agent program, you do not need to worry about its own location. You can write, run, and debug it independently. It also does not care about the location of the target program. Even when writing an agent program, the target program has not been created yet, and you can still do the coding.

[0065] Independent deployment: During the deployment phase, the proxy program and the target program are physically separated and do not need to be in the same project. As long as the two programs are directly connected to each other through the network, they can be automatically and dynamically associated when the program is running. This solves the problem of strong physical binding during deployment. This design makes the enhanced code more flexible and applicable to a wider range of scenarios.

[0066] Flexible reuse: The existing technology that requires a one-to-one strong coupling between the proxy service and the target service is abandoned, and the proxy program is optimized to serve multiple target programs at the same time. The principle of achieving this effect is to let the target service actively find the proxy program, that is, when the target program is started, the address of the proxy program is passed as a startup parameter to the target program, and dynamically linked at runtime. In this way, a code with a common enhanced part can provide services for multiple sets of target services at the same time.

[0067] As an embodiment of the present invention: the key event corresponds to a unique callback method, wherein the callback method is loaded into the main program by a custom registration method, and the callback method runs before the main program of the target program.

[0068] The principle of the above technical solution is:

[0069] When a key event of the present invention occurs, the main program will encapsulate the custom registered callback method and related information into a message object, and send it to the running target program through a specific communication mechanism. After the target program receives the message, it will call the corresponding local plug-in to perform related operations based on the custom registered callback method and related information in the message. Since the custom registered callback method has been determined and registered before the main program runs, when the local plug-in is called, the target program can immediately start the plug-in and start execution, thereby greatly shortening the response time and delay of the application. At the same time, since the custom registered callback method runs before the main program of the target program, it can ensure that a series of complex operations are completed before the target program starts.

[0070] As an embodiment of the present invention: the JVM Tool Interface includes a first interface and a second interface, wherein the first interface is used to connect to a local plug-in, and the second interface is connected to a JVM of a target program;

[0071] Local plug-ins are agent programs used to enhance the running functions of target programs;

[0072] JVM Tool Interface is loaded by JVM as a dynamic link library.

[0073] The principle of the above technical solution is:

[0074] Specifically, the present invention can add multiple interfaces to the JVM Tool Interface, each interface having different uses and functions. For example, an interface named "EventListener" can be added to receive event notifications from the application and pass them to the corresponding local plug-in. In addition, an interface named "MethodInterceptor" can be added to intercept specific methods of the target program and modify these methods or call other services before or after these methods are executed.

[0075] You can use dynamic link libraries to load and manage the JVM Tool Interface. A dynamic link library is a reusable code module that can be loaded into the application's memory and dynamically referenced and replaced at runtime. This loading method makes the loading and management of the JVM Tool Interface more flexible and efficient, and can also avoid compatibility issues caused by version and other reasons.

[0076] In addition, in order to allow the local plug-in to better interact with the JVM Tool Interface, some additional APIs and methods can be provided for it. For example, some APIs for accessing and managing target program resources can be provided for the local plug-in, such as opening, closing, reading and modifying files, database records, network requests, etc. These APIs can allow the local plug-in to directly operate the underlying resources of the target program, thereby further improving the performance of the application and user experience.

[0077] As an embodiment of the present invention: the JVM Tool Interface also includes a ClassFileLoadHook event, wherein when the ClassFileLoadHook event is triggered, the current time is used as the modification time for modifying the target program bytecode.

[0078] The principle of the above technical solution is:

[0079] When the JVM detects the ClassFileLoadHook event, the present invention can determine which strategy should be adopted to adjust the bytecode of the target program according to information such as the type and parameters of the event. For example, if the ClassFileLoadHook event is caused by a specific class, then a new processing logic can be inserted into the method of the class to improve the efficiency of the method.

[0080] In addition, in practical applications, in order to ensure that the JVM Tool Interface can be correctly loaded and used, it is also necessary to properly encapsulate and design the Tool Interface. For example, some common callback functions can be defined to perform specific tasks at different stages of the tool chain. In this way, even if some parts of the tool chain change, it will not affect the normal operation of the entire tool chain.

[0081] As an embodiment of the present invention: the dynamic adjustment of the original bytecode includes:

[0082] Get the modified bytecode of the local plugin;

[0083] The modified bytecode and the original bytecode are merged to generate a modified target bytecode.

[0084] The principle of the above technical solution is:

[0085] In the process of dynamically adjusting the original bytecode, the present invention first needs to obtain the modified bytecode of the local plug-in. This step usually involves analyzing, optimizing and modifying the plug-in code so that the plug-in can play a role in a wider range of application scenarios.

[0086] Next, the modified bytecode is merged with the original bytecode. The key to this process is how to ensure the compatibility of the two and avoid exceptions or potential problems caused by incompatibility. To this end, a variety of technical means can be used, such as string concatenation, array copying, pointer operations, etc. The ultimate goal is to generate a modified target bytecode that contains the dynamically adjusted plug-in code and the native bytecode, thereby achieving comprehensive optimization of the target program.

[0087] This dynamic adjustment method can not only solve the performance problems of the application in specific scenarios, but also improve the user experience. At the same time, since this adjustment is made without affecting the original code, it is easier to find and fix possible problems during later maintenance and updates.

[0088] As an embodiment of the present invention: after the original bytecode is dynamically adjusted, the method further includes:

[0089] Setting a functional logic test, wherein the functional logic test includes a plurality of triggers, wherein the triggers are set based on the functional logic of the target program;

[0090] Obtaining the dynamically adjusted target bytecode as input code for functional logic testing of the target program;

[0091] Based on the input code, obtain the first trigger result of the functional logic test and generate a Webshell file with execution parameters;

[0092] The Webshell file is input into the gain function, the output result is recorded, and when the output result of the gain function is positive, a first response is returned, wherein the first response is used to characterize the enhanced execution function of the dynamically adjusted application program.

[0093] The principle of the above technical solution is:

[0094] The present invention uses the dynamically adjusted target bytecode as the input code for the functional logic test of the target program. At this point, we can use various analysis techniques and models, such as fuzz testing, simulation testing, etc., to determine which tests are the most important and add them to the functional logic test set.

[0095] According to the input code, the first trigger result of the functional logic test is obtained. These results will be used as an important basis for evaluating the enhanced effect of the dynamically adjusted application execution function.

[0096] Generate a Webshell file with execution parameters. This file is a special script that can be executed in the dynamically adjusted application. It can be used to start an additional test to verify the enhanced effect of the dynamically adjusted application function.

[0097] Input the generated Webshell file into the gain function and record the output result. The gain function is a special algorithm that can improve or enhance the performance of an application. It can improve the performance of a dynamically adjusted application to a whole new level.

[0098] When the output of the gain function is positive, the first response is returned, which will be used to characterize the performance enhancement of the dynamically adjusted application.

[0099] As an embodiment of the present invention: the merging of the modified bytecode and the original bytecode further includes:

[0100] Generate a Token sequence based on the original bytecode;

[0101] Based on the preset attention mechanism gating, determine the source code features of each token position in the token sequence;

[0102] Perform SAT analysis on the modified bytecode to determine the enhanced features;

[0103] The enhanced features and source code are also fused through the joint decoder to determine the core logic of the target bytecode and generate a text summary of the core logic, where:

[0104] When the result of the text summary output by the joint decoder is a positive number, it means that dynamic adjustment can be performed;

[0105] When the result of the text summary output by the joint decoder is a negative number, it means that the local plug-in corresponding to the current modified bytecode cannot be dynamically adjusted.

[0106] The principle of the above technical solution is:

[0107] like Figure 2 As shown, the present invention generates a Token sequence based on the original bytecode. A Token is the smallest executable unit in an application, which can be code, data, a string, etc. By generating a Token sequence, we can better understand the structure and logic of an application.

[0108] According to the preset attention mechanism gating, the source code features of each token position in the token sequence are determined. The attention mechanism gating can identify the key parts in the token sequence and determine their sources and uses. This information can help us better understand the behavior and logic of the application.

[0109] Perform static analysis on the modified bytecode to identify enhancement features. Static analysis is a method of analyzing the code to identify potential problems and opportunities in the code. Through static analysis, we can find problems in the modified bytecode and optimize and improve it.

[0110] Jointly decode the enhanced features and the source code to determine the core logic of the target bytecode. Joint decoding is a method that combines the enhanced features and the decoder to generate a new bytecode. Through joint decoding, we can ensure that the modified bytecode is consistent with the original bytecode and can improve the performance and stability of the application.

[0111] Generate a text summary of the core logic. By generating the core logic, we can get a new, optimized application with improved performance and user experience.

[0112] When the result of the text summary output by the joint decoder is a positive number, it means that dynamic adjustment can be made. This means that we can dynamically adjust the application by changing the execution mode of the core logic. This adjustment can be fine-grained or coarse-grained, depending on our needs.

[0113] As an embodiment of the present invention: the preset key event also includes:

[0114] The preset key event and the code fragment associated with the original bytecode are grouped as a monitoring group;

[0115] One or more call buffers are set according to the monitoring group, and the local plug-in is cached in the call buffer, wherein the one or more call buffers are set in a local server of the target program;

[0116] When a preset key event is monitored, a target call buffer in the local server with the highest correlation with the preset key event is determined, and the target call buffer is used as the highest priority call buffer, and:

[0117] In response to the registration information of the local plug-in corresponding to the target buffer, and according to the registration information, an enhancement target for dynamically enhancing the target program is determined.

[0118] The principle of the above technical solution is:

[0119] The present invention includes: presetting key events: taking the preset key events and the code snippets associated with the original bytecode as a monitoring group. Setting call caches: setting one or more call caches according to the monitoring group, and caching the local plug-ins in the call caches. These call caches can be deployed in the local server of the target program. Determining the call cache with the highest priority: when a preset key event is monitored, determining the target call cache with the highest correlation with the preset key event in the local server, and taking the target call cache as the highest priority call cache. Responding to the registration information of the target cache: responding to the registration information of the local plug-in corresponding to the target cache, and determining the enhancement target for dynamic enhancement of the target program based on the registration information. The application-based dynamic function enhancement method of the present invention can respond to user needs in real time when a preset key event is triggered, thereby realizing dynamic adjustment of the application and improving the performance of the application and user experience.

[0120] As an embodiment of the present invention: the calling of the local plug-in also meets the following conditions:

[0121] In response to the event triggering information, the first interface of the JVM Tool Interface is configured to be in an available state, and the original bytecode of the target program is configured to be in an insertable state;

[0122] In response to the target plug-in in the local plug-in, the modified bytecode in the target plug-in is configured to be in an authenticated state.

[0123] The principle of the above technical solution is:

[0124] In response to event triggering information, the present invention configures the first interface of the JVM Tool Interface to an available state, which allows developers to use the tool interface to write and load plug-ins. The original bytecode of the target program is configured to be pluggable, which means that the function of the target program can be enhanced without changing the original code. In response to the target plug-in in the local plug-in, the modified bytecode in the target plug-in is configured to be authenticated. This step is to ensure the security and stability of the plug-in, and only authenticated plug-ins can be successfully loaded and used. Through the above technical scheme, the embodiments of the present invention can realize dynamic enhancement of applications at runtime, realize real-time improvement and optimization of application functions, and ensure the stability and security of the system.

[0125] In actual applications, we can expand and improve the above technical solutions for different types of applications and scenarios. For example, we can add more interfaces and plug-ins to support more types of functional enhancement requirements. At the same time, we can also develop more intelligent and automated tools to simplify the process of writing, loading and managing plug-ins and improve work efficiency.

[0126] As an embodiment of the present invention: the callback mode is set by the following steps:

[0127] Switch the main program to the trusted registration mode, and define the callback method corresponding to each preset key event according to the preset key event.

[0128] The principle of the above technical solution is:

[0129] In the process of calling back the unreachable key events, when the administrator registers the unreachable callback mode, the present invention adjusts the main program to a credible registration mode, and then implements the callback registration.

[0130] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A method for dynamic enhancement of functions based on an application program, characterized in that: include: When the target program is running, monitor whether there are preset key events; When there is a preset key event, obtain event trigger information; Based on the event trigger information, the local plug-in is called through the JVM Tool Interface; The original bytecode is dynamically adjusted according to the local plug-in.

2. A method for dynamically enhancing functions based on an application program as claimed in claim 1, characterized in that: The key event corresponds to a unique callback method, wherein the callback method is loaded into the main program by a custom registration method, and the callback method runs before the main program of the target program.

3. A method for dynamic enhancement of functions based on an application program as claimed in claim 1, characterized in that: The JVMTool Interface includes a first interface and a second interface, wherein the first interface is used to connect to a local plug-in, and the second interface is connected to a JVM of a target program; Local plug-ins are agent programs used to enhance the running functions of target programs; JVM Tool Interface is loaded by JVM as a dynamic link library.

4. A method for dynamically enhancing functions based on an application program as claimed in claim 1, characterized in that: The JVMTool Interface also includes a ClassFileLoadHook event, wherein when the ClassFileLoadHook event is triggered, the current time is used as the modification time for modifying the target program bytecode.

5. The method for dynamically enhancing functions based on an application program as claimed in claim 1, characterized in that: The dynamic adjustment of the original bytecode includes: Get the modified bytecode of the local plugin; The modified bytecode and the original bytecode are merged to generate a modified target bytecode.

6. A method for dynamically enhancing functions based on an application program as claimed in claim 5, characterized in that: After the original bytecode is dynamically adjusted, the following steps are also included: Setting a functional logic test, wherein the functional logic test includes a plurality of triggers, wherein the triggers are set based on the functional logic of the target program; Obtaining the dynamically adjusted target bytecode as input code for functional logic testing of the target program; Based on the input code, obtain the first trigger result of the functional logic test and generate a Webshell file with execution parameters; The Webshell file is input into the gain function, the output result is recorded, and when the output result of the gain function is positive, a first response is returned, wherein the first response is used to characterize the enhanced execution function of the dynamically adjusted application program.

7. A method for dynamically enhancing functions based on an application program as claimed in claim 5, characterized in that: The merging of the modified bytecode and the original bytecode further includes: Generate a Token sequence based on the original bytecode; Based on the preset attention mechanism gating, determine the source code features of each token position in the token sequence; Perform SAT analysis on the modified bytecode to determine the enhanced features; The enhanced features and source code are also fused through the joint decoder to determine the core logic of the target bytecode and generate a text summary of the core logic, where: When the result of the text summary output by the joint decoder is a positive number, it means that dynamic adjustment can be performed; When the result of the text summary output by the joint decoder is a negative number, it means that the local plug-in corresponding to the current modified bytecode cannot be dynamically adjusted.

8. A method for dynamically enhancing functions based on an application program as claimed in claim 5, characterized in that: The preset key events also include: The preset key event and the code fragment associated with the original bytecode are grouped as a monitoring group; One or more call buffers are set according to the monitoring group, and the local plug-in is cached in the call buffer, wherein the one or more call buffers are set in a local server of the target program; When a preset key event is monitored, a target call buffer in the local server with the highest correlation with the preset key event is determined, and the target call buffer is used as the highest priority call buffer, and: In response to the registration information of the local plug-in corresponding to the target buffer, and according to the registration information, an enhancement target for dynamically enhancing the target program is determined.

9. A method for dynamically enhancing functions based on an application program as claimed in claim 3, characterized in that: The calling of the local plug-in also meets the following conditions: In response to the event triggering information, the first interface of the JVM Tool Interface is configured to be in an available state, and the original bytecode of the target program is configured to be in an insertable state; In response to the target plug-in in the local plug-in, the modified bytecode in the target plug-in is configured to be in an authenticated state.

10. A method for dynamically enhancing functions based on an application program as claimed in claim 2, characterized in that: The callback method is set by the following steps: Switch the main program to the trusted registration mode, and define the callback method corresponding to each preset key event according to the preset key event.

Citation Information

Patent Citations

  • Interface test method and device, electronic equipment and storage medium

    CN112597001A

  • JVM cross-process communication method and system with target application

    CN116775332A

  • Code abstract generation method and system based on multi-modal feature fusion

    CN118550580A

  • Scheme for verifying the effects of program optimizations

    US9495138B1

  • Execution of asset tokenization and ownership with machine learning technology

    WO2025046281A1