Hot repair method, device, equipment and storage medium are applied
Patent Information
- Application Number
- CN202611177238.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-04
- Publication Date
- 2026-10-20
AI Technical Summary
[0003]本申请的主要目的在于提供一种应用热修复方法、装置、设备及存储介质,旨在解决目前的应用修复方案中补丁代码均由人工编写,生成代码的安全性和确定性较低的技术问题
[0025]本申请提出的一个或多个技术方案,通过对获取的意图描述信息进行解析,得到结构化的修复意图对象;根据所述修复意图对象构建结构化提示词,并对所述结构化提示词进行推理,生成目标代码片段;对所述目标代码片段进行语法编译,生成对应的字节码文件;将所述字节码文件注入至当前应用中,以覆盖所述修复意图对象对应的原始代码。通过将代码生成能力下沉至端侧,利用结构化提示词直接生成目标代码片段,并在本地完成编译与注入,消除了人工编写补丁代码及云端分发预编译产物的环节,从而缩短了修复链路并提升了响应效率,提高了应用热修复的安全性以及准确性。
Smart Images

Figure FT_1 
Figure FT_2 
Figure FT_3
Abstract
Description
Technical Field
[0001] This application relates to the field of applied thermal repair technology, and more particularly to applied thermal repair methods, apparatus, devices and storage media. Background Technology
[0002] In mobile application development and maintenance, hotfix technology is often used to dynamically modify application behavior without releasing a new version in order to fix online defects or adjust business logic. Existing hotfix solutions generally employ a model where pre-compiled patch packages are distributed to clients for loading. This means the patch code relies entirely on developers to manually write, compile, and test it, with the mobile device merely acting as a receiver and loader for the patch package. This model results in a long chain from problem discovery to patch effectiveness and makes it impossible to dynamically generate fix code based on the device's runtime context, failing to meet the needs of rapid business response. Summary of the Invention
[0003] The main purpose of this application is to provide an application hotfix method, apparatus, device and storage medium, which aims to solve the technical problem that the patch code in the current application fix scheme is all written manually, resulting in low security and determinism of the generated code.
[0004] To achieve the above objectives, this application proposes a thermal repair method, which includes: The obtained intent description information is parsed to obtain a structured repair intent object; Based on the repair intent object, a structured prompt word is constructed, and reasoning is performed on the structured prompt word to generate a target code fragment; The target code fragment is syntactically compiled to generate the corresponding bytecode file; The bytecode file is injected into the current application to overwrite the original code corresponding to the repair intent object.
[0005] In one embodiment, the step of parsing the acquired intent description information to obtain a structured repair intent object includes: The obtained intent description information is parsed to obtain the keyword information in the intent description information and the list of interfaces to be called declared in the intent description information; The keyword information and the list of interfaces to be called are validated to obtain a structured intent repair object.
[0006] In one embodiment, the step of validating the keyword information and the list of interfaces to be called to obtain a structured intent repair object includes: The keyword information is subjected to basic information verification to obtain the basic information verification result; Perform security constraint verification on the list of interfaces to be called, and obtain the security constraint verification result; If both the basic information verification result and the security constraint verification result pass the verification, the keyword information is encapsulated into a structured intent repair object.
[0007] In one embodiment, the step of performing basic information verification on the keyword information to obtain the basic information verification result includes: Obtain the class name information, method name information, and behavior description information from the keyword information; Determine whether the class name information is consistent with the target class name, whether the method name information is consistent with the target method name, and whether the behavior description information is consistent with the target behavior description, wherein the target class name, the target method name, and the target behavior description are information in the key fields required to perform hotfix; If the class name information is consistent with the target class name, the method name information is consistent with the target method name, and the behavior description information is consistent with the target behavior description, the string format of the class name information is matched and detected. If the string format of the class name information conforms to the preset naming convention, the basic information verification result is determined to be successful.
[0008] In one embodiment, the step of performing security constraint verification on the list of interfaces to be called and obtaining the security constraint verification result includes: Iterate through the list of interfaces to be called and compare each interface in the list with a preset interface whitelist; If all interfaces in the list of interfaces to be called exist in the interface whitelist, the security constraint verification result is determined to be successful. If any of the interfaces in the list of interfaces to be called does not exist in the interface whitelist, the security constraint verification result is determined to be verification failure.
[0009] In one embodiment, the step of constructing structured prompts based on the repair intent object includes: Based on the intent type corresponding to the repair intent object, determine the corresponding structured prompt word template; The repair intent object is parsed to generate prompt words containing class information segment, behavior description segment, constraint segment and output format segment; The prompt words are filled into the structured prompt word template to obtain structured prompt words.
[0010] In one embodiment, the step of syntactically compiling the target code fragment to generate the corresponding bytecode file includes: The target code fragment is parsed into compilation units; Detect whether there are syntax errors in the compilation unit; If there are no syntax errors in the compilation unit, the target code fragment is compiled into a bytecode array, and the corresponding bytecode file is obtained based on the bytecode array.
[0011] In one embodiment, the step of compiling the target code segment into a bytecode array and obtaining the corresponding bytecode file based on the bytecode array, when there are no syntax errors in the compilation unit, includes: If there are no syntax errors in the compilation unit, the target code fragment is compiled into a bytecode array; The bytecode of the first preset version in the bytecode array is converted into the bytecode of the second preset version to obtain a version-converted bytecode array, wherein the first preset version is higher than the second preset version; The converted bytecode of the aforementioned version is optimized to obtain optimized bytecode; Generate a bytecode file that conforms to a preset specification based on the optimized bytecode.
[0012] In one embodiment, after the step of detecting whether there is a syntax error in the compilation unit, the method further includes: If a syntax error exists in the compilation unit, determine the type and location of the compilation error, and generate a code snapshot; A compilation failure log is generated based on the compilation error type, the error location, the code snapshot, and the intent description information; The compilation failure log will be reported.
[0013] In one embodiment, the step of injecting the bytecode file into the current application to overwrite the original code corresponding to the repair intent object includes: Write the bytecode file to the current application's private directory and construct a class loader instance for loading the bytecode file; The path list object in the current application's default class loader is obtained through reflection, and the original element array containing the original code corresponding to the repair intent object is extracted from the path list object. Extract the patch element object containing the bytecode file from the class loader instance; The patch element object is inserted at the beginning of the original element array to generate a merged target element array. The target element array is then written back to the path list object using reflection to overwrite the original code corresponding to the repair intent object.
[0014] In one embodiment, after the steps of constructing structured prompts based on the repair intent object and inferring from the structured prompts to generate target code fragments, the method further includes: The target code segment is subjected to constraint verification to determine whether the number of lines in the target code segment exceeds a preset line count threshold and whether the syntax structure of the target code segment is complete; If the number of lines in the target code segment does not exceed a preset line count threshold and the syntax structure is complete, the constraint verification is determined to be successful, and the step of syntactic compilation of the target code segment to generate the corresponding bytecode file is triggered.
[0015] Furthermore, to achieve the above objectives, this application also proposes an application-based thermal repair device, which includes: The parsing module is used to parse the acquired intent description information to obtain a structured repair intent object; A construction module is used to construct structured prompts based on the repair intent object, and to infer from the structured prompts to generate target code snippets; The compilation module is used to perform syntax compilation on the target code fragment and generate the corresponding bytecode file; The injection module is used to inject the bytecode file into the current application to overwrite the original code corresponding to the repair intent object.
[0016] In one embodiment, the parsing module is further configured to parse the acquired intent description information to obtain keyword information in the intent description information and a list of interfaces to be called declared in the intent description information; The keyword information and the list of interfaces to be called are validated to obtain a structured intent repair object.
[0017] In one embodiment, the parsing module is further configured to perform basic information verification on the keyword information to obtain a basic information verification result; Perform security constraint verification on the list of interfaces to be called, and obtain the security constraint verification result; If both the basic information verification result and the security constraint verification result pass the verification, the keyword information is encapsulated into a structured intent repair object.
[0018] In one embodiment, the parsing module is further configured to obtain class name information, method name information, and behavior description information from the keyword information; Determine whether the class name information is consistent with the target class name, whether the method name information is consistent with the target method name, and whether the behavior description information is consistent with the target behavior description, wherein the target class name, the target method name, and the target behavior description are information in the key fields required to perform hotfix; If the class name information is consistent with the target class name, the method name information is consistent with the target method name, and the behavior description information is consistent with the target behavior description, the string format of the class name information is matched and detected. If the string format of the class name information conforms to the preset naming convention, the basic information verification result is determined to be successful.
[0019] In one embodiment, the parsing module is further configured to traverse the list of interfaces to be called and compare each interface in the list of interfaces to be called with a preset interface whitelist; If all interfaces in the list of interfaces to be called exist in the interface whitelist, the security constraint verification result is determined to be successful. If any of the interfaces in the list of interfaces to be called does not exist in the interface whitelist, the security constraint verification result is determined to be verification failure.
[0020] In one embodiment, the construction module is further configured to determine a corresponding structured prompt word template based on the intent type corresponding to the repair intent object; The repair intent object is parsed to generate prompt words containing class information segment, behavior description segment, constraint segment and output format segment; The prompt words are filled into the structured prompt word template to obtain structured prompt words.
[0021] In one embodiment, the compilation module is further configured to parse the target code fragment into compilation units; Detect whether there are syntax errors in the compilation unit; If there are no syntax errors in the compilation unit, the target code fragment is compiled into a bytecode array, and the corresponding bytecode file is obtained based on the bytecode array.
[0022] In addition, to achieve the above objectives, this application also proposes an application hot-repair device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the application hot-repair method as described above.
[0023] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the application hot-repair method as described above.
[0024] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the application hotfix method as described above.
[0025] This application proposes one or more technical solutions that, by parsing the acquired intent description information, obtain a structured repair intent object; construct structured prompt words based on the repair intent object, and infer from the structured prompt words to generate target code fragments; perform syntax compilation on the target code fragments to generate corresponding bytecode files; and inject the bytecode files into the current application to overwrite the original code corresponding to the repair intent object. By decentralizing code generation capabilities to the client side, directly generating target code fragments using structured prompt words, and completing compilation and injection locally, the steps of manually writing patch code and distributing pre-compiled artifacts in the cloud are eliminated, thereby shortening the repair chain, improving response efficiency, and enhancing the security and accuracy of application hotfixes. Attached Figure Description
[0026] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0027] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0028] Figure 1 This is a flowchart illustrating the application of the thermal repair method in Embodiment 1 of this application. Figure 2 This is a schematic flowchart illustrating the application of the thermal repair method in Embodiment 2 of this application. Figure 3 This is a flowchart illustrating the application of the thermal repair method in Embodiment 3 of this application. Figure 4 This is a schematic diagram of the module structure of the thermal repair device used in an embodiment of this application; Figure 5 This is a schematic diagram of the device structure of the hardware operating environment involved in the application of the hot repair method in the embodiments of this application.
[0029] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0030] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.
[0031] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.
[0032] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device or application hot-repair device capable of performing the above functions. The following description uses an application hot-repair device as an example to illustrate this embodiment and the subsequent embodiments. All actions involving the acquisition of signals, information, or data in this application are performed in accordance with the relevant data protection regulations of the locality and with authorization from the owner of the corresponding device.
[0033] Based on this, embodiments of this application provide a method for applying thermal repair, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the thermal repair method applied in this application.
[0034] In this embodiment, the application of the thermal repair method includes steps S10 to S40: Step S10: Parse the obtained intent description information to obtain a structured repair intent object.
[0035] It should be noted that in the current solution, when performing hot patching, the patch code is written manually, and the device does not have the ability to generate code. In order to solve the problems of long cycle and easy error in manually writing patch code, this embodiment eliminates the manual patch code writing step and transforms the device from a passive patch receiver to an active patch generator.
[0036] Therefore, in this example, the intent description information is lightweight text data sent from the cloud configuration center to the edge device. The intent description information is usually encapsulated in JSON or domain-specific language (DSL) format. The intent description information is a lightweight text description, smaller than a traditional binary patch package.
[0037] The intent description declares the target class name that needs fixing, the target method signature, a natural language description of the expected behavior changes, and security constraints. The cloud only distributes the intent description text and does not participate in writing or compiling the patch code. Security constraints may include a whitelist of allowed API calls, a maximum number of lines in a method body, and other conditions.
[0038] In this step, after receiving the text, the edge device extracts its fields and performs validity checks using its built-in parser, converting it into a structured object that can be directly called within the application—the repair intent object. This process achieves a mapping from natural language or semi-structured text to precise program semantics, laying the data foundation for subsequent automated processing.
[0039] It should be understood that the intent description information can also be read from a local configuration file or manually entered by the user, as long as it provides structured text describing the repair requirements.
[0040] Step S20: Construct structured prompts based on the repair intent object, and infer from the structured prompts to generate target code fragments.
[0041] In practice, after obtaining the repair intent object, it is not directly used as input for code generation. Instead, it is first assembled into structured prompts according to a preset template strategy. These prompts explicitly include elements such as class context information, behavior change requirements, API call whitelist constraints, and output format specifications. This design can effectively guide the edge AI model to understand the task boundaries.
[0042] This embodiment primarily utilizes a lightweight AI model engine embedded in the mobile device to translate and assemble the intent descriptions sent from the cloud into Java source code compliant with Android specifications in real time. The on-device engine is integrated into the target app as an Android Library, and a background service persistently listens for intent messages pushed from the cloud.
[0043] In practical implementation, the lightweight inference engine integrated on the device loads a model finely tuned for the code generation task. Based on this structured prompt, it performs real-time inference and directly outputs target code snippets that conform to grammatical specifications. For example, this target code snippet can be a Java source code string containing only method body implementations, without class definitions or import statements. By moving code generation capabilities from the development environment to the mobile runtime, the device gains the ability to autonomously create executable logic based on intent, completely eliminating the need for manual patching.
[0044] In one feasible implementation, the step of "constructing structured prompt words based on the repair intent object" in step S20 may include: determining the corresponding structured prompt word template based on the intent type corresponding to the repair intent object; The repair intent object is parsed to generate prompt words containing class information segment, behavior description segment, constraint segment and output format segment; The prompt words are filled into the structured prompt word template to obtain structured prompt words.
[0045] Understandably, in scenarios where code is generated autonomously on the client side, directly inputting repair intentions in natural language form into the model often leads to divergent results, grammatical errors, or the inclusion of unnecessary redundant information. To address this issue, this application employs a template-driven structured prompt word construction strategy. First, the system matches the most suitable structured prompt word template from a pre-built template library based on the intent type identifier carried by the repair intention object.
[0046] Intent types include, but are not limited to, different scenarios such as method logic replacement, field default value modification, exception handling enhancement, or return value interception. Since different types of repair tasks have different requirements for contextual information—for example, method replacement requires a complete method signature and parameter types, while field modification focuses more on field declarations and access modifiers—dynamic mapping between intent types and templates can provide the model with the most accurate task context framework, avoiding information noise or missing information caused by generic templates.
[0047] After determining the template, the system performs in-depth analysis of the repair intent object and generates prompt words containing four core functional segments.
[0048] The class information segment contains the target class name and the full method signature. It is used to populate metadata such as the target fully qualified class name, method signature, and parameter types. Its purpose is to enable the model to understand the class context of the patch, ensuring that the generated code can be seamlessly embedded into the existing class structure and avoiding symbol reference errors caused by the lack of context.
[0049] The behavior description section contains the natural language change requirements extracted from the intent description information, clarifying the functions that the patch needs to implement.
[0050] The constraint section explicitly injects security and specification restrictions, including a whitelist of allowed API calls and a maximum number of lines in the method body, limiting the range of APIs that the model can use and the output length.
[0051] The output format segment is an engineering adaptation instruction for the client-side compilation pipeline. It explicitly requires the model to output only the method body code and not class definitions, import statements or package declarations. The format constraint directly determines whether the generated text can be correctly parsed and packaged by the subsequent client-side compiler. If the model outputs a complete Java file structure, it will cause an error in the client-side lightweight compilation process.
[0052] After generating the content of each paragraph, the system fills it into the selected structured prompt template according to predefined placeholder rules, and finally assembles a complete structured prompt. For example, for a login logic repair task, the assembled prompt may be presented as: "[Class Information] com.example.auth.LoginManager#login(String, String); [Behavior] When password verification fails, call RetryService.recordFailure() and return false; [Constraints] Only RetryService. and Log are allowed to be called, and the code shall not exceed 50 lines; [Format] Only return the method body code block."
[0053] Through the construction and filling mechanism of the above-described four-segment structured prompt word template, this embodiment realizes the transformation from fuzzy natural language intent to precise engineering instructions. Compared with the traditional method of directly concatenating strings, this template-based design physically isolates the variable content from the instruction structure, which not only improves the maintainability and extensibility of the prompt words, but more importantly, significantly enhances the controllability of the output of the edge AI model.
[0054] In practical implementation, the core constraints of AI code generation include: generating only method bodies, not class definitions, import statements, or package declarations; the number of generated code lines not exceeding the `maxMethodSize` limit; only APIs declared in the `allowedApis` whitelist are allowed to be called; and the generated code must conform to Java syntax specifications and be directly compileable via JDT. Through API whitelists for the intent description language, method body line limits, and the "only method body generation" constraint mechanism, the scope of AI model generation is strictly limited within controllable boundaries, avoiding the generation of dangerous system calls or unexpected code logic. The four-stage design of the structured Prompt further ensures the determinism and predictability of the model output.
[0055] Step S30: Compile the target code fragment to generate the corresponding bytecode file.
[0056] It should be noted that since the code snippets generated by the artificial intelligence model are essentially source code in text form, they cannot be directly executed by the virtual machine, so compilation and conversion need to be completed on the client side.
[0057] This step utilizes a pure Java compiler integrated within the application sandbox to perform abstract syntax tree parsing and error detection on the target code snippet. After confirming the absence of syntax errors, it compiles the code into standard class bytecode, and further converts it into a dex format bytecode file adapted to the current runtime environment using a bytecode conversion tool. The entire compilation process is completed locally on the client side, without calling system-level compilation processes or relying on PC-side toolchains, and without uploading the code to the cloud for compilation. This client-side compilation mechanism not only ensures the security of source code data remaining within its domain, but also enables patch generation to respond instantly, unaffected by network transmission and cloud build queue delays.
[0058] In one feasible implementation, after the model inference is completed, in order to improve the accuracy of code generation, the generated diamante can be pre-validated. Therefore, after step S20, steps A11~A12 are also included: Step A11: Perform constraint verification on the target code segment to determine whether the number of lines in the target code segment exceeds a preset line count threshold and whether the syntax structure of the target code segment is complete; It should be noted that constraint validation of the target code snippet includes bracket matching validation: checking whether the number of { and} is consistent, as well as semicolon integrity checks; line count limit validation, which can determine whether the number of lines in the target code snippet exceeds the set preset line count threshold, and whether the syntax structure of the target code snippet is complete.
[0059] Step A12: If the number of lines in the target code segment does not exceed the preset line count threshold and the syntax structure is complete, determine that the constraint verification is passed, and trigger the execution of the step of syntactic compilation of the target code segment to generate the corresponding bytecode file.
[0060] It should be noted that if the constraint verification fails, the information of the current failure needs to be fed back to the AI inference module to re-trigger the target code snippet generation process until the generated target code passes the constraint verification. Only when the number of lines and the completeness of the syntax structure of the target code snippet pass the verification is the constraint verification confirmed to be successful, and the subsequent syntax compilation process is triggered.
[0061] Step S40: Inject the bytecode file into the current application to overwrite the original code corresponding to the repair intent object.
[0062] After obtaining the executable bytecode file, the system loads it into memory using a dynamic class loading mechanism and uses reflection to modify the search path of the current application's default class loader, placing the element containing the patch code before the original code element. Based on the class loading characteristics of the parent delegation model, when the virtual machine attempts to load the target class, it will preferentially hit the patch class located at the beginning of the search path, thus achieving runtime replacement of the original method logic without restarting the application.
[0063] In one feasible implementation, step S40 may include steps A21 to A24: Step A21: Write the bytecode file to the private directory of the current application and construct a class loader instance for loading the bytecode file; Before performing the injection, the system first writes the compiled bytecode file to the private directory of the current application, and at the same time creates a class loader instance, namely the DexClassLoader instance, to load the patch Dex file.
[0064] Specifically, HotPatchLoader loads the patch Dex file through DexClassLoader; the bytecode file is the patch Dex file.
[0065] Step A22: Obtain the path list object in the current application's default class loader through reflection, and extract the original element array containing the original code corresponding to the repair intent object from the path list object; Understandably, the pathList field of PathClassLoader is then obtained through reflection, which is the path list object in the current application's default class loader. Subsequently, the array of elements containing the original class code to be fixed is extracted from the path list object to prepare for the subsequent insertion of patch bytecode.
[0066] It is understandable that when responding to a class loading request, the path list object searches for class definitions sequentially according to the order of the element array, so that the class corresponding to the patch element object is loaded before the class corresponding to the original code.
[0067] Step A23: Extract the patch element object containing the bytecode file from the class loader instance; In practice, a patch element object containing the target bytecode can be extracted from the created DexClassLoader instance. This object stores the bytecode information corresponding to the newly generated repair class, thus completing the data preparation for subsequent insertion operations.
[0068] Step A24: Insert the patch element object into the beginning of the original element array to generate a merged target element array, and write the target element array back into the path list object through reflection to overwrite the original code corresponding to the repair intent object.
[0069] In practice, the patch element object is inserted at the beginning of the array to generate a merged array of target elements. Reflection is then used to write the merged array back to `pathList`. The entire injection process uses a synchronization lock to ensure thread safety and prevent inconsistencies in state caused by concurrent access from multiple threads.
[0070] This embodiment utilizes Android's parent delegation model. When searching for classes, the ClassLoader searches sequentially according to the order of the dexElements array. Therefore, the patch class located at the front of the array will be loaded before the original class, thus achieving runtime replacement at the method level. Subsequent calls to this method will execute the AI-generated patch version.
[0071] The parent delegation model is a class loading delegation mechanism used by the Java Virtual Machine and Android Virtual Machine. When loading a class, the class loader first delegates the loading to its parent loader. This application utilizes the array search order characteristic of this mechanism. When searching for a class, the ClassLoader searches sequentially according to the order of the dexElements array. By inserting the patch Dex at the beginning of the array, the patch class is loaded before the original class, thereby achieving runtime method overriding. This allows the patch class located at the beginning of the array to be loaded before the original class, achieving method-level runtime replacement that takes effect without restarting the application.
[0072] This embodiment provides an application hotfix method. It parses the acquired intent description information to obtain a structured fix intent object; constructs structured prompts based on the fix intent object; and infers from the structured prompts to generate target code fragments. The target code fragments are then compiled to generate corresponding bytecode files. These bytecode files are injected into the current application to overwrite the original code corresponding to the fix intent object. By decentralizing code generation capabilities to the client-side, directly generating target code fragments using structured prompts, and completing compilation and injection locally, the steps of manually writing patch code and distributing pre-compiled artifacts in the cloud are eliminated. This shortens the fix chain, improves response efficiency, and enhances the security and accuracy of application hotfixes.
[0073] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in Embodiment 1 above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 2Step S10 includes steps S101 to S102: Step S101: Parse the obtained intent description information to obtain the keyword information in the intent description information and the list of interfaces to be called declared in the intent description information.
[0074] It should be noted that after the edge device receives the intent description information sent from the cloud, it first needs to extract the core elements used to drive code generation from the text.
[0075] Keyword information refers to semantic fields that can uniquely identify the repair target and the expected behavior, such as the fully qualified class name of the target (targetClass), the name of the target method (targetMethod), the method signature (methodSignature), and the behavior change description (behavior).
[0076] The list of APIs to be called refers to the set of APIs (allowedApis) explicitly declared in the intent description information that are allowed to be called in the patch code. This list forms the basic boundary for subsequent security checks.
[0077] In practical implementation, the intent description information can be parsed using a JSON parser or a DSL parser, converting the unstructured text stream into key-value pairs or temporary data containers in memory. By adopting a processing order of extraction followed by validation, the original transmission format and internal business objects are decoupled, allowing subsequent validation logic to evolve independently of the data format. This also facilitates the rapid identification of low-level errors such as missing fields during the extraction phase, avoiding resource waste caused by directly passing incomplete raw text into a complex validation engine.
[0078] In practice, after receiving the intent description pushed from the cloud, the edge device first decrypts it, and then the IntentParser module parses the JSON text into a structured PatchIntent object. After obtaining the keyword information and the list of interfaces to be called, multi-level verification can be performed, and those that pass the verification are used as intent repair objects.
[0079] Step S102: Verify the keyword information and the list of interfaces to be called to obtain a structured intent repair object.
[0080] It should be noted that only after the verification is passed will these discrete fields be encapsulated into structured intent repair objects (such as PatchIntent objects) to ensure that the input data entering the downstream AI inference and compilation process is complete and compliant.
[0081] For example, if the parsing process finds that the required target class name field is missing, or the list of interfaces to be called is empty, the system will immediately trigger the exception handling mechanism, terminate the current repair task and generate an error log, thus ensuring the stability of the automated generation process on the client side.
[0082] In one feasible implementation, step S102 may include steps B11-B13: Step B11: Perform basic information verification on the keyword information to obtain the basic information verification result; It's important to note that the basic information verification focuses on confirming the functional completeness and syntactic validity of the repair intent, aiming to address the question of "can it be repaired?". For example, this verification process checks whether key fields such as the target class name and method name are not empty, whether the string format conforms to Java naming conventions, and whether the behavioral description possesses basic semantic integrity. Only when these fundamental elements meet the preset engineering standards can the basic information verification result be considered passed, thus ensuring that the input received by the subsequent AI model is a structurally complete and correctly parsed program semantic, rather than incomplete or garbled text.
[0083] In one feasible implementation, step B11 may include: obtaining class name information, method name information, and behavior description information from the keyword information; Determine whether the class name information is consistent with the target class name, whether the method name information is consistent with the target method name, and whether the behavior description information is consistent with the target behavior description, wherein the target class name, the target method name, and the target behavior description are information in the key fields required to perform hotfix; If the class name information is consistent with the target class name, the method name information is consistent with the target method name, and the behavior description information is consistent with the target behavior description, the string format of the class name information is matched and detected. If the string format of the class name information conforms to the preset naming convention, the basic information verification result is determined to be successful.
[0084] In practice, a dual verification mechanism of content consistency and format compliance ensures that the remediation intent can accurately pinpoint the specific code entity in the application. During verification, three core elements are first extracted from the parsed keyword information: class name, method name, and behavior description. These extracted elements are then compared one by one with the pre-defined or context-defined target class name, target method name, and target behavior description. The target field represents the baseline of the object that the current hotfix task actually expects to modify; it can be a standard definition from application metadata or a standard reference value carried when the intent is issued from the cloud.
[0085] Only when the extracted information is completely consistent with the target information in terms of content can it be considered that the intent semantically points to a real and correct object to be repaired. For example, if the intent description declares that it is repairing the "login" method of the "com.example.app.UserManager" class, and the corresponding target class name in the system is indeed "com.example.app.UserManager" and the target method name is "login", then the content consistency check passes.
[0086] After confirming content consistency, the string format of the class name information is further matched and checked to verify whether it conforms to the preset naming conventions of the programming language and runtime environment. In this embodiment, the preset naming convention uses the regular expression [a-zA-Z][a-zA-Z0-9_.]. In other implementations, equivalent format validation logic can be used based on the syntax rules of the target operating platform. For example, the regular expression pattern or validation algorithm can be adjusted for Kotlin, C++, or other language environments, as long as the filtering function for illegal identifiers can be achieved. Regular expression matching is used to verify whether the class name conforms to the preset naming conventions.
[0087] If both field integrity and type validity checks pass, then the basic information verification result is considered successful.
[0088] Step B12: Perform security constraint verification on the list of interfaces to be called, and obtain the security constraint verification result; It's important to note that security constraint verification focuses on verifying the compliance and risk controllability of remediation actions, aiming to address whether remediation is permitted. In scenarios where code is generated autonomously on the client side, the list of APIs to be called declared in the intent description is compared one by one with a pre-defined security whitelist to confirm that all APIs to be called are within the trusted scope. If any high-risk system interfaces outside the whitelist or unauthorized sensitive permission calls are found, the security constraint verification result will be directly judged as failing. This design intercepts security risks before code generation, effectively preventing malicious code injection risks caused by tampering with the intent description or misconfiguration.
[0089] In one feasible implementation, step B12 may include: traversing the list of interfaces to be called and comparing each interface in the list of interfaces to be called with a preset interface whitelist; If all interfaces in the list of interfaces to be called exist in the interface whitelist, the security constraint verification result is determined to be successful. If any of the interfaces in the list of interfaces to be called does not exist in the interface whitelist, the security constraint verification result is determined to be verification failure.
[0090] The pre-defined interface whitelist is the core benchmark for security constraints, defining the set of application programming interfaces (APIs) that the edge device is allowed to call when performing hotfixes. This whitelist can originate from a static configuration file pre-built locally when the application is packaged, or from a remote configuration that is distributed by a cloud configuration center along with graph description information or dynamically updated at runtime.
[0091] During the validation process, each element in the list of interfaces to be called is iterated and compared one by one with a pre-defined interface whitelist. The security constraint validation is considered successful only if all interfaces in the list have a corresponding entry in the whitelist. Conversely, if any interface in the list is not registered in the whitelist, the security constraint validation is considered unsuccessful regardless of the validity of the other interfaces, and the subsequent code generation process is terminated.
[0092] Step B13: If both the basic information verification result and the security constraint verification result pass the verification, the keyword information is encapsulated into a structured intent repair object.
[0093] In practice, after the verification is passed, the PatchIntent object is passed to the subsequent AI code generation module.
[0094] If any verification dimension fails, an abnormal termination policy will be triggered, halting the subsequent prompt word construction and code generation process. Log information containing the specific reasons for the failure will be generated for troubleshooting. Through this rigorous source filtering mechanism, this embodiment not only ensures that the intended objects entering the downstream compilation pipeline possess both functional correctness and security compliance, but also significantly improves the overall stability and security boundary control capabilities of the edge-side hotfix system, providing a reliable foundation of trust for automated repair processes without human intervention.
[0095] This embodiment parses the acquired intent description information to obtain keyword information and a list of interfaces to be called declared in the intent description information; it then verifies the keyword information and the list of interfaces to be called to obtain a structured intent repair object. By extracting and double-verifying the key elements in the intent description information, the integrity and compliance of the input data on which subsequent code generation is based are ensured, providing a reliable structured foundation for automated generation on the client side.
[0096] Based on the first embodiment of this application, in the third embodiment of this application, the content that is the same as or similar to that in the first embodiment described above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 3Step S30 includes steps S301 to S303: Step S301: Parse the target code fragment into a compilation unit.
[0097] Understandably, since edge devices, such as Android devices, do not have a system-level javac compiler process (and cannot call javac via Runtime.exec()), this embodiment uses Eclipse JDT Core as the edge compilation engine. JDT Core is a compiler implemented entirely in pure Java, which can run directly on the Dalvik / ART virtual machine without needing to call an external process via Runtime.exec().
[0098] In practice, the compilation process is divided into two stages: the first stage is AST parsing and syntax checking, which involves first parsing the Java source code into compilation units using ASTParser.
[0099] Step S302: Detect whether there are syntax errors in the compilation unit.
[0100] Understandably, it can detect whether there are syntax errors in the compilation unit, such as undefined variables, missing syntax symbols, mismatched brackets, and other basic syntax problems. At the same time, it will collect error type and location information to generate a diagnostic report.
[0101] Step S303: If there are no syntax errors in the compilation unit, compile the target code segment into a bytecode array, and obtain the corresponding bytecode file based on the bytecode array.
[0102] If a syntax error is detected in the compilation unit, the process is terminated and a compilation failure message is reported to the cloud.
[0103] In practice, once it is confirmed that there are no syntax errors in the compilation unit, the JDT compiler will start the code generation process, compile the source code into standard .class bytecode through the JDT's internal Compiler class, and output it as a byte[] array, thus obtaining the bytecode file.
[0104] In one feasible implementation, step S303 may include steps C11-C14: Step C11: If there are no syntax errors in the compilation unit, compile the target code segment into a bytecode array; It should be noted that if there are no syntax errors in the compilation unit, the bytecode array can be obtained from the .class bytecode generated by JDT compilation.
[0105] Step C12: Convert the bytecode of the first preset version in the bytecode array into the bytecode of the second preset version, to obtain a version-converted bytecode array, wherein the first preset version is higher than the second preset version; In scenarios where code is generated autonomously on the client side, compiler components integrated into the application (such as Eclipse JDTCore) are typically configured to support newer Java language specifications (such as Java 11 or Java 17) to correctly parse and compile code generated by AI models that includes modern syntax features. However, mobile terminal devices suffer from severe operating system fragmentation, with many devices running Android systems that only support lower bytecode formats (such as Java 8 or earlier).
[0106] If bytecode generated by a higher-version compiler is directly injected into a lower-version runtime environment, the virtual machine will throw a VerifyError exception when performing class verification because it cannot recognize the new instruction set or the class file version number is too high, causing hotfix to fail. Therefore, this embodiment introduces a version downgrade conversion mechanism, converting the first preset version bytecode representing the higher language specification into the second preset version bytecode representing the lower language specification. This conversion process is often called "desugaring," and its core principle is to rewrite the high-version syntax features at the bytecode level into an equivalent implementation that the low-version virtual machine can understand. For example, converting lambda expressions into anonymous inner class calls, converting the Stream API into traditional loop iteration logic, or converting the time API under the java.time package into calls to third-party compatibility libraries.
[0107] Specifically, Java 8+ features such as lambda expressions and method references are converted into compatible low-version bytecode to ensure that the generated Dex can be executed correctly at all target API levels.
[0108] Step C13: Optimize the bytecode of the version conversion to obtain optimized bytecode; In practical implementation, the bytecode for version conversion can be optimized. For example, constant folding (compile-time calculation of constant expressions) can be implemented, which means that the result of the constant expression is directly calculated at compile time and the value is embedded in the instruction to avoid repeated calculation at runtime; dead code elimination is used to remove redundant logic or code branches that may be generated by artificial intelligence models; and method inlining is used to embed frequently called small method bodies directly into the call site to reduce stack frame switching overhead.
[0109] Step C14: Generate a bytecode file that conforms to a preset specification based on the optimized bytecode.
[0110] Finally, a bytecode file conforming to a preset specification is generated based on the optimized bytecode. This preset specification refers to the binary file format standard required by the target runtime environment, such as the DEX (DalvikExecutable) format for the Android platform. This file not only contains the downgraded and optimized executable code but also encapsulates necessary metadata such as class definition indexes, string constant pools, and type reference tables, making it an independent and complete loading unit.
[0111] The above process converts standard Java bytecode into a .dex format executable by the Dalvik virtual machine. Traditional solutions complete the compilation process on the developer's PC (using the Android SDK's javac+dex toolchain), and patches are distributed to the client as pre-compiled .dex files. This application integrates compilation capabilities directly into the app, leveraging JDTCore's pure Java features to complete runtime compilation within the app sandbox, enabling the client to have autonomous "source code -> bytecode" compilation capabilities without relying on a PC-side toolchain.
[0112] In one possible implementation, after step S302, the method further includes: If a syntax error exists in the compilation unit, determine the type and location of the compilation error, and generate a code snapshot; A compilation failure log is generated based on the compilation error type, the error location, the code snapshot, and the intent description information; The compilation failure log will be reported.
[0113] In scenarios where code is generated autonomously on the edge, compilation failures are a common occurrence in engineering, as the output of AI models has a certain degree of probability and unpredictability. When a syntax error is confirmed in a compilation unit, the error type and location are extracted from the compiler's problem diagnosis interface. The error type includes not only the underlying error code but also semantic classification labels, such as missing syntax structure, undefined symbols, type mismatch, or illegal modifiers, to facilitate automated attribution analysis in the cloud. The error location is precisely recorded down to the line number, column number, and even the node path of the abstract syntax tree in the source code, providing spatial coordinates for problem reproduction. Crucially, a code snapshot is generated simultaneously, which fully preserves the original target code fragment actually output by the AI model during this inference.
[0114] In practice, when errors are detected during compilation, such as syntax errors, type mismatches, or references to undeclared symbols in AI-generated code, the patch generation process is terminated, and the compilation failure information is reported to the cloud. The reported information includes: the compilation error type and message, the error's location in the source code (line number, column number), a complete snapshot of the AI-generated code, and the original intent description. Operations personnel can view the failure details in the cloud management backend, adjust the intent description or constraint parameters, and then resubmit the code. This ensures the security of the edge-side compilation pipeline: any code that does not conform to Java syntax specifications or cannot be compiled will not enter the subsequent Dex conversion and hot reloading stages, eliminating the risk of invalid code being injected into the runtime from the source.
[0115] This embodiment parses the target code fragment into compilation units; detects whether there are syntax errors in the compilation units; if there are no syntax errors in the compilation units, compiles the target code fragment into a bytecode array, and obtains the corresponding bytecode file based on the bytecode array. By integrating syntax parsing and compilation capabilities on the client side, and using a parsing-then-compile strategy, it ensures that only syntactically correct code fragments are converted into executable bytecode, preventing invalid code from entering the runtime environment.
[0116] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the application of the thermal repair method. Any simple modifications based on this technical concept are within the protection scope of this application.
[0117] This application also provides an application of a thermal repair device; please refer to [reference needed]. Figure 4 The application of the thermal repair device includes: The parsing module 10 is used to parse the acquired intent description information to obtain a structured repair intent object.
[0118] The construction module 20 is used to construct structured prompt words based on the repair intent object, and to infer from the structured prompt words to generate target code fragments.
[0119] The compilation module 30 is used to perform syntax compilation on the target code fragment to generate the corresponding bytecode file.
[0120] The injection module 40 is used to inject the bytecode file into the current application to overwrite the original code corresponding to the repair intent object.
[0121] The application hotfix device provided in this application, employing the application hotfix method described in the above embodiments, can solve the technical problem that current application fixation schemes rely on manually written patch code, resulting in low security and determinism of the generated code. Compared with the prior art, the beneficial effects of the application hotfix device provided in this application are the same as those of the application hotfix method described in the above embodiments, and other technical features of the application hotfix device are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0122] In one feasible implementation, the parsing module 10 is further configured to parse the acquired intent description information to obtain keyword information in the intent description information and a list of interfaces to be called declared in the intent description information. The keyword information and the list of interfaces to be called are validated to obtain a structured intent repair object.
[0123] In one feasible implementation, the parsing module 10 is further used to perform basic information verification on the keyword information to obtain the basic information verification result; Perform security constraint verification on the list of interfaces to be called, and obtain the security constraint verification result; If both the basic information verification result and the security constraint verification result pass the verification, the keyword information is encapsulated into a structured intent repair object.
[0124] In one feasible implementation, the parsing module 10 is further used to obtain class name information, method name information, and behavior description information from the keyword information; Determine whether the class name information is consistent with the target class name, whether the method name information is consistent with the target method name, and whether the behavior description information is consistent with the target behavior description, wherein the target class name, the target method name, and the target behavior description are information in the key fields required to perform hotfix; If the class name information is consistent with the target class name, the method name information is consistent with the target method name, and the behavior description information is consistent with the target behavior description, the string format of the class name information is matched and detected. If the string format of the class name information conforms to the preset naming convention, the basic information verification result is determined to be successful.
[0125] In one feasible implementation, the parsing module 10 is further configured to traverse the list of interfaces to be called and compare each interface in the list of interfaces to be called with a preset interface whitelist. If all interfaces in the list of interfaces to be called exist in the interface whitelist, the security constraint verification result is determined to be successful. If any of the interfaces in the list of interfaces to be called does not exist in the interface whitelist, the security constraint verification result is determined to be verification failure.
[0126] In one feasible implementation, the construction module 20 is further configured to determine the corresponding structured prompt word template based on the intent type corresponding to the repair intent object; The repair intent object is parsed to generate prompt words containing class information segment, behavior description segment, constraint segment and output format segment; The prompt words are filled into the structured prompt word template to obtain structured prompt words.
[0127] In one feasible implementation, the compilation module 30 is further configured to parse the target code fragment into a compilation unit; Detect whether there are syntax errors in the compilation unit; If there are no syntax errors in the compilation unit, the target code fragment is compiled into a bytecode array, and the corresponding bytecode file is obtained based on the bytecode array.
[0128] In one feasible implementation, the compilation module 30 is further configured to compile the target code segment into a bytecode array if there are no syntax errors in the compilation unit; The bytecode of the first preset version in the bytecode array is converted into the bytecode of the second preset version to obtain a version-converted bytecode array, wherein the first preset version is higher than the second preset version; The converted bytecode of the aforementioned version is optimized to obtain optimized bytecode; Generate a bytecode file that conforms to a preset specification based on the optimized bytecode.
[0129] In one feasible implementation, the compiled module 30 is further configured to determine the type and location of the compilation error and generate a code snapshot when a syntax error exists in the compilation unit; A compilation failure log is generated based on the compilation error type, the error location, the code snapshot, and the intent description information; The compilation failure log will be reported.
[0130] In one feasible implementation, the injection module 40 is further configured to write the bytecode file to the private directory of the current application and construct a class loader instance for loading the bytecode file. The path list object in the current application's default class loader is obtained through reflection, and the original element array containing the original code corresponding to the repair intent object is extracted from the path list object. Extract the patch element object containing the bytecode file from the class loader instance; The patch element object is inserted at the beginning of the original element array to generate a merged target element array. The target element array is then written back to the path list object using reflection to overwrite the original code corresponding to the repair intent object.
[0131] In one feasible implementation, the construction module 20 is further configured to perform constraint verification on the target code segment to determine whether the number of lines of the target code segment exceeds a preset line number threshold and whether the syntax structure of the target code segment is complete. If the number of lines in the target code segment does not exceed a preset line count threshold and the syntax structure is complete, the constraint verification is determined to be successful, and the step of syntactic compilation of the target code segment to generate the corresponding bytecode file is triggered.
[0132] This application provides an application hot-fix device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the application hot-fix method in the first embodiment described above.
[0133] The following is for reference. Figure 5 The diagram illustrates a structural schematic suitable for implementing the application hot-repair device in the embodiments of this application. The application hot-repair device in the embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), tablets, PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 5 The application of thermal repair device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0134] like Figure 5As shown, the application hot-repair device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in ROM (Read Only Memory) 1002 or a program loaded from storage device 1003 into RAM (Random Access Memory) 1004. RAM 1004 also stores various programs and data required for the operation of the application hot-repair device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via bus 1005. Input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to I / O interface 1006: input devices 1007 including, for example, touch screens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, LCDs (Liquid Crystal Displays), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the application thermal repair equipment to communicate wirelessly or wiredly with other devices to exchange data. While the figures show application thermal repair equipment with various systems, it should be understood that implementation or possession of all the systems shown is not required. More or fewer systems may be implemented alternatively.
[0135] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0136] The application hotfix device provided in this application, employing the application hotfix method described in the above embodiments, can solve the technical problem that current application fixation solutions rely on manually written patch code, resulting in low security and determinism of the generated code. Compared with the prior art, the beneficial effects of the application hotfix device provided in this application are the same as those of the application hotfix method described in the above embodiments, and other technical features of this application hotfix device are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0137] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0138] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0139] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the application hot-fix method described in the above embodiments.
[0140] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, RAM (Random Access Memory), ROM (Read Only Memory), EPROM (Erasable Programmable Read Only Memory or Flash Memory), optical fibers, CD-ROM (CD-Read Only Memory), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0141] The aforementioned computer-readable storage medium may be included in the application thermal repair device; or it may exist independently and not assembled into the application thermal repair device.
[0142] The aforementioned computer-readable storage medium carries one or more programs. When the aforementioned one or more programs are executed by the application hotfix device, the application hotfix device causes the following: parsing the acquired intent description information to obtain a structured repair intent object; constructing structured prompt words based on the repair intent object, and inferring from the structured prompt words to generate a target code fragment; performing syntax compilation on the target code fragment to generate a corresponding bytecode file; and injecting the bytecode file into the current application to overwrite the original code corresponding to the repair intent object.
[0143] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including LAN (Local Area Network) or WAN (Wide Area Network)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0144] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0145] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0146] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., computer programs) for executing the above-described application hotfix method. This solves the technical problem in current application fix schemes where patch code is manually written, resulting in low security and determinism of the generated code. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the application hotfix method provided in the above embodiments, and will not be repeated here.
[0147] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the application hotfix method described above.
[0148] The computer program product provided in this application can solve the technical problem that in current application repair solutions, patch code is all written manually, resulting in low security and determinism of the generated code. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the application hot-fix method provided in the above embodiments, and will not be repeated here.
[0149] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.
[0150] This application discloses A1. A method for applying thermal repair, the method comprising: The obtained intent description information is parsed to obtain a structured repair intent object; Based on the repair intent object, a structured prompt word is constructed, and reasoning is performed on the structured prompt word to generate a target code fragment; The target code fragment is syntactically compiled to generate the corresponding bytecode file; The bytecode file is injected into the current application to overwrite the original code corresponding to the repair intent object.
[0151] A2. As described in A1, the step of parsing the acquired intent description information to obtain a structured repair intent object includes: The obtained intent description information is parsed to obtain the keyword information in the intent description information and the list of interfaces to be called declared in the intent description information; The keyword information and the list of interfaces to be called are validated to obtain a structured intent repair object.
[0152] A3. As described in A2, the step of validating the keyword information and the list of interfaces to be called to obtain a structured intent repair object includes: The keyword information is subjected to basic information verification to obtain the basic information verification result; Perform security constraint verification on the list of interfaces to be called, and obtain the security constraint verification result; If both the basic information verification result and the security constraint verification result pass the verification, the keyword information is encapsulated into a structured intent repair object.
[0153] A4. As described in A3, the step of performing basic information verification on the keyword information to obtain the basic information verification result includes: Obtain the class name information, method name information, and behavior description information from the keyword information; Determine whether the class name information is consistent with the target class name, whether the method name information is consistent with the target method name, and whether the behavior description information is consistent with the target behavior description, wherein the target class name, the target method name, and the target behavior description are information in the key fields required to perform hotfix; If the class name information is consistent with the target class name, the method name information is consistent with the target method name, and the behavior description information is consistent with the target behavior description, the string format of the class name information is matched and detected. If the string format of the class name information conforms to the preset naming convention, the basic information verification result is determined to be successful.
[0154] A5. As described in A3, the step of performing security constraint verification on the list of interfaces to be called and obtaining the security constraint verification result includes: Iterate through the list of interfaces to be called and compare each interface in the list with a preset interface whitelist; If all interfaces in the list of interfaces to be called exist in the interface whitelist, the security constraint verification result is determined to be successful. If any of the interfaces in the list of interfaces to be called does not exist in the interface whitelist, the security constraint verification result is determined to be verification failure.
[0155] A6. As described in A1, the step of constructing structured prompt words based on the repair intent object includes: Based on the intent type corresponding to the repair intent object, determine the corresponding structured prompt word template; The repair intent object is parsed to generate prompt words containing class information segment, behavior description segment, constraint segment and output format segment; The prompt words are filled into the structured prompt word template to obtain structured prompt words.
[0156] A7. As described in A1, the step of syntax compiling the target code fragment to generate the corresponding bytecode file includes: The target code fragment is parsed into compilation units; Detect whether there are syntax errors in the compilation unit; If there are no syntax errors in the compilation unit, the target code fragment is compiled into a bytecode array, and the corresponding bytecode file is obtained based on the bytecode array.
[0157] A8. As described in A7, the step of compiling the target code segment into a bytecode array and obtaining the corresponding bytecode file based on the bytecode array, provided that there are no syntax errors in the compilation unit, includes: If there are no syntax errors in the compilation unit, the target code fragment is compiled into a bytecode array; The bytecode of the first preset version in the bytecode array is converted into the bytecode of the second preset version to obtain a version-converted bytecode array, wherein the first preset version is higher than the second preset version; The converted bytecode of the aforementioned version is optimized to obtain optimized bytecode; Generate a bytecode file that conforms to a preset specification based on the optimized bytecode.
[0158] A9. As described in A7, after the step of detecting whether there is a syntax error in the compilation unit, the method further includes: If a syntax error exists in the compilation unit, determine the type and location of the compilation error, and generate a code snapshot; A compilation failure log is generated based on the compilation error type, the error location, the code snapshot, and the intent description information; The compilation failure log will be reported.
[0159] A10. The method as described in any one of A1 to A9, wherein the step of injecting the bytecode file into the current application to overwrite the original code corresponding to the repair intent object includes: Write the bytecode file to the current application's private directory and construct a class loader instance for loading the bytecode file; The path list object in the current application's default class loader is obtained through reflection, and the original element array containing the original code corresponding to the repair intent object is extracted from the path list object. Extract the patch element object containing the bytecode file from the class loader instance; The patch element object is inserted at the beginning of the original element array to generate a merged target element array. The target element array is then written back to the path list object using reflection to overwrite the original code corresponding to the repair intent object.
[0160] A11. The method as described in any one of A1 to A9, after the step of constructing structured prompts based on the repair intent object and inferring from the structured prompts to generate target code fragments, further includes: The target code segment is subjected to constraint verification to determine whether the number of lines in the target code segment exceeds a preset line count threshold and whether the syntax structure of the target code segment is complete; If the number of lines in the target code segment does not exceed a preset line count threshold and the syntax structure is complete, the constraint verification is determined to be successful, and the step of syntactic compilation of the target code segment to generate the corresponding bytecode file is triggered.
[0161] This application also discloses B12. An application thermal repair apparatus, the apparatus comprising: The parsing module is used to parse the acquired intent description information to obtain a structured repair intent object; A construction module is used to construct structured prompts based on the repair intent object, and to infer from the structured prompts to generate target code snippets; The compilation module is used to perform syntax compilation on the target code fragment and generate the corresponding bytecode file; The injection module is used to inject the bytecode file into the current application to overwrite the original code corresponding to the repair intent object.
[0162] B13. The apparatus as described in B12, wherein the parsing module is further configured to parse the acquired intent description information to obtain keyword information in the intent description information and a list of interfaces to be called declared in the intent description information; The keyword information and the list of interfaces to be called are validated to obtain a structured intent repair object.
[0163] B14. The apparatus as described in B13, wherein the parsing module is further configured to perform basic information verification on the keyword information to obtain a basic information verification result; Perform security constraint verification on the list of interfaces to be called, and obtain the security constraint verification result; If both the basic information verification result and the security constraint verification result pass the verification, the keyword information is encapsulated into a structured intent repair object.
[0164] B15. The apparatus as described in B14, wherein the parsing module is further configured to obtain class name information, method name information, and behavior description information from the keyword information; Determine whether the class name information is consistent with the target class name, whether the method name information is consistent with the target method name, and whether the behavior description information is consistent with the target behavior description, wherein the target class name, the target method name, and the target behavior description are information in the key fields required to perform hotfix; If the class name information is consistent with the target class name, the method name information is consistent with the target method name, and the behavior description information is consistent with the target behavior description, the string format of the class name information is matched and detected. If the string format of the class name information conforms to the preset naming convention, the basic information verification result is determined to be successful.
[0165] B16. The apparatus as described in B14, wherein the parsing module is further configured to traverse the list of interfaces to be called and compare each interface in the list of interfaces to be called with a preset interface whitelist; If all interfaces in the list of interfaces to be called exist in the interface whitelist, the security constraint verification result is determined to be successful. If any of the interfaces in the list of interfaces to be called does not exist in the interface whitelist, the security constraint verification result is determined to be verification failure.
[0166] B17. The apparatus as described in B12, wherein the construction module is further configured to determine a corresponding structured prompt word template based on the intent type corresponding to the repair intent object; The repair intent object is parsed to generate prompt words containing class information segment, behavior description segment, constraint segment and output format segment; The prompt words are filled into the structured prompt word template to obtain structured prompt words.
[0167] B18. The apparatus as described in B12, wherein the compilation module is further configured to parse the target code fragment into a compilation unit; Detect whether there are syntax errors in the compilation unit; If there are no syntax errors in the compilation unit, the target code fragment is compiled into a bytecode array, and the corresponding bytecode file is obtained based on the bytecode array.
[0168] This application also discloses C19. An application hotfix device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the application hotfix method as described above.
[0169] This application also discloses D20. A storage medium, which is a computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the steps of the application hot-fix method as described above.
Claims
1. A thermal repair method, characterized in that, The application of thermal repair methods includes: The obtained intent description information is parsed to obtain a structured repair intent object; Based on the repair intent object, a structured prompt word is constructed, and reasoning is performed on the structured prompt word to generate a target code fragment; The target code fragment is syntactically compiled to generate the corresponding bytecode file; The bytecode file is injected into the current application to overwrite the original code corresponding to the repair intent object.
2. The method as described in claim 1, characterized in that, The step of parsing the acquired intent description information to obtain a structured repair intent object includes: The obtained intent description information is parsed to obtain the keyword information in the intent description information and the list of interfaces to be called declared in the intent description information; The keyword information and the list of interfaces to be called are validated to obtain a structured intent repair object.
3. The method as described in claim 2, characterized in that, The step of validating the keyword information and the list of interfaces to be called to obtain a structured intent repair object includes: The keyword information is subjected to basic information verification to obtain the basic information verification result; Perform security constraint verification on the list of interfaces to be called, and obtain the security constraint verification result; If both the basic information verification result and the security constraint verification result pass the verification, the keyword information is encapsulated into a structured intent repair object.
4. The method as described in claim 3, characterized in that, The step of performing basic information verification on the keyword information to obtain the basic information verification result includes: Obtain the class name information, method name information, and behavior description information from the keyword information; Determine whether the class name information is consistent with the target class name, whether the method name information is consistent with the target method name, and whether the behavior description information is consistent with the target behavior description, wherein the target class name, the target method name, and the target behavior description are information in the key fields required to perform hotfix; If the class name information is consistent with the target class name, the method name information is consistent with the target method name, and the behavior description information is consistent with the target behavior description, the string format of the class name information is matched and detected. If the string format of the class name information conforms to the preset naming convention, the basic information verification result is determined to be successful.
5. The method as described in claim 3, characterized in that, The step of performing security constraint verification on the list of interfaces to be called and obtaining the security constraint verification result includes: Iterate through the list of interfaces to be called and compare each interface in the list with a preset interface whitelist; If all interfaces in the list of interfaces to be called exist in the interface whitelist, the security constraint verification result is determined to be successful. If any of the interfaces in the list of interfaces to be called does not exist in the interface whitelist, the security constraint verification result is determined to be verification failure.
6. The method as described in claim 1, characterized in that, The steps for constructing structured prompts based on the repair intent object include: Based on the intent type corresponding to the repair intent object, determine the corresponding structured prompt word template; The repair intent object is parsed to generate prompt words containing class information segment, behavior description segment, constraint segment and output format segment; The prompt words are filled into the structured prompt word template to obtain structured prompt words.
7. The method as described in claim 1, characterized in that, The step of syntactically compiling the target code fragment to generate the corresponding bytecode file includes: The target code fragment is parsed into compilation units; Detect whether there are syntax errors in the compilation unit; If there are no syntax errors in the compilation unit, the target code fragment is compiled into a bytecode array, and the corresponding bytecode file is obtained based on the bytecode array.
8. A device for applying thermal repair, characterized in that, The device includes: The parsing module is used to parse the acquired intent description information to obtain a structured repair intent object; A construction module is used to construct structured prompts based on the repair intent object, and to infer from the structured prompts to generate target code snippets; The compilation module is used to perform syntax compilation on the target code fragment and generate the corresponding bytecode file; The injection module is used to inject the bytecode file into the current application to overwrite the original code corresponding to the repair intent object.
9. A device for applying thermal repair, characterized in that, The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the applied hot-fix method as described in any one of claims 1 to 7.
10. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the application hot-repair method as described in any one of claims 1 to 7.
