A dynamic-annotation-based result programming method

By using a combination of static and dynamic annotations in distributed applications, with dynamic annotations embedded as string arguments, the problem of coupling between extension logic and business code is solved, enabling real-time hot updates of rules and node routing, thus improving the continuous delivery efficiency of distributed applications.

CN122240074APending Publication Date: 2026-06-19GUANGZHOU YUNBIAO NETWORK TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GUANGZHOU YUNBIAO NETWORK TECH CO LTD
Filing Date
2026-01-29
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

Existing technologies in distributed applications have highly coupled extension logic and business code, making it impossible to perform real-time hot updates without restarting the process, resulting in low efficiency in continuous delivery.

Method used

By writing static and dynamic annotations in the code class file, and embedding dynamic annotations as string arguments in the specified parameter positions, the system first executes the annotation callback at runtime, and then uses the callback result to complete the instantiation or function call, thereby realizing hot rule updates and distributed node routing.

🎯Benefits of technology

Decouple extension logic from business code, improve the continuous delivery efficiency of distributed applications, and enable real-time hot updates of rules and node routing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122240074A_ABST
    Figure CN122240074A_ABST
Patent Text Reader

Abstract

This invention relates to the field of programming paradigm technology and discloses a result-based programming method based on dynamic annotations. The method includes: writing static and dynamic annotations in a code class file; executing the static annotations in the annotated code class file in memory; after completing the preprocessing of the annotated code class file, detecting whether a dynamic annotation exists at a specified parameter position of the call statement in the annotated code class file; executing the callback processing of the dynamic annotations; and using the callback results to implement the execution behavior of the call statement. This invention, without disrupting the original code structure, allows the system to execute annotation callbacks first at runtime, and then use the callback results to complete instantiation or function calls. This enables hot rule updates and distributed node routing, thereby decoupling extended logic from business code and improving the continuous delivery efficiency of distributed applications.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a result programming method based on dynamic annotations, belonging to the field of programming paradigm technology. Background Technology

[0002] Static annotations and dynamic annotations are metaprogramming techniques that have gained increasing attention in distributed system programming paradigms in recent years. Static annotations can be attached during the function definition phase and expanded during the compilation phase to ensure correct execution at runtime. Dynamic annotations, on the other hand, embed string arguments through syntax and are placed at specified parameter positions in function or class constructors. The system executes the callback function bound to the annotation first, and then executes the original statement. Result programming solidifies this order into a paradigm where annotations are executed first, and their results drive subsequent calls. This paradigm is used to implement node routing, parameter adjustment, or logical expansion in distributed environments.

[0003] Currently, if developers need to implement capabilities such as automatic routing to target nodes before a call or on-demand replacement at runtime in distributed applications, they typically rely on decorators, middleware, or explicit proxy encapsulation. These approaches often hardcode the extension logic outside the function body or on the calling side, requiring the same rule to be rewritten in multiple places. When extension requirements change with node roles, business versions, or runtime states, maintainers must modify multiple parts of the source code and redeploy the service simultaneously. Furthermore, decorators or middleware frameworks are generally registered during the startup phase. If a rule needs to be hot-updated, it usually requires restarting the process or reloading the module, which cannot take effect immediately without downtime. As the scale of distributed clusters expands, the coupling of the aforementioned extension logic with business code and the difficulty in hot-updating restrict the efficiency of continuous application delivery.

[0004] Therefore, existing technologies suffer from the drawback of highly coupled extension logic and business code, and the inability to perform real-time hot updates without restarting the process, resulting in a significant reduction in the continuous delivery efficiency of distributed applications in scenarios with frequent rule changes. Summary of the Invention

[0005] This invention provides a result programming method based on dynamic annotations. Its main purpose is to enable the system to execute annotation callbacks first and then use the callback results to complete instantiation or function calls without destroying the original code structure. This achieves hot rule updates and distributed node routing, thereby decoupling the extended logic from the business code and improving the continuous delivery efficiency of distributed applications.

[0006] To achieve the above objectives, the present invention provides a result programming method based on dynamic annotations, comprising:

[0007] Static and dynamic annotations are written in the code class file to obtain an annotated code class file, wherein the dynamic annotations are written in the specified parameter position of the calling statement in the code class file;

[0008] After loading the annotated code class file from external storage into memory, the static annotations in the annotated code class file are executed in memory to complete the preprocessing of the annotated code class file.

[0009] After completing the preprocessing of the annotated code class file, it is checked whether the dynamic annotation exists at the specified parameter position of the call statement in the annotated code class file;

[0010] When the dynamic annotation exists at the specified parameter position of the call statement in the annotated code class file, the callback processing of the dynamic annotation is executed to obtain the callback result;

[0011] The callback result is used to execute the calling statement, thereby completing the result programming of the code class file.

[0012] Optionally, the callback processing of the dynamic annotation to obtain the callback result includes:

[0013] Identify the declaration phase type corresponding to the call statement, wherein the declaration phase type includes function definition type and class constructor type;

[0014] When the type in the declaration phase is a function definition type, the function processing flow is triggered;

[0015] When the type of the declaration phase is a class constructor type, the class-level result programming process is triggered;

[0016] After triggering the function processing flow and the class-level result programming processing flow, the annotation identifier in the specified parameter position of the call statement is parsed;

[0017] Based on the annotation identifier, query the target callback function bound to the dynamic annotation;

[0018] Execute the target callback function to obtain the callback result.

[0019] Optionally, executing the target callback function to obtain the callback result includes:

[0020] Execute the target callback function to generate a dynamic adjustment task for the call statement;

[0021] The dynamic adjustment task includes a dynamic adjustment task for the input parameters and a dynamic adjustment task for the calling target. The dynamic adjustment task for the input parameters includes modifying the input parameters, and the dynamic adjustment task for the calling target includes injecting additional logic, dynamically updating the code structure, and registering runtime hooks.

[0022] Based on the aforementioned dynamic adjustment task, the input parameters and the target of the calling statement are dynamically adjusted to obtain the callback result;

[0023] The dynamic adjustment task is used to dynamically adjust the input entity and the calling target, and the callback result is used to complete the execution behavior of the calling statement, which includes object instantiation and function calling.

[0024] Optionally, the execution of the target callback function to generate the dynamic adjustment task of the calling statement includes:

[0025] The node identifier of the dynamic annotation is parsed through the target callback function;

[0026] The target node in the distributed system is located using the node identifier;

[0027] The target callback function is transmitted to the target node through the underlying network scheduling mechanism;

[0028] The target callback function is executed on the target node to generate a dynamically adjusted task for the call statement.

[0029] Optionally, before executing the callback processing of the dynamic annotation and obtaining the callback result, the method further includes:

[0030] When loading annotated code class files, dynamic annotations are bound to target callback functions through an annotation-callback registration mechanism.

[0031] Update the target callback function of the dynamic annotation without reloading the code class file to change the execution behavior of the call statement.

[0032] Optionally, the step of using the callback result to implement the execution behavior of the calling statement includes:

[0033] Match the call type corresponding to the callback result, wherein the call type includes the call type of class instantiation, the call type of global function, and the call type of script function;

[0034] After obtaining the callback result, the preloading function in the annotated code class file is called to initialize the remaining properties and methods in the annotated code class file;

[0035] After initializing the remaining attributes and methods in the annotated code class file, based on the callback result and the call type, the call statement is assigned values ​​according to a preset definition to obtain new assigned values.

[0036] The object instantiation and function call of the calling statement are executed by assigning new actual parameters, thereby realizing the execution behavior of the calling statement.

[0037] Optionally, the matching of the call type corresponding to the callback result includes:

[0038] Check if a class named with the target symbol has been defined within the file scope of the annotated code class file;

[0039] If a class named after the target symbol has been defined within the file scope, determine the call type of the class instantiation corresponding to the callback result;

[0040] If no class named with the target symbol is defined within the file scope, check if a global function named with the target symbol has been defined within the file scope.

[0041] If a global function named after the target symbol has been defined within the file scope, determine the call type of the global function corresponding to the callback result;

[0042] If no global function named after the target symbol is defined within the file scope, determine the call type of the script function corresponding to the callback result.

[0043] Optionally, the step of writing static and dynamic annotations in the code class file to obtain an annotated code class file includes:

[0044] When defining functions in the code class file in external storage, write static annotations in the top comment area of ​​the code class file;

[0045] Dynamic annotations are embedded as string arguments using a predefined syntax;

[0046] Write the string argument at the specified parameter position of the calling statement in the code class file to write the dynamic annotation in the code class file;

[0047] The static annotations are updated during the compilation phase in memory.

[0048] Optionally, executing the static annotations in the annotated code class file in memory includes:

[0049] Dependency checks, resource preloading, and loading process adjustments are performed on the annotated code class files to execute the static annotations in the annotated code class files.

[0050] Optionally, detecting whether the dynamic annotation exists at a specified parameter position of the call statement in the annotated code class file includes:

[0051] When the annotated code class file begins execution, the location of the specified parameter in the call statement is identified;

[0052] The system queries whether a dynamic annotation matching a preset string exists at the specified parameter location.

[0053] When a dynamic annotation matching a preset string is found at the specified parameter position, it is determined that the dynamic annotation exists at the specified parameter position.

[0054] If no dynamic annotation matching the preset string is found at the specified parameter position, it is determined that the dynamic annotation does not exist at the specified parameter position.

[0055] Compared to the problems described in the background technology, this embodiment of the invention writes static and dynamic annotations in the code class file. Dynamic annotations are embedded as string actual parameters and placed at specified parameter positions, allowing extended logic and business calls to coexist in a single line. This reduces hard-coding and eliminates the need for complex syntax such as nested decorators, enabling code reuse. Annotations can be attached to any function or class object creation. This embodiment executes the static annotations in the annotated code class file in memory to perform resource validity checks, dependency analysis, and dynamic adjustment of the loading process during the loading phase, providing a clear initialization order, resolving the uncertainty of object initialization in distributed systems, and ensuring the readiness of the subsequent runtime environment. This embodiment detects the specified parameters of the call statements in the annotated code class file. The existence of the dynamic annotation at the specified position is determined to prioritize its identification at runtime, ensuring that annotation logic is executed first and dynamic annotations are identified and executed first, thereby ensuring the correctness and consistency of distributed logic. This embodiment of the invention executes the callback processing of the dynamic annotation, allowing the target callback function to gain control over the function definition and class. This enables modification of input parameters, injection of additional logic, dynamic generation or replacement of code structure, and registration of runtime hooks. Low invasiveness is achieved through standard parameter positions, allowing dynamic injection of logic via annotations at runtime without modifying the original code. This embodiment of the invention utilizes the callback result to execute the call statement, assigning the result as a parameter according to the definition for further assignment operations, instantiating or calling related objects, allowing the same rule to be reused in multiple places. Therefore, this invention, without disrupting the original code structure, places the dynamic annotation at a specified parameter position in the call statement, enabling the system to execute the annotation callback first at runtime, and then use the callback result to complete instantiation or function calls. This achieves hot rule updates and distributed node routing, thereby decoupling extended logic from business code and improving the continuous delivery efficiency of distributed applications. Attached Figure Description

[0056] Figure 1 This is a flowchart illustrating a result programming method based on dynamic annotations provided in an embodiment of the present invention.

[0057] Figure 2 The following is an execution flowchart of a result programming method based on dynamic annotations provided in an embodiment of the present invention, which includes dynamic annotation statements.

[0058] Figure 3 A diagram illustrating the static annotations, static definitions, and execution steps of a result programming method based on dynamic annotations provided in an embodiment of the present invention.

[0059] Figure 4 A system diagram of annotation definition and execution for a result programming method based on dynamic annotations provided in an embodiment of the present invention;

[0060] Figure 5 A complete flowchart of the note dynamic annotation in the ObjectSense framework, which is a result programming method based on dynamic annotation provided in an embodiment of the present invention;

[0061] Figure 6 A timing diagram of dynamic annotations in a result programming method based on dynamic annotations provided in an embodiment of the present invention;

[0062] Figure 7 This is a schematic diagram of a module for implementing the result programming system based on dynamic annotations, provided in an embodiment of the present invention.

[0063] The objectives, features, and advantages of this invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0064] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

[0065] This application provides a result programming method based on dynamic annotations. The executing entity of this dynamic annotation-based result programming method includes, but is not limited to, at least one of the following computer devices that can be configured to execute the method provided in this application: a server, a terminal, etc. In other words, the result programming method based on dynamic annotations can be executed by software or hardware installed on a terminal device or a server device. The server includes, but is not limited to, a single server, a server cluster, a cloud server, or a cloud server cluster.

[0066] Reference Figure 1The diagram shown is a flowchart illustrating a result programming method based on dynamic annotations according to an embodiment of the present invention. In this embodiment, the result programming method based on dynamic annotations includes:

[0067] S1. Write static and dynamic annotations in the code class file to obtain an annotated code class file, wherein the dynamic annotations are written in the specified parameter positions of the calling statements in the code class file.

[0068] This invention provides an embodiment of the invention that writes static and dynamic annotations in code class files. Dynamic annotations are embedded as string actual parameters and placed at specified parameter positions, allowing extended logic and business calls to be in the same line, reducing hard-coding and eliminating the need for complex syntax such as nested decorators. This enables code reuse, and annotations can be attached to any function or class object creation.

[0069] The dynamic annotation refers to the annotation expression embedded in the string argument at the specified parameter position, which is used to trigger runtime callbacks. The static annotation refers to the metadata instruction written in quote string form at the top of the code class file or in the function definition line. It is recognized and executed during the file loading stage to complete preprocessing tasks such as dependency analysis, resource validity check and loading process adjustment to ensure that the subsequent runtime logic can be executed correctly. The code class file refers to the source code file used by the user to store static and dynamic annotations.

[0070] In one embodiment of the present invention, the step of writing static and dynamic annotations in a code class file to obtain an annotated code class file includes: when defining functions in the code class file in external storage, writing static annotations in the top comment area of ​​the code class file; embedding dynamic annotations as string arguments using a preset syntax; and writing the string arguments at a specified parameter position in the call statement of the code class file to write the dynamic annotations in the code class file; wherein the static annotations are updated during the compilation phase in memory.

[0071] Wherein, "external storage" refers to persistent storage media, such as disk files, before the code class file is loaded into memory; "function definition" refers to the process of writing function signatures in the code class file; "top comment area" refers to the top position of the line where the function definition is located, used to write static annotations, such as "@accessible" written on the first line above the function and enclosed in quotation marks; "preset syntax" refers to the established syntax format for embedding dynamic annotations as string arguments; "string arguments" refers to the double-quoted text within the first parameter position of the call statement, such as the entire "@peer(master)" in Let result = new n:Person("@peer(master)", ...); "specified parameter position of the call statement" refers to the position of the arguments pre-specified when the function or class constructor is called, such as the position of the first or last argument in the function or class constructor call; "updated during the compilation phase in memory" means that static annotations are expanded during the compilation phase to ensure correct execution at runtime.

[0072] Optionally, when defining functions in the code class file in external storage, the process of writing static annotations in the top comment area of ​​the code class file is as follows: when defining functions in the code class file, the static annotation is written in quote string form at the top line of the function, for example, "@accessible". Further, the process of embedding dynamic annotations as string arguments using preset syntax and writing the string arguments at the specified parameter position of the call statement in the code class file to write the dynamic annotations in the code class file is as follows: the dynamic annotations are embedded as string arguments using the same quote syntax and placed at the specified parameter position of the call statement, for example, "@peer(master)", thereby obtaining an annotated code class file. The static annotations will be expanded during the compilation stage in memory to ensure correct execution at runtime.

[0073] S2. After loading the annotated code class file from external storage into memory, execute the static annotations in the annotated code class file in memory to complete the preprocessing process of the annotated code class file.

[0074] This invention provides a clear initialization order by executing static annotations in the annotated code class file in memory, thereby completing resource validity checks, dependency analysis, and dynamic adjustment of the loading process during the loading phase. This resolves the uncertainty of object initialization in distributed systems and ensures the readiness of the subsequent runtime environment.

[0075] In one embodiment of the present invention, executing the static annotations in the annotated code class file in the memory includes: performing dependency checks, resource preloading, and loading process adjustments on the annotated code class file to execute the static annotations in the annotated code class file.

[0076] The dependency check process refers to the process of analyzing whether other files or modules that the current code class file depends on already exist and whether their versions meet the requirements. The resource preloading process refers to loading the resources that have been checked and confirmed to be available into memory in advance to avoid reloading them at runtime. The loading process adjustment process refers to rearranging the loading order or timing of subsequent files based on the results of dependency checks and resource preloading to ensure that the loading phase is completed smoothly.

[0077] Optionally, the process of performing dependency checks, resource preloading, and loading process adjustments on the annotated code class file to execute the static annotations in the annotated code class file is as follows: During the loading phase, the system sequentially performs three operations on the annotated code class file: first, iterates through the file dependency list to complete dependency checks; then, it preloads the required resources into memory to achieve resource preloading; finally, it dynamically reorders or delays loading based on the dependency check results to complete the loading process adjustment. After the three steps are completed, the static annotations are considered to have been executed, and the file enters the ready state.

[0078] S3. After completing the preprocessing of the annotated code class file, check whether the dynamic annotation exists at the specified parameter position of the call statement in the annotated code class file.

[0079] This invention detects whether the dynamic annotation exists at the specified parameter position of the call statement in the annotated code class file, so as to prioritize the identification of dynamic annotations at runtime, ensure that annotation logic is executed first, and dynamic annotations are identified and executed first, thereby ensuring the correctness and consistency of distributed logic.

[0080] In one embodiment of the present invention, detecting whether the dynamic annotation exists at a specified parameter position of a call statement in the annotated code class file includes: identifying the specified parameter position of the call statement when the annotated code class file starts running; querying the specified parameter position to see if a dynamic annotation matching a preset string exists; determining that the dynamic annotation exists at the specified parameter position when a dynamic annotation matching a preset string exists; and determining that the dynamic annotation does not exist at the specified parameter position when no dynamic annotation matching a preset string exists.

[0081] The preset string refers to an annotation expression string that starts with "@" and conforms to the form "@identifier(parameter)".

[0082] Optionally, starting to run the annotated code class file refers to the first statement execution stage after the code class file has been loaded into memory and the static annotations have been executed. Further, querying whether there is a dynamic annotation matching the preset string at the specified parameter position means that the string at the specified parameter position is subjected to pattern recognition at runtime. If it meets the preset "@identifier(parameter)" format, it is determined that there is a dynamic annotation at that position; otherwise, it is determined that there is no dynamic annotation.

[0083] S4. When the dynamic annotation exists at the specified parameter position of the call statement in the annotated code class file, the callback processing of the dynamic annotation is executed to obtain the callback result.

[0084] This invention provides a way to enable the target callback function to gain control over the function definition and class by executing the callback processing of the dynamic annotation. This allows for modification of input parameters, injection of additional logic, dynamic generation or replacement of code structure, and registration of runtime hooks. The invention achieves low intrusion through standard parameter positions and allows for dynamic injection of logic at runtime via annotations without modifying the original code.

[0085] In one embodiment of the present invention, the step of executing the callback processing of the dynamic annotation to obtain a callback result includes: identifying the declaration phase type corresponding to the call statement, wherein the declaration phase type includes function definition type and class constructor type; when the declaration phase type is function definition type, triggering a function processing flow; when the declaration phase type is class constructor type, triggering a class-level result programming processing flow; after triggering the function processing flow and the class-level result programming processing flow, parsing the annotation identifier in the specified parameter position of the call statement; querying the target callback function bound to the dynamic annotation according to the annotation identifier; and executing the target callback function to obtain a callback result.

[0086] The declaration phase type refers to the declaration category of a function definition or class constructor at the source code level, which determines whether to trigger a function processing flow or a class-level result programming processing flow. The function processing flow refers to the dynamic annotation processing sequence triggered when the declaration phase type is a function definition, which is dedicated to the extended logic of function calls. The class-level result programming processing flow refers to the dynamic annotation processing sequence triggered when the declaration phase type is a class constructor, which is dedicated to the extended logic before class instantiation. The annotation identifier refers to the name part after the "@" symbol in the dynamic annotation string, which is used to uniquely identify an annotation and bind the corresponding target callback function. The target callback function refers to the function pre-bound to a specific annotation identifier and executed at runtime, which is responsible for generating dynamic adjustment tasks and returning callback results.

[0087] In another embodiment of the present invention, executing the target callback function to obtain a callback result includes: executing the target callback function to generate a dynamic adjustment task for the calling statement; wherein the dynamic adjustment task includes a dynamic adjustment task for the input arguments and a dynamic adjustment task for the calling target, the dynamic adjustment task for the input arguments includes modifying the input parameters, and the dynamic adjustment task for the calling target includes injecting additional logic, dynamically updating the code structure, and registering runtime hooks; based on the dynamic adjustment task, dynamically adjusting the input arguments and the calling target of the calling statement to obtain a callback result; wherein the dynamic adjustment task is used to dynamically adjust the input arguments and the calling target, and the callback result is used to complete the execution behavior of the calling statement, the execution behavior including object instantiation and function call.

[0088] The dynamic adjustment task refers to the set of adjustment instructions generated after the target callback function is executed, including the modification of input parameters and the injection of additional logic, code structure updates, or runtime hook registration into the calling target.

[0089] In another embodiment of the present invention, the step of executing the target callback function to generate a dynamic adjustment task for the calling statement includes: parsing the node identifier of the dynamic annotation through the target callback function; locating the target node of the distributed system through the node identifier; transmitting the target callback function to the target node through the underlying network scheduling mechanism; and executing the target callback function on the target node to generate a dynamic adjustment task for the calling statement.

[0090] The node identifier refers to the name part of the dynamic annotation string used to represent the distributed target node, in the example form of master in @peer(master). The underlying network scheduling mechanism refers to the mechanism within the framework that transmits callback functions and related parameters to the network communication and scheduling functions on which the target node depends.

[0091] In another embodiment of the present invention, before executing the callback processing of the dynamic annotation and obtaining the callback result, the method further includes: binding the dynamic annotation and the target callback function through the annotation-callback registration mechanism when loading the annotated code class file; and updating the target callback function of the dynamic annotation to change the execution behavior of the calling statement without reloading the code class file.

[0092] The annotation-callback registration mechanism refers to the internal mechanism that establishes a binding relationship between annotation identifiers and corresponding target callback functions during the loading phase, supporting subsequent runtime lookup and execution. The loading phase refers to the phase in which the annotated code class file is loaded from external storage into memory and immediately enters the static annotation execution phase. In the same phase, the system sequentially completes dependency checks, resource preloading, and loading process adjustments, and completes annotation-callback registration in this phase to prepare for subsequent dynamic annotation triggering.

[0093] S5. Utilize the callback result to execute the call statement, thereby completing the result programming of the code class file.

[0094] In this embodiment of the invention, the execution behavior of the call statement is realized by utilizing the callback result. The result is used as a parameter for further assignment operations according to the definition, and related objects are instantiated or called, so that the same rule can be reused in multiple places.

[0095] In one embodiment of the present invention, the execution of the call statement using the callback result includes: matching the call type corresponding to the callback result, wherein the call type includes the call type of class instantiation, the call type of global function, and the call type of script function; after obtaining the callback result, calling the preloading function in the annotated code class file to initialize the remaining attributes and methods in the annotated code class file; after initializing the remaining attributes and methods in the annotated code class file, based on the callback result and the call type, performing an argument assignment operation on the call statement according to a preset definition to obtain new arguments; and executing the object instantiation and function call of the call statement through the new arguments to realize the execution of the call statement.

[0096] The preloaded function refers to the file-level initialization routine that the system automatically calls after the callback result is returned but before formal instantiation, used to complete the final assembly of object properties and methods; the remaining properties refer to object fields that have not yet been initialized; the remaining methods refer to member functions that have not yet been bound; the preset definition refers to the system's built-in assignment rule table, which takes effect after the callback result is returned but before formal assignment, for example: replacing the specified parameter position of the original call statement with the entire parameter list in the callback result; if the callback result carries additional subsequent arguments, they are appended to the specified parameter position in sequence; if the callback result does not provide subsequent arguments, the remaining parameters of the original call statement are retained unchanged.

[0097] Optionally, the process of calling the preloading function in the annotated code class file to initialize the remaining attributes and methods in the annotated code class file is as follows: the system passes the class reference in the callback result to the preloading function, the preloading function sequentially assigns default values ​​to the remaining attributes, completes the binding of the remaining methods, and returns the ready complete class descriptor; further, the process of assigning values ​​to the actual parameters of the call statement according to the callback result and the call type, and obtaining the new actual parameters, is as follows: the system selects the instantiation or function call path according to the call type, takes the parameter list in the callback result as the actual input parameter, replaces the specified parameter position and its subsequent actual parameters of the original call statement, and forms the new actual parameters; further, the process of executing the object instantiation and function call of the call statement through the new actual parameters to realize the execution behavior of the call statement is as follows: the system takes the new actual parameters as input parameters, executes the corresponding instantiation or function call according to the call type, completes the last step of the result programming, and returns the newly created instance or function result.

[0098] For example, the process of matching the call type corresponding to the callback result is as follows: When executing the statement Let result = n:Person(...), the type of Person is first determined according to the following priority order to determine the specific call logic and execution method: a) Check whether a class named Person has been defined in the current file scope. If a definition exists, Person is regarded as a class and processed according to the instantiation of the class. The specific execution steps are: Let result = new n:Person("@xxx", ...). This operation creates an instance of the Person class and passes the relevant parameters to the instantiation process; b) If no Person class definition exists in the file scope, it is further determined whether a global function named Person exists. If a defined global function exists, it is processed according to the global function call rules. The specific execution steps are: Let result = global n:Add(...); If neither step a nor b is satisfied, Person is regarded as a function in the script scope and executed according to the script function call rules. The specific execution steps are: Let result = script n: Add1(...), the above steps ensure that the calling logic for Person is accurately matched with the actual definition and scope of application in a hierarchical manner, thereby dynamically matching the most suitable calling type.

[0099] It should be noted that, in the application development of distributed systems, a dynamic annotation-driven code deployment and execution method is proposed. This method aims to simplify the development process of distributed applications through dynamic annotations. The core method of this invention includes: deploying code on multiple distributed nodes with a unified code foundation, executing targeted logic according to the different roles of the nodes; defining the names and relationships of distributed nodes through dynamic annotations, so that upper-layer applications can define distributed execution logic without modifying the underlying implementation. This method supports upper-layer application developers to flexibly define different dynamic annotations according to specific needs, which facilitates the configuration of code logic for specific distributed nodes and improves the convenience and scalability of system development.

[0100] In another embodiment of the present invention, matching the call type corresponding to the callback result includes: detecting whether a class named with the target symbol has been defined in the file scope of the annotated code class file; if a class named with the target symbol has been defined in the file scope, determining the call type of the class instantiation corresponding to the callback result; if a class named with the target symbol has not been defined in the file scope, detecting whether a global function named with the target symbol has been defined in the file scope; if a global function named with the target symbol has been defined in the file scope, determining the call type of the global function corresponding to the callback result; if a global function named with the target symbol has not been defined in the file scope, determining the call type of the script function corresponding to the callback result.

[0101] See Figure 2 The diagram shown is an execution flowchart of a result programming method based on dynamic annotations provided in an embodiment of the present invention, which includes dynamic annotation statements. Figure 2 In the ObjectSense language framework, when executing a statement, it determines whether the statement contains dynamic annotations. If the statement contains dynamic annotations, the dynamic annotations are executed sequentially, followed by the statement's own logic. During statement execution, it checks whether the statement contains at least one dynamic annotation. If the statement contains dynamic annotations, they are executed one by one in a predetermined order. After the dynamic annotations are executed, the statement's own logic is processed. Figure 2 The steps described above enable automatic processing of dynamic annotations, thereby optimizing the statement execution flow and functional scalability.

[0102] See Figure 3 The diagram shown illustrates the static annotations, static definitions, and execution steps of a dynamic annotation-based result programming method according to an embodiment of the present invention. Figure 3In the process, step 1: The user defines static annotations (SA) and dynamic annotations (DA) in the code class file (hereinafter referred to as code file A) and marks them in the relevant statements in code file A. For example, certain statements can be marked with SA annotations to indicate the preprocessing logic of the program, while specific runtime behaviors can be defined with DA annotations; step 2: Load code file A. In the code execution environment, code file A is loaded into memory, and static and dynamic annotations begin to take effect; Step 3: The static annotation SA in code file A is executed. At this time, all logic related to static annotations will be processed during the code file loading, such as annotation parsing and preprocessing operations; Step 4: When a statement (hereinafter referred to as S1) in code file A is triggered for execution, the dynamic processing stage begins; Step 5: First, the dynamic annotation DA bound to statement S1 is executed. During the execution of the dynamic annotation, the code execution environment will execute the logic defined in the annotation based on the current context; Step 6: After the execution of the dynamic annotation DA is completed, the core logic of statement S1 is returned, and the actual content of statement S1 is executed.

[0103] See Figure 4 The diagram shown is a system diagram of annotation definition and execution in a result programming method based on dynamic annotations provided in an embodiment of the present invention. Figure 4 In this code, based on the ObjectSense language framework, annotation-based code classes are defined. When the program file is loaded, annotations are registered and callback functions are bound to them. When the code is included, the dynamic annotation file is loaded, and the functions of static annotations are executed. When the dynamic annotation statement is executed, the dynamic annotation is executed, and then the statement's logic is executed. Specifically, in... Figure 4In the example, static and dynamic annotations are provided simultaneously within the same code class file: First, the class ApplicationDemo and the class Demo... The static annotation "@accessible" is enclosed in quotes above each line, ensuring it can be attached during function definition. Secondly, the string "@peer(lifter)" appears at the specified parameter position in the class Demo, ensuring the dynamic annotation embeds the string argument and places it at the specified parameter position. Thirdly, the system first identifies the static annotation during program file loading and simultaneously binds the PeerAnnotation class with the "@peer" symbol, ensuring the annotation is registered and bound to the callback function during program file loading. Fourthly, after loading, during the code import phase, the static annotation function S:Preload is executed once for preprocessing such as resource validity checks and dependency analysis. Fifthly, during runtime, when the first argument "@peer(lifter)" is encountered, the framework calls the S:PeerAnnotation callback according to the registered relationship, implementing extensions such as modifying input parameters and injecting additional logic. After the callback returns, the original function body of S:Add continues execution, fully presenting the flow of executing dynamic annotation statements, executing dynamic annotations, and then executing the statement's own logic. Sixthly, the Object on the right... The text executed in the Sense (OSE) environment only indicates that the entire process described above is running within that framework.

[0104] See Figure 5 The diagram shown is a complete flowchart of the note dynamic annotation based on the result programming method provided by an embodiment of the present invention within the ObjectSense framework. Figure 5In this invention, another result programming paradigm that can be used in conjunction with static annotations is the dynamic annotation (note). By defining code classes for annotations and importing dynamic annotation files during code execution, the loading and execution of dynamic and static annotations are achieved. During execution, the dynamic annotation logic is called first, followed by the code logic containing the annotations. This invention ensures the continuity and efficiency of dynamic annotations and the main logic of the statements during execution, thereby achieving efficient collaboration between annotation functionality and code logic. The detailed process is as follows: After the user opens the APP, the system sequentially executes Load ObjectSense, Customize import Command, and CustomizeSourcePost Command to complete environment preparation; then Load HyperCode loads the external micro-annotation definitions, and the APP source code imports the dynamic annotation file through import note Annotation. The framework immediately responds and calls Preload to execute the annotation callback first, then collects all annotations and saves the data; next, the SourcePost command collects all registered annotations within the application, matches the corresponding nodes, executes the callback, and finally returns control and calls Main() to continue the business logic.

[0105] See Figure 6 The diagram shown is a timing diagram of dynamic annotations in a result programming method based on dynamic annotations provided in an embodiment of the present invention. Figure 6The diagram presents the complete execution chain of Let statement-level result programming under the ObjectSense framework: After the user starts the app, it sequentially loads ObjectSense, customizes import Command, loads Hyper Code, and customizes Let statements to complete environment initialization. Then, the app source code imports dynamic annotation files via `import note Annotation`. The framework immediately responds and calls `Preload` to execute annotation callbacks, while simultaneously collecting all annotation data. Next, `Let n:xxx("@xxx",...)` within `Main()` is recognized, and the framework generates extended code in two stages: Step 1 collects registered annotations, matches parameters, and triggers callbacks; Step 2 calls the callback function `s:xxx(..)` and executes the generated result, finally returning and finishing. The above sequence diagram of dynamic annotations has two practical applications: 1. Execution of assignment statements, with explicit and implicit calls following different execution priorities; 2. Execution of script functions without assignment statements. The detailed explanation of method one is as follows: Explicit call format: In a local script file, the annotation-related class or function is called in a formatted way: `Let result = new n:` <classname> ("@ <annotationexpression>", ...), where ClassName represents the class name of the local script file, @ <annotationexpression>This represents an annotation expression; if a global function is called, it is done using the syntax: Let result = global n: <functionname>(...), where FunctionName represents a function defined in the global scope; if a script-scoped function is called, the following structure is executed: Let result = script n: <localfunctionname>(...), where LocalFunctionName represents the function within the scope of the current script file. Among the related parameters, the specified parameter position number must include the annotation expression; otherwise, an error will occur. Implicit call format: This method allows implicit calls implemented based on a dynamic determination mechanism of the call target: Let result = n: <name>(...), its logic consists of the following three steps: 1. If a class with a matching name exists in the local script file, it is processed as a class and converted into an explicit call: Let result = newn: <classname> ("@ <annotationexpression>2. If the local matching class does not exist but a matching function exists in the global scope, it is treated as a global function and converted to an explicit call: Let result = global n: <functionname>(...), 3. If none of the above conditions are met, then it will be processed as a script-scoped function, converted to an explicit call: Let result = script n: <localfunctionname>(...), the dynamic annotation execution mechanism is based on an annotation expression-driven response mechanism. During the call, the annotation expression triggers predefined callback behavior. Simultaneously, the execution result of the annotation response is integrated with subsequent assignment operations. The specific mechanism is as follows: Let result = new n: <classname> ("@ <annotationexpression1> | @ <annotationexpression2>The method involves parsing and executing callbacks in the annotation expression sequentially: executing the response callback functions of all annotation expressions in order (such as @AnnotationExpression1 and @AnnotationExpression2); merging the results after the annotation response and continuing to execute class or function assignment operations; Method two, the process executed in non-assignment statements is as follows: Let n:Add1("@peer(master)", #{x:1, y:2}), the method of executing script functions in non-assignment statements, characterized by the following steps: First, execute the annotation operation corresponding to the specified node (e.g., "master"); then call the script function Add1 and pass it a dictionary parameter containing multiple data items (e.g., #{x:1, y:2}).

[0106] Compared to the problems described in the background technology, this embodiment of the invention writes static and dynamic annotations in the code class file. Dynamic annotations are embedded as string actual parameters and placed at specified parameter positions, allowing extended logic and business calls to coexist in a single line. This reduces hard-coding and eliminates the need for complex syntax such as nested decorators, enabling code reuse. Annotations can be attached to any function or class object creation. This embodiment executes the static annotations in the annotated code class file in memory to perform resource validity checks, dependency analysis, and dynamic adjustment of the loading process during the loading phase, providing a clear initialization order, resolving the uncertainty of object initialization in distributed systems, and ensuring the readiness of the subsequent runtime environment. This embodiment detects the specified parameters of the call statements in the annotated code class file. The existence of the dynamic annotation at the specified position is determined to prioritize its identification at runtime, ensuring that annotation logic is executed first and dynamic annotations are identified and executed first, thereby ensuring the correctness and consistency of distributed logic. This embodiment of the invention executes the callback processing of the dynamic annotation, allowing the target callback function to gain control over the function definition and class. This enables modification of input parameters, injection of additional logic, dynamic generation or replacement of code structure, and registration of runtime hooks. Low invasiveness is achieved through standard parameter positions, allowing dynamic injection of logic via annotations at runtime without modifying the original code. This embodiment of the invention utilizes the callback result to execute the call statement, assigning the result as a parameter according to the definition for further assignment operations, instantiating or calling related objects, allowing the same rule to be reused in multiple places. Therefore, this invention, without disrupting the original code structure, places the dynamic annotation at a specified parameter position in the call statement, enabling the system to execute the annotation callback first at runtime, and then use the callback result to complete instantiation or function calls. This achieves hot rule updates and distributed node routing, thereby decoupling extended logic from business code and improving the continuous delivery efficiency of distributed applications.

[0107] like Figure 7 The diagram shown is a functional block diagram of a result programming system based on dynamic annotations according to the present invention.

[0108] The dynamic annotation-based result programming system 700 described in this invention can be installed in a computer device. Depending on the functions implemented, the dynamic annotation-based result programming system may include an annotation writing module 701, a static execution module 702, an annotation detection module 703, a callback execution module 704, and a result programming module 705. The module described in this invention can also be referred to as a unit, which refers to a series of computer program segments that can be executed by the computer device's processor and perform a fixed function, and are stored in the computer device's memory.

[0109] In this embodiment of the invention, the functions of each module / unit are as follows:

[0110] The annotation writing module 701 is used to write static annotations and dynamic annotations into a code class file to obtain an annotated code class file, wherein the dynamic annotations are written at the specified parameter positions of the calling statements in the code class file;

[0111] The static execution module 702 is used to load the annotated code class file from external storage into memory, and then execute the static annotations in the annotated code class file in memory to complete the preprocessing process of the annotated code class file.

[0112] The annotation detection module 703 is used to detect whether the dynamic annotation exists at the specified parameter position of the call statement in the annotated code class file after the preprocessing process of the annotated code class file is completed.

[0113] The callback execution module 704 is used to execute the callback processing of the dynamic annotation when the dynamic annotation exists at the specified parameter position of the call statement in the annotated code class file, and obtain the callback result.

[0114] The result programming module 705 is used to implement the execution behavior of the call statement using the callback result, so as to complete the result programming of the code class file.

[0115] In detail, the modules in the dynamic annotation-based result programming system 300 described in this embodiment of the invention employ the same methods as described above. Figure 1 The technique used is the same as the dynamic annotation-based programming method described in the previous section, and it can produce the same technical effect, so it will not be repeated here.

[0116] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.

[0117] Finally, it should be noted that in the above embodiments, each embodiment can be combined with each other or independent. Deleting any one of them will not affect the technical implementation of other embodiments. The above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention. < / annotationexpression1> < / classname> < / localfunctionname> < / functionname> < / annotationexpression> < / classname> < / name> < / localfunctionname> < / functionname> < / annotationexpression> < / annotationexpression> < / classname>

Claims

1. A result programming method based on dynamic annotations, characterized in that, The method includes: Static and dynamic annotations are written in the code class file to obtain an annotated code class file, wherein the dynamic annotations are written in the specified parameter position of the calling statement in the code class file; After loading the annotated code class file from external storage into memory, the static annotations in the annotated code class file are executed in memory to complete the preprocessing of the annotated code class file. After completing the preprocessing of the annotated code class file, it is checked whether the dynamic annotation exists at the specified parameter position of the call statement in the annotated code class file; When the dynamic annotation exists at the specified parameter position of the call statement in the annotated code class file, the callback processing of the dynamic annotation is executed to obtain the callback result; The callback result is used to execute the calling statement, thereby completing the result programming of the code class file.

2. The result programming method based on dynamic annotations as described in claim 1, characterized in that, The callback processing for executing the dynamic annotation, and obtaining the callback result, includes: Identify the declaration phase type corresponding to the call statement, wherein the declaration phase type includes function definition type and class constructor type; When the type in the declaration phase is a function definition type, the function processing flow is triggered; When the type of the declaration phase is a class constructor type, the class-level result programming process is triggered; After triggering the function processing flow and the class-level result programming processing flow, the annotation identifier in the specified parameter position of the call statement is parsed; Based on the annotation identifier, query the target callback function bound to the dynamic annotation; Execute the target callback function to obtain the callback result.

3. The result programming method based on dynamic annotations as described in claim 2, characterized in that, The execution of the target callback function to obtain the callback result includes: Execute the target callback function to generate a dynamic adjustment task for the call statement; The dynamic adjustment task includes a dynamic adjustment task for the input parameters and a dynamic adjustment task for the calling target. The dynamic adjustment task for the input parameters includes modifying the input parameters, and the dynamic adjustment task for the calling target includes injecting additional logic, dynamically updating the code structure, and registering runtime hooks. Based on the aforementioned dynamic adjustment task, the input parameters and the target of the calling statement are dynamically adjusted to obtain the callback result; The dynamic adjustment task is used to dynamically adjust the input entity and the calling target, and the callback result is used to complete the execution behavior of the calling statement, which includes object instantiation and function calling.

4. The result programming method based on dynamic annotations as described in claim 3, characterized in that, The dynamic adjustment task of executing the target callback function to generate the calling statement includes: The node identifier of the dynamic annotation is parsed through the target callback function; The target node in the distributed system is located using the node identifier; The target callback function is transmitted to the target node through the underlying network scheduling mechanism; The target callback function is executed on the target node to generate a dynamically adjusted task for the call statement.

5. The result programming method based on dynamic annotations as described in claim 1, characterized in that, Before obtaining the callback result after executing the callback process of the dynamic annotation, the process further includes: When loading annotated code class files, dynamic annotations are bound to target callback functions through an annotation-callback registration mechanism. Update the target callback function of the dynamic annotation without reloading the code class file to change the execution behavior of the call statement.

6. The result programming method based on dynamic annotations as described in claim 1, characterized in that, The execution of the call statement using the callback result includes: Match the call type corresponding to the callback result, wherein the call type includes the call type of class instantiation, the call type of global function, and the call type of script function; After obtaining the callback result, the preloading function in the annotated code class file is called to initialize the remaining properties and methods in the annotated code class file; After initializing the remaining attributes and methods in the annotated code class file, based on the callback result and the call type, the call statement is assigned values ​​according to a preset definition to obtain new assigned values. The object instantiation and function call of the calling statement are executed by assigning new actual parameters, thereby realizing the execution behavior of the calling statement.

7. The result programming method based on dynamic annotations as described in claim 6, characterized in that, The matching of the call type corresponding to the callback result includes: Check if a class named with the target symbol has been defined within the file scope of the annotated code class file; If a class named after the target symbol has been defined within the file scope, determine the call type of the class instantiation corresponding to the callback result; If no class named with the target symbol is defined within the file scope, check if a global function named with the target symbol has been defined within the file scope. If a global function named after the target symbol has been defined within the file scope, determine the call type of the global function corresponding to the callback result; If no global function named after the target symbol is defined within the file scope, determine the call type of the script function corresponding to the callback result.

8. The result programming method based on dynamic annotations as described in claim 1, characterized in that, The process of writing static and dynamic annotations into the code class file to obtain an annotated code class file includes: When defining functions in the code class file in external storage, write static annotations in the top comment area of ​​the code class file; Dynamic annotations are embedded as string arguments using a predefined syntax; Write the string argument at the specified parameter position of the calling statement in the code class file to write the dynamic annotation in the code class file; The static annotations are updated during the compilation phase in memory.

9. The result programming method based on dynamic annotations as described in claim 1, characterized in that, The static annotations in the annotated code class file executed in memory include: Dependency checks, resource preloading, and loading process adjustments are performed on the annotated code class files to execute the static annotations in the annotated code class files.

10. The result programming method based on dynamic annotations as described in claim 1, characterized in that, The step of detecting whether the dynamic annotation exists at a specified parameter position of the call statement in the annotated code class file includes: When the annotated code class file begins execution, the location of the specified parameter in the call statement is identified; The system queries whether a dynamic annotation matching a preset string exists at the specified parameter location. When a dynamic annotation matching a preset string is found at the specified parameter position, it is determined that the dynamic annotation exists at the specified parameter position. If no dynamic annotation matching the preset string is found at the specified parameter position, it is determined that the dynamic annotation does not exist at the specified parameter position.