CN112068814A - Method, device, system and medium for generating executable file - Google Patents

Method, device, system and medium for generating executable file Download PDF

Info

Publication number
CN112068814A
CN112068814A CN201910495960.2A CN201910495960A CN112068814A CN 112068814 A CN112068814 A CN 112068814A CN 201910495960 A CN201910495960 A CN 201910495960A CN 112068814 A CN112068814 A CN 112068814A
Authority
CN
China
Prior art keywords
attribute
code
executable file
obtaining
key
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910495960.2A
Other languages
Chinese (zh)
Inventor
陈晓军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201910495960.2A priority Critical patent/CN112068814A/en
Publication of CN112068814A publication Critical patent/CN112068814A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The present disclosure provides a method for generating an executable file, including: the method comprises the steps of constructing original codes, setting attribute variables of the original codes to be dynamic types, constructing execution codes and adding the execution codes to the original codes, and generating an executable file according to the original codes, wherein the execution codes are constructed and added to the original codes, so that when the executable file is operated, key value pairs of the attribute variables are added to a specific object in response to setting operation for obtaining the attribute values of the attribute variables, the key value pairs comprise key names corresponding to the attribute variables and the attribute values to be set by the setting operation, and when the executable file is operated, in response to obtaining operation for obtaining the attribute values of the attribute variables, the attribute values corresponding to the key names are obtained from the specific object according to the key names corresponding to the attribute variables. The disclosure also provides a device, a system and a medium for generating the executable file.

Description

Method, device, system and medium for generating executable file
Technical Field
The present disclosure relates to the field of computers, and in particular, to a method, an apparatus, a system, and a medium for generating an executable file.
Background
An executable file refers to a file that can be loaded and executed by an operating system. An executable file is a component of an application that needs to run on the executable file. In different operating system environments, executable programs are presented differently. For example, in the iOS operating system of apple Inc., the file format that can be executed is Mach-O (Mach Object file format).
In the course of implementing the disclosed concept, the inventors found that there are at least the following problems in the prior art: the more complex the business logic and pages of an application are, the larger the data volume of the executable file is, and the larger the storage space occupied by the executable file is. How to reduce the data size of the executable file without affecting business logic and pages is an urgent problem to be solved.
Disclosure of Invention
In view of this, an aspect of the present disclosure provides a method, an apparatus, a system, and a medium for generating an executable file.
One aspect of the present disclosure provides a method of generating an executable file. The method comprises the following steps: the method comprises the steps of constructing original codes, setting attribute variables of the original codes to be dynamic types, constructing execution codes and adding the execution codes to the original codes, and generating an executable file according to the original codes, wherein the execution codes are constructed and added to the original codes, so that when the executable file is operated, key value pairs of the attribute variables are added to a specific object in response to setting operations for obtaining the attribute values of the attribute variables, the key value pairs comprise key names corresponding to the attribute variables and attribute values to be set by the setting operations, and when the executable file is operated, in response to obtaining the attribute values of the attribute variables, the attribute values corresponding to the key names are obtained from the specific object according to the key names corresponding to the attribute variables.
According to an embodiment of the present disclosure, the adding the key-value pair of the attribute variable to the specific object includes adding the key-value pair of the attribute variable to the specific object by calling a parse instance method in the runtime mechanism. The obtaining the attribute value corresponding to the key name from the specific object according to the key name corresponding to the attribute variable includes obtaining the attribute value corresponding to the key name from the specific object by calling an analysis instance method in a runtime mechanism and according to the key name corresponding to the attribute variable.
According to an embodiment of the present disclosure, the method for generating an executable file further includes: constructing an error detection code and adding the error detection code into the original code, so that when the executable file runs, in response to the obtained setting operation not being a preset operation, the operation of adding the key value pair of the attribute variable into a specific object is refused to be executed, and error information is generated; and when the executable file runs, in response to the obtained obtaining operation not being a preset operation, refusing to execute the operation of obtaining the attribute value corresponding to the key name, and generating error information.
According to an embodiment of the present disclosure, the method for generating an executable file further includes: constructing a judgment code and adding the judgment code into an original code, so that whether a preset data structure comprises a corresponding relation between an operated attribute variable and a setting operation or an obtaining operation or not is judged when an executable file runs, wherein the preset data structure comprises any one of the following: array, map, list. If the preset data structure comprises the corresponding relation between the operated attribute variable and the setting operation or the obtaining operation, determining the setting operation or the obtaining operation as the preset operation; otherwise, determining that the setting operation or the obtaining operation is not a preset operation.
According to an embodiment of the present disclosure, the execution code and/or the error detection code and/or the judgment code is located in a parent class of a class in which the attribute variable is located.
Another aspect of the present disclosure provides an executable file generation apparatus, including: the device comprises a first building module, a setting module, a second building module and a generating module. The first constructing module is used for constructing the original code. And the setting module is used for setting the attribute variables of the original code into dynamic types. And the second construction module is used for constructing the execution code and adding the execution code to the original code. And the generating module is used for generating an executable file according to the original code. The method comprises the steps of constructing an execution code and adding the execution code into an original code, so that when an executable file is run, in response to a setting operation for obtaining an attribute value of an attribute variable, a key value pair of the attribute variable is added into a specific object, wherein the key value pair comprises a key name corresponding to the attribute variable and the attribute value to be set by the setting operation. And when the executable file runs, responding to the acquisition operation of acquiring the attribute values of the attribute variables, and acquiring the attribute values corresponding to the key names from the specific objects according to the key names corresponding to the attribute variables.
According to an embodiment of the present disclosure, the first building block includes: the adding submodule is used for adding the key value pair of the attribute variable into a specific object by calling an analysis instance method in a runtime mechanism; and the obtaining submodule is used for obtaining an attribute value corresponding to the key name from the specific object according to the key name corresponding to the attribute variable by calling an analysis example method in the runtime mechanism.
According to an embodiment of the present disclosure, the apparatus for generating an executable file further includes: and the third construction module is used for constructing the error detection code and adding the error detection code into the original code, so that when the executable file runs, in response to the fact that the obtained setting operation is not a preset operation, the operation of adding the key value pair of the attribute variable into the specific object is refused to be executed, and error information is generated. And when the executable file runs, in response to the obtained obtaining operation not being a preset operation, refusing to execute the operation of obtaining the attribute value corresponding to the key name, and generating error information.
According to an embodiment of the present disclosure, the apparatus for generating an executable file further includes: a fourth construction module, configured to construct a judgment code and add the judgment code to the original code, so that when the executable file runs, it is judged whether a preset data structure includes a corresponding relationship between an operated attribute variable and a setting operation or an obtaining operation, where the preset data structure includes any one of: array, map, list. If the preset data structure comprises the corresponding relation between the operated attribute variable and the setting operation or the obtaining operation, determining the setting operation or the obtaining operation as the preset operation; otherwise, determining that the setting operation or the obtaining operation is not a preset operation.
According to an embodiment of the present disclosure, the execution code and/or the error detection code and/or the judgment code is located in a parent class of a class in which the attribute variable is located.
Another aspect of the present disclosure provides a system for generating an executable file. The system includes one or more processors, and memory for storing one or more programs. Wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method as described above.
Another aspect of the present disclosure provides a computer-readable storage medium storing computer-executable instructions for implementing the method as described above when executed.
Another aspect of the disclosure provides a computer program comprising computer executable instructions for implementing the method as described above when executed.
According to the embodiment of the disclosure, the original code is constructed and added to the original code to generate the original code by setting the attribute variable of the original code as the dynamic type, and the executable file is generated according to the original code. Therefore, the size of the executable file is reduced and the occupation of the system storage space is reduced under the condition that the setting operation and the obtaining operation of the attribute variables are normal.
Drawings
For a more complete understanding of the present disclosure and the advantages thereof, reference is now made to the following descriptions taken in conjunction with the accompanying drawings, in which:
fig. 1 schematically illustrates an application scenario of a method and an apparatus for generating an executable file according to an embodiment of the present disclosure;
FIG. 2 schematically shows a flow chart of a method of generating an executable file according to an embodiment of the present disclosure;
FIG. 3 schematically shows a flow diagram of a method performed by executing code according to an embodiment of the present disclosure;
FIG. 4 schematically shows a flow diagram of a method of generating an executable file according to another embodiment of the disclosure;
FIG. 5 schematically illustrates a flow diagram of a method of error detection code and judgment code execution in accordance with an embodiment of the present disclosure;
fig. 6 schematically shows a block diagram of a structure of an executable file generation apparatus according to an embodiment of the present disclosure;
FIG. 7 schematically shows a block diagram of a first building block according to an embodiment of the disclosure;
fig. 8 is a block diagram schematically showing a structure of an executable file generation apparatus according to another embodiment of the present disclosure; and
FIG. 9 schematically illustrates a block diagram of a computer system suitable for implementing the above-described method according to an embodiment of the present disclosure.
Detailed Description
Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood that the description is illustrative only and is not intended to limit the scope of the present disclosure. In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the embodiments of the disclosure. It may be evident, however, that one or more embodiments may be practiced without these specific details. Moreover, in the following description, descriptions of well-known structures and techniques are omitted so as to not unnecessarily obscure the concepts of the present disclosure.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The terms "comprises," "comprising," and the like, as used herein, specify the presence of stated features, steps, operations, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, or components.
All terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art unless otherwise defined. It is noted that the terms used herein should be interpreted as having a meaning that is consistent with the context of this specification and should not be interpreted in an idealized or overly formal sense.
Where a convention analogous to "at least one of A, B and C, etc." is used, in general such a construction is intended in the sense one having skill in the art would understand the convention (e.g., "a system having at least one of A, B and C" would include but not be limited to systems that have a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.). Where a convention analogous to "A, B or at least one of C, etc." is used, in general such a construction is intended in the sense one having skill in the art would understand the convention (e.g., "a system having at least one of A, B or C" would include but not be limited to systems that have a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.).
Some block diagrams and/or flow diagrams are shown in the figures. It will be understood that some blocks of the block diagrams and/or flowchart illustrations, or combinations thereof, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the instructions, which execute via the processor, create means for implementing the functions/acts specified in the block diagrams and/or flowchart block or blocks. The techniques of this disclosure may be implemented in hardware and/or software (including firmware, microcode, etc.). In addition, the techniques of this disclosure may take the form of a computer program product on a computer-readable storage medium having instructions stored thereon for use by or in connection with an instruction execution system.
The embodiment of the disclosure provides a method for generating an executable file and a device capable of applying the method. The method comprises the steps of constructing an original code, setting attribute variables of the original code into a dynamic type, constructing an execution code, adding the execution code to the original code, and generating an executable file according to the original code. Wherein the execution code is constructed and added to the original code such that, when the executable file is run, the key-value pair of the attribute variable is added to the specific object in response to a set operation to obtain the attribute value of the attribute variable. The key value pair includes a key name corresponding to an attribute variable and an attribute value to be set by a setting operation, and when the executable file runs, in response to an obtaining operation for obtaining the attribute value of the attribute variable, the attribute value corresponding to the key name is obtained from a specific object according to the key name corresponding to the attribute variable.
Fig. 1 schematically illustrates an application scenario of a method and an apparatus for generating an executable file according to an embodiment of the present disclosure. It should be noted that fig. 1 is only an example of a scenario in which the embodiments of the present disclosure may be applied to help those skilled in the art understand the technical content of the present disclosure, but does not mean that the embodiments of the present disclosure may not be applied to other devices, systems, environments or scenarios.
As shown in fig. 1, the system architecture 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. The terminal devices 101, 102, 103 may have executable files running thereon various applications, such as shopping-type applications, web browser applications, search-type applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 105 may be a server that provides various services, such as a compilation server (for example only). The compilation server may construct a code of the application executable file, compile the code to generate an executable file, and then transmit the executable file to the terminal device.
It should be noted that the method for generating an executable file provided by the embodiment of the present disclosure may be generally executed by the server 105. Accordingly, the executable file generation apparatus provided by the embodiment of the present disclosure may be generally disposed in the server 105. The method for generating the executable file provided by the embodiment of the present disclosure may also be performed by a server or a server cluster different from the server 105 and capable of communicating with the terminal devices 101, 102, 103 and/or the server 105. Accordingly, the executable file generation apparatus provided by the embodiment of the present disclosure may also be disposed in a server or a server cluster different from the server 105 and capable of communicating with the terminal devices 101, 102, 103 and/or the server 105.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Fig. 2 schematically shows a flow chart of a method of generating an executable file according to an embodiment of the present disclosure.
As shown in fig. 2, the method includes operations S210 to S230.
In operation S210, an original code is constructed.
According to an embodiment of the present disclosure, the original code may be, for example, application code written based on the Object-C language. Object-C is usually written as Objective-C or Obj-C or OC, is a language derived from the C language, inherits the characteristics of the C language, and is an Object-oriented programming language for expanding C. The OC language may be used to develop iOS executables.
In operation S220, an attribute variable of the original code is set to a dynamic type.
For the attribute variables of the non-dynamic type, the compiler automatically adds a setting method (setter) and an obtaining method (getter) of the attribute variables in the codes of the executable file during compilation, and the compiler does not automatically add the setter and the getter of the attribute variables after the attribute variables are set to the dynamic type, namely the size of the executable file can be reduced. Based on this principle, in operation S220, the attribute variable in the original code is set to a dynamic type.
In operation S230, execution code is constructed and added to the original code.
In operation S240, an executable file is generated from the original code.
Fig. 3 schematically shows a flow chart of a method performed by executing code according to an embodiment of the present disclosure.
As shown in fig. 3, the execution code performs the following operations S310 to S330 when executing the executable file:
in operation S310, an object is initialized.
The object is a data structure that can store key-value pairs (e.g., < key, value >), and can be read and written by an external method.
According to the embodiment of the present disclosure, the object may be implemented as various data structures such as class (class), structure (struct), linked list, array, and the like.
In operation S320, when an application program is to perform a setting operation on an attribute value of an attribute variable, a key-value pair of the attribute variable is added to a specific object.
The key value pair comprises a key name corresponding to the attribute variable and an attribute value to be set by the setting operation.
According to the embodiment of the present disclosure, the operation S320 may include, for example, obtaining a key name key corresponding to the attribute variable and an attribute value to be set by the setting operation, and then adding a key value pair < key, value > composed of the key and the value to the initialized object. According to an embodiment of the present disclosure, the above-mentioned operation of adding the key-value pair of the attribute variable to a specific object may be implemented, for example, by calling a resolved instance method (resolveInstanceMethod) in a runtime (runtime) mechanism. A resolveInstanceMethod may be called, in which the following method is added via the class _ addMethod function: and adding a key value pair < key, value > into the initialized object, wherein key is the key name corresponding to the attribute variable, and value is the attribute value to be set by the setting operation. If the above method addition is successful, the resolveInstanceMethod is returned YES.
In operation S330, when the application program is to perform an obtaining operation on the attribute value of the attribute variable, an attribute value corresponding to the key name is obtained from the specific object according to the key name corresponding to the attribute variable.
According to the embodiment of the present disclosure, the operation S330 may include, for example, when the application program is to perform an obtaining operation on the attribute value of the attribute variable, first obtaining a key name key of the operated attribute variable, then searching the object for an attribute value corresponding to the key according to the key, and if the corresponding value is successfully found, returning the value.
According to an embodiment of the present disclosure, the operation of obtaining the attribute value corresponding to the key name from the specific object according to the key name corresponding to the attribute variable may be implemented by, for example, calling a resolveInstanceMethod. A resolveInstanceMethod may be called, in which the following method is added via the class _ addMethod function: according to the key of the attribute variable, searching the value corresponding to the key in the object; and if the corresponding value is found successfully, returning the value. If the above method addition is successful, the resolveInstanceMethod is returned YES.
Fig. 4 schematically shows a flow chart of a method of generating an executable file according to another embodiment of the present disclosure.
As shown in fig. 4, the executable file generation method further includes operation S410 before operation S240 based on the foregoing embodiment.
In operation S410, an error detection code and a judgment code are constructed and added to the original code.
FIG. 5 schematically shows a flow diagram of a method of error detection code and judgment code execution according to an embodiment of the disclosure.
As shown in fig. 5, the above-mentioned judgment code is used to perform the following operation S510 when the executable file is executed, and the above-mentioned error detection code is used to perform the following operation S520 when the executable file is executed.
In operation S510, if a setting operation or an obtaining operation is performed on the attribute value of the attribute variable, it is determined whether the setting operation or the obtaining operation is a preset operation.
According to the embodiment of the present disclosure, the operation S510 may include, for example, when performing a setting operation or an obtaining operation on an attribute value of an attribute variable, determining whether a corresponding relationship between the setting operation or the obtaining operation and the operated attribute variable is included in a preset data structure. If the preset data structure comprises the corresponding relation between the operated attribute variable and the setting operation or the obtaining operation, determining the setting operation or the obtaining operation as the preset operation; otherwise, the set operation or the get operation is not a preset operation.
According to an embodiment of the present disclosure, the preset data structure may be an array, a list, a map (map), or the like, for example.
When an executable file written based on the Object-C language runs, each time a setting operation or an obtaining operation is to be performed on a property value of a property variable, a program first looks for a setting or obtaining method of the property variable. Based on the principle, in other embodiments, whether the operation is the preset operation may be determined by determining whether the method required to be called by the operation is the preset method. Specifically, when the program cannot find a method of a certain attribute variable, it may be determined whether the correspondence between the ID of the attribute variable and the ID of the method is included in the preset data structure, according to the ID of the attribute variable and the ID of the found method. And if the preset data structure contains the corresponding relation of the two IDs, determining that the operation corresponding to the method is a preset operation.
In operation S520, in response to the setting operation not being a preset operation, refusing to perform operation S320, and generating error information; and/or refusing to execute the operation S330 and generating error information in response to the acquiring operation not being a preset operation.
According to an embodiment of the present disclosure, the operation S520 may include, for example, in a case where the determination result obtained in the operation S510 is not the preset operation, not performing the operation of S320 or S330, and returning the resolveInstanceMethod to NO to generate the error information.
In summary, according to the embodiments of the present disclosure, on one hand, the attribute variables of the original code are set as dynamic types, and a setting method and an obtaining method for automatically generating the attribute variables by a compiler at a compiling stage are avoided, so that the size of a compiled executable file is reduced, and the problem that an application store cannot be put on shelf due to the fact that the size of the executable file exceeds a limit is at least partially solved. On the other hand, by adding an execution code, an error detection code and a judgment code into the original code, the attribute variables of the executable file runtime can normally carry out setting operation and acquisition operation.
In addition, according to the embodiment of the present disclosure, the execution code, the error detection code, and the judgment code may be located in a parent class of a class in which the attribute variable is located, so that the attribute variable may inherit the execution code, the error detection code, and the judgment code in the parent class and execute the above operations, without writing a corresponding code in the class in which each attribute variable is located, thereby further reducing the size of the executable file.
Fig. 6 schematically shows a block diagram of an executable file generation apparatus 600 according to an embodiment of the present disclosure.
As shown in fig. 6, the executable file generation apparatus 600 includes a first building module 610, a setting module 620, a second building module 630, and a generation module 640.
The first construction module 610 may perform operation S210, for example, for constructing the original code.
The setting module 620 may perform, for example, operation S220 for setting a property variable of the original code to a dynamic type.
The second construction module 630 may perform, for example, operation S230 for constructing the execution code and adding the execution code to the original code. The method comprises the steps of constructing an execution code and adding the execution code into an original code, so that when an executable file is run, in response to a setting operation for obtaining an attribute value of an attribute variable, a key value pair of the attribute variable is added into a specific object, wherein the key value pair comprises a key name corresponding to the attribute variable and the attribute value to be set by the setting operation. And when the executable file runs, responding to the acquisition operation of acquiring the attribute values of the attribute variables, and acquiring the attribute values corresponding to the key names from the specific objects according to the key names corresponding to the attribute variables.
The generating module 640 may perform operation S240, for example, for generating an executable file from the original code.
Fig. 7 schematically illustrates a block diagram of a first building module 610 according to an embodiment of the disclosure.
As shown in fig. 7, the first building block 610 may include an add sub-block 710 and a get sub-block 720.
The adding sub-module 710 is used for adding the key-value pair of the attribute variable to the specific object by calling the parse instance method in the runtime mechanism.
The obtaining submodule 720 is configured to obtain an attribute value corresponding to a key name from a specific object according to the key name corresponding to the attribute variable by calling an analysis instance method in the runtime mechanism.
Fig. 8 schematically shows a block diagram of an apparatus 800 for generating an executable file according to another embodiment of the present disclosure.
As shown in fig. 8, the executable file generating apparatus 800 may further include a third building module 810 and/or a fourth building module 820 based on the foregoing embodiments.
A third constructing module 810, configured to construct an error detection code and add the error detection code to the original code, so that when the executable file runs, in response to that the obtained setting operation is not a preset operation, the operation of adding the key-value pair of the attribute variable to the specific object is rejected, and error information is generated; and when the executable file runs, in response to the obtained obtaining operation not being a preset operation, refusing to execute the operation of obtaining the attribute value corresponding to the key name, and generating error information.
A fourth constructing module 820, configured to construct a judgment code and add the judgment code to the original code, so as to judge whether a preset data structure includes a corresponding relationship between an operated attribute variable and a setting operation or an obtaining operation when the executable file runs, where the preset data structure includes any one of: array, mapping and list; if the preset data structure comprises the corresponding relation between the operated attribute variable and the setting operation or the obtaining operation, determining the setting operation or the obtaining operation as the preset operation; otherwise, determining that the setting operation or the obtaining operation is not a preset operation.
Any number of modules, sub-modules, units, sub-units, or at least part of the functionality of any number thereof according to embodiments of the present disclosure may be implemented in one module. Any one or more of the modules, sub-modules, units, and sub-units according to the embodiments of the present disclosure may be implemented by being split into a plurality of modules. Any one or more of the modules, sub-modules, units, sub-units according to embodiments of the present disclosure may be implemented at least in part as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system on a chip, a system on a substrate, a system on a package, an Application Specific Integrated Circuit (ASIC), or may be implemented in any other reasonable manner of hardware or firmware by integrating or packaging a circuit, or in any one of or a suitable combination of software, hardware, and firmware implementations. Alternatively, one or more of the modules, sub-modules, units, sub-units according to embodiments of the disclosure may be at least partially implemented as a computer program module, which when executed may perform the corresponding functions.
For example, any number of the first building module 610, the setting module 620, the second building module 630, the generating module 640, the adding sub-module 710, the obtaining sub-module 720, the third building module 810, and the fourth building module 820 may be combined and implemented in one module, or any one of them may be split into a plurality of modules. Alternatively, at least part of the functionality of one or more of these modules may be combined with at least part of the functionality of the other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the first building module 610, the setting module 620, the second building module 630, the generating module 640, the adding sub-module 710, the obtaining sub-module 720, and the third building module 810 may be implemented at least partially as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system on a chip, a system on a substrate, a system on a package, an Application Specific Integrated Circuit (ASIC), or may be implemented by hardware or firmware in any other reasonable manner of integrating or packaging a circuit, or implemented by any one of three implementations of software, hardware, and firmware, or in a suitable combination of any of them. Alternatively, at least one of the first building module 610, the setting module 620, the second building module 630, the generating module 640, the adding sub-module 710, the obtaining sub-module 720, and the third building module 810 may be at least partially implemented as a computer program module that, when executed, may perform a corresponding function.
FIG. 9 schematically illustrates a block diagram of a computer system suitable for implementing the above-described method according to an embodiment of the present disclosure. The computer system illustrated in FIG. 9 is only one example and should not impose any limitations on the scope of use or functionality of embodiments of the disclosure.
As shown in fig. 9, a computer system 900 according to an embodiment of the present disclosure includes a processor 901 which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)902 or a program loaded from a storage section 908 into a Random Access Memory (RAM) 903. Processor 901 may comprise, for example, a general purpose microprocessor (e.g., a CPU), an instruction set processor and/or associated chipset, and/or a special purpose microprocessor (e.g., an Application Specific Integrated Circuit (ASIC)), among others. The processor 901 may also include on-board memory for caching purposes. The processor 901 may comprise a single processing unit or a plurality of processing units for performing the different actions of the method flows according to embodiments of the present disclosure.
In the RAM 903, various programs and data necessary for the operation of the system 900 are stored. The processor 901, the ROM 902, and the RAM 903 are connected to each other through a bus 904. The processor 901 performs various operations of the method flows according to the embodiments of the present disclosure by executing programs in the ROM 902 and/or the RAM 903. Note that the programs may also be stored in one or more memories other than the ROM 902 and the RAM 903. The processor 901 may also perform various operations of the method flows according to embodiments of the present disclosure by executing programs stored in the one or more memories.
System 900 may also include an input/output (I/O) interface 905, input/output (I/O) interface 905 also connected to bus 904, according to an embodiment of the present disclosure. The system 900 may also include one or more of the following components connected to the I/O interface 905: an input portion 906 including a keyboard, a mouse, and the like; an output section 907 including components such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 908 including a hard disk and the like; and a communication section 909 including a network interface card such as a LAN card, a modem, or the like. The communication section 909 performs communication processing via a network such as the internet. The drive 910 is also connected to the I/O interface 905 as necessary. A removable medium 911 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 910 as necessary, so that a computer program read out therefrom is mounted into the storage section 908 as necessary.
According to embodiments of the present disclosure, method flows according to embodiments of the present disclosure may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable storage medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 909, and/or installed from the removable medium 911. The computer program, when executed by the processor 901, performs the above-described functions defined in the system of the embodiment of the present disclosure. The systems, devices, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
The present disclosure also provides a computer-readable storage medium, which may be contained in the apparatus/device/system described in the above embodiments; or may exist separately and not be assembled into the device/apparatus/system. The computer-readable storage medium carries one or more programs which, when executed, implement the method according to an embodiment of the disclosure.
According to embodiments of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, which may include, for example but is not limited to: a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. For example, according to embodiments of the present disclosure, a computer-readable storage medium may include the ROM 902 and/or the RAM 903 described above and/or one or more memories other than the ROM 902 and the RAM 903.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
Those skilled in the art will appreciate that various combinations and/or combinations of features recited in the various embodiments and/or claims of the present disclosure can be made, even if such combinations or combinations are not expressly recited in the present disclosure. In particular, various combinations and/or combinations of the features recited in the various embodiments and/or claims of the present disclosure may be made without departing from the spirit or teaching of the present disclosure. All such combinations and/or associations are within the scope of the present disclosure.
The embodiments of the present disclosure have been described above. However, these examples are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although the embodiments are described separately above, this does not mean that the measures in the embodiments cannot be used in advantageous combination. The scope of the disclosure is defined by the appended claims and equivalents thereof. Various alternatives and modifications can be devised by those skilled in the art without departing from the scope of the present disclosure, and such alternatives and modifications are intended to be within the scope of the present disclosure.

Claims (12)

1. A method for generating an executable file comprises the following steps:
constructing an original code;
setting attribute variables of the original code into a dynamic type;
constructing execution code and adding the execution code to the original code; and
generating an executable file according to the original code;
constructing an execution code and adding the execution code into the original code, so that when the executable file is run, in response to a setting operation for obtaining an attribute value of the attribute variable, a key value pair of the attribute variable is added into a specific object, wherein the key value pair comprises a key name corresponding to the attribute variable and the attribute value to be set by the setting operation; and when the executable file runs, responding to the acquisition operation of acquiring the attribute value of the attribute variable, and acquiring the attribute value corresponding to the key name from the specific object according to the key name corresponding to the attribute variable.
2. The method of claim 1, wherein:
adding the key-value pairs of the attribute variables into a specific object, wherein the step of adding the key-value pairs of the attribute variables into the specific object comprises the step of calling an analysis instance method in a runtime mechanism; and
the obtaining the attribute value corresponding to the key name from the specific object according to the key name corresponding to the attribute variable includes obtaining the attribute value corresponding to the key name from the specific object by calling an analysis instance method in a runtime mechanism and according to the key name corresponding to the attribute variable.
3. The method of claim 1 or 2, further comprising:
constructing an error detection code and adding the error detection code to the original code, so that when an executable file runs, in response to the obtained setting operation not being a preset operation, the operation of adding the key value pair of the attribute variable to a specific object is refused to be executed, and error information is generated; and
and when the executable file runs, in response to the fact that the obtained obtaining operation is not a preset operation, refusing to execute the operation of obtaining the attribute value corresponding to the key name, and generating error information.
4. The method of claim 3, further comprising:
constructing a judgment code and adding the judgment code into the original code, so that whether a preset data structure comprises a corresponding relation between an operated attribute variable and the setting operation or the obtaining operation is judged when the executable file runs, wherein the preset data structure comprises any one of the following: array, mapping and list; and
if the preset data structure comprises the corresponding relation between the operated attribute variable and the setting operation or the obtaining operation, determining that the setting operation or the obtaining operation is the preset operation; otherwise, determining that the setting operation or the obtaining operation is not a preset operation.
5. The method of claim 4, wherein the execution code and/or error detection code and/or judgment code is located in a parent of the class in which the attribute variable is located.
6. An executable file generation apparatus, comprising:
the first constructing module is used for constructing an original code;
the setting module is used for setting the attribute variables of the original codes into dynamic types;
the second construction module is used for constructing an execution code and adding the execution code to the original code; and
the generating module is used for generating an executable file according to the original code;
constructing an execution code and adding the execution code into the original code, so that when the executable file is run, in response to a setting operation for obtaining an attribute value of the attribute variable, a key value pair of the attribute variable is added into a specific object, wherein the key value pair comprises a key name corresponding to the attribute variable and the attribute value to be set by the setting operation; and when the executable file runs, responding to the acquisition operation of acquiring the attribute value of the attribute variable, and acquiring the attribute value corresponding to the key name from the specific object according to the key name corresponding to the attribute variable.
7. The apparatus of claim 6, wherein the first building block comprises:
the adding submodule is used for adding the key value pair of the attribute variable into the specific object by calling an analysis instance method in a runtime mechanism; and
and the obtaining submodule is used for obtaining an attribute value corresponding to the key name from the specific object according to the key name corresponding to the attribute variable by calling an analysis example method in a runtime mechanism.
8. The apparatus of claim 6 or 7, further comprising:
a third constructing module, configured to construct an error detection code and add the error detection code to the original code, so that when the executable file runs, in response to that the obtained setting operation is not a preset operation, the execution of an operation of adding the key-value pair of the attribute variable to a specific object is rejected, and error information is generated; and
and when the executable file runs, in response to the fact that the obtained obtaining operation is not a preset operation, refusing to execute the operation of obtaining the attribute value corresponding to the key name, and generating error information.
9. The apparatus of claim 8, further comprising:
a fourth construction module, configured to construct a judgment code and add the judgment code to the original code, so as to judge whether a preset data structure includes a corresponding relationship between an operated attribute variable and the setting operation or the obtaining operation when the executable file runs, where the preset data structure includes any one of: array, mapping and list; and
if the preset data structure comprises the corresponding relation between the operated attribute variable and the setting operation or the obtaining operation, determining that the setting operation or the obtaining operation is the preset operation; otherwise, determining that the setting operation or the obtaining operation is not a preset operation.
10. The apparatus of claim 9, wherein the execution code and/or error detection code and/or judgment code is located in a parent of the class in which the attribute variable is located.
11. An executable file generation system, comprising:
one or more processors;
a storage device for storing one or more programs,
wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method of any of claims 1 to 5.
12. A computer readable storage medium having stored thereon executable instructions which, when executed by a processor, cause the processor to carry out the method of any one of claims 1 to 5.
CN201910495960.2A 2019-06-10 2019-06-10 Method, device, system and medium for generating executable file Pending CN112068814A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910495960.2A CN112068814A (en) 2019-06-10 2019-06-10 Method, device, system and medium for generating executable file

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910495960.2A CN112068814A (en) 2019-06-10 2019-06-10 Method, device, system and medium for generating executable file

Publications (1)

Publication Number Publication Date
CN112068814A true CN112068814A (en) 2020-12-11

Family

ID=73657963

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910495960.2A Pending CN112068814A (en) 2019-06-10 2019-06-10 Method, device, system and medium for generating executable file

Country Status (1)

Country Link
CN (1) CN112068814A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114428823A (en) * 2022-01-28 2022-05-03 北京国电通网络技术有限公司 Data linkage method, device, equipment and medium based on multidimensional variable expression

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114428823A (en) * 2022-01-28 2022-05-03 北京国电通网络技术有限公司 Data linkage method, device, equipment and medium based on multidimensional variable expression

Similar Documents

Publication Publication Date Title
CN111221521B (en) Method, device, computer system and readable storage medium for generating log code
US8806437B2 (en) Automated testing process
CN110955409B (en) Method and device for creating resources on cloud platform
CN110895471A (en) Installation package generation method, device, medium and electronic equipment
CN111427579A (en) Plug-in, application program implementing method and system, computer system and storage medium
CN113127361B (en) Application development method and device, electronic equipment and storage medium
CN112631590B (en) Component library generation method, device, electronic equipment and computer readable medium
CN112328301B (en) Method and device for maintaining consistency of operating environments, storage medium and electronic equipment
US20170242781A1 (en) Efficient Software Testing
US11100233B2 (en) Optimizing operating system vulnerability analysis
CN112965916B (en) Page testing method, page testing device, electronic equipment and readable storage medium
CN112925583B (en) Host application capability extension method, device, equipment and storage medium
US11288170B1 (en) Log analysis debugging without running on real production environment
CN112068814A (en) Method, device, system and medium for generating executable file
CN115982491A (en) Page updating method and device, electronic equipment and computer readable storage medium
CN113535565B (en) Interface use case generation method, device, equipment and medium
CN112506781B (en) Test monitoring method, device, electronic equipment, storage medium and program product
CN115248680A (en) Software construction method, system, device, medium, and program product
CN112395194B (en) Method and device for accessing test platform
CN111796865B (en) Byte code file modification method, device, terminal equipment and medium
CN111142972B (en) Method, apparatus, system, and medium for extending functions of application program
CN114741294A (en) Page debugging method, device, equipment and storage medium
CN113805877A (en) Project engineering construction method and device based on IDEA plug-in
CN113377376A (en) Data packet generation method, data packet generation device, electronic device, and storage medium
CN111859403A (en) Method and device for determining dependency vulnerability, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination