CN110673834A - Source code calling method and device, computer equipment and storage medium - Google Patents
Source code calling method and device, computer equipment and storage medium Download PDFInfo
- Publication number
- CN110673834A CN110673834A CN201910901436.0A CN201910901436A CN110673834A CN 110673834 A CN110673834 A CN 110673834A CN 201910901436 A CN201910901436 A CN 201910901436A CN 110673834 A CN110673834 A CN 110673834A
- Authority
- CN
- China
- Prior art keywords
- target
- class
- calling
- implementation method
- source code
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/20—Software design
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
Abstract
The embodiment of the invention discloses a source code calling method, a source code calling device, computer equipment and a storage medium, wherein the method comprises the following steps: determining at least one target class to be called; wherein the target class is a source code class; constructing target calling information according to the target class; the target calling information comprises reference path information and class name information of the target class; and calling the target class through the target calling information. The technical scheme of the embodiment of the invention can simplify the operation flow of calling the source code, improve the efficiency of calling the source code and reduce the learning cost and the maintenance cost of calling the source code.
Description
Technical Field
The embodiment of the invention relates to the technical field of android development, in particular to a source code calling method and device, computer equipment and a storage medium.
Background
In the Android system, there are many Hidden APIs (Application programming interfaces), also called Hidden APIs. The Hidden purpose of the Hidden AP is to prevent the developer from using the incomplete or unstable part of the SDK (Software Development Kit), such as the interface or architecture.
In the actual development process, some Hidden APIs may be required to be called to realize some specific functions or to obtain some specific data. Currently, there are mainly two ways to implement the invocation of the Hidden API: firstly, calling a Hidden API by using a reflection method; second, a fully compiled JAR (Java ARchive) package generated during source code compilation is used, such as a frame.
In the process of implementing the invention, the inventor finds that the prior art has the following defects: if the number or types of hide classes to be called is large, the reflection method needs large workload. Meanwhile, since the reflection method realizes reference through the character string, the problems of wrong reference path or class name spelling and the like are easily caused, the problem troubleshooting difficulty is high, and the maintenance is difficult. When the Hidden API is called in a mode of adding the frame.jar, the frame.jar is compiled, time is consumed, workload is large, complexity is high, and most Android developers cannot master the method skillfully. Jar also causes more compatibility issues, resulting in higher learning and maintenance costs.
Disclosure of Invention
The embodiment of the invention provides a source code calling method, a source code calling device, computer equipment and a storage medium, which are used for simplifying the operation flow of source code calling, improving the efficiency of source code calling and reducing the learning cost and the maintenance cost of source code calling.
In a first aspect, an embodiment of the present invention provides a source code invoking method, including:
determining at least one target class to be called; wherein the target class is a source code class;
constructing target calling information according to the target class; the target calling information comprises reference path information and class name information of the target class;
and calling the target class through the target calling information.
In a second aspect, an embodiment of the present invention further provides a source code invoking device, including:
the target class determination module is used for determining at least one target class to be called; wherein the target class is a source code class;
the calling information construction module is used for constructing target calling information according to the target class; the target calling information comprises reference path information and class name information of the target class;
and the target class calling module is used for calling the target class through the target calling information.
In a third aspect, an embodiment of the present invention further provides a computer device, where the computer device includes:
one or more processors;
storage means for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement the source code invocation methods provided by any of the embodiments of the invention.
In a fourth aspect, an embodiment of the present invention further provides a computer storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the source code invoking method provided in any embodiment of the present invention.
The embodiment of the invention determines at least one source code class to be called as the target class and constructs the target calling information according to the target class, thereby calling the target class through the target calling information, solving the problems of low efficiency, high learning and maintenance cost and the like of the existing source code calling method, simplifying the operation flow of calling the source code, improving the efficiency of calling the source code and reducing the learning cost and the maintenance cost of calling the source code.
Drawings
Fig. 1 is a flowchart of a method for providing examination information according to an embodiment of the present invention;
fig. 2 is a schematic diagram of a source code calling apparatus according to a second embodiment of the present invention;
fig. 3 is a schematic structural diagram of a computer device according to a third embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention.
It is to be further noted that, for the convenience of description, only some but not all of the relevant portions of the invention are shown in the drawings. Before discussing exemplary embodiments in more detail, it should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although a flowchart may describe the operations (or steps) as a sequential process, many of the operations can be performed in parallel, concurrently, or simultaneously. In addition, the order of the operations may be re-arranged. The process may be terminated when its operations are completed, but may have additional steps not included in the figure. The processes may correspond to methods, functions, procedures, subroutines, and the like.
Example one
Fig. 1 is a flowchart of a source code invoking method according to an embodiment of the present invention, where the embodiment is applicable to a case of dynamically invoking system source code, and the method may be executed by a source code invoking apparatus, and the apparatus may be implemented by software and/or hardware, and may be generally integrated in a computer device. Accordingly, as shown in fig. 1, the method comprises the following operations:
s110, determining at least one target class to be called; wherein the target class is a source code class.
The target class may be a hidden API class such as hide class, and the type of the hidden API class belongs to the source code class.
In the embodiment of the present invention, when the system source code is called, at least one target class to be called may be determined first.
S120, constructing target calling information according to the target class; the target calling information comprises reference path information and class name information of the target class.
The reference path information may be package name information to which the target class belongs, and the reference path information and the class name information may jointly form a reference address of the target class.
Correspondingly, after the target class to be called is determined, corresponding target calling information comprising the reference path information and the class name information of the target class can be constructed according to the target class. It should be noted that, the target call information in the embodiment of the present invention is not actual function call information. That is, when generating an apk (Android Package), the system itself cannot call the corresponding target class by the target call information.
In an optional embodiment of the present invention, the constructing target invocation information according to the target class may include: acquiring an implementation method of the target class package; reconstructing each implementation method to obtain a target implementation method; repackaging the target implementation method to obtain a target reconstruction class; compiling the object reconstruction class to obtain an object compilation file; and taking the target compiling file as the target calling information.
The target implementation method may be a method obtained by performing reconstruction according to an implementation method included in the target class. The target restructured class may be built from the target class and may be for classes invoked by the application. The target compiled file may be a compiled file obtained by compiling the target reconstruction class.
Specifically, when the target call information is constructed according to the target class, the implementation method of the target class package may be first obtained, and then each implementation method is reconstructed to obtain the corresponding target implementation method. Further, the target implementation method obtained through reconstruction is packaged again to obtain a target reconstruction class. And finally, compiling the target reconstruction class to obtain a target compilation file serving as target calling information.
In an optional embodiment of the present invention, the reconstructing each of the implementation methods to obtain a target implementation method may include: and taking the method signature included by the implementation method as the method signature of the target implementation method.
Specifically, when reconstructing the implementation methods of the target classes, the method signatures included in the implementation methods may be used as the method signatures of the target implementation methods. That is, the target implementation retains only the declaration data for each implementation. It follows that the target implementation method does not comprise any functional code. If the implementation method of the target class needs to return a value, the target implementation method of the target reconstruction class may return a null value null. The benefits of such a process are: the whole Android system does not need to be compiled, so that the learning cost and the workload are greatly reduced, the content of the target compiled file can be flexibly configured according to different Android versions, and a set of source codes of the Android system of another version does not need to be compiled, so that the flexibility is higher.
In an optional embodiment of the present invention, the using the target compiled file as the target calling information may include: performing dependence processing on the target compiling file according to a set dependence mode; and taking the target compiled file after the dependency processing as the target calling information. Alternatively, the target compilation file may be a JAR format file.
The setting of the dependency mode may be a dependency mode selected according to actual requirements, such as using compileOnly for dependency.
In the embodiment of the present invention, the dependency processing may be performed on the target compiled file according to a set dependency manner, and then the target compiled file after the dependency processing is used as the target call information. The benefits of such a process are: spelling errors can be avoided in the calling process, and therefore maintainability is improved. Meanwhile, the target calling information can be ensured not to participate in the packing process, so that the safety and the compatibility of the apk are improved. When the apk program is deployed in a real system environment, the real system level API can be called according to the target calling information, namely calling of the source code is realized.
S130, calling the target class through the target calling information.
In the embodiment of the invention, after the target calling information is constructed according to the target class, the target class can be called according to the constructed target calling information.
The embodiment of the invention determines at least one source code class to be called as the target class and constructs the target calling information according to the target class, thereby calling the target class through the target calling information, solving the problems of low efficiency, high learning and maintenance cost and the like of the existing source code calling method, simplifying the operation flow of calling the source code, improving the efficiency of calling the source code and reducing the learning cost and the maintenance cost of calling the source code.
Example two
Fig. 2 is a schematic diagram of a source code invoking device according to a second embodiment of the present invention, and as shown in fig. 2, the device includes: a target class determination module 210, a call information construction module 220, and a target class call module 230, wherein:
a target class determination module 210, configured to determine at least one target class to be called; wherein, the target class is a source code class;
a calling information construction module 220, configured to construct target calling information according to the target class; the target calling information comprises reference path information and class name information of the target class;
and a target class calling module 230, configured to call the target class through the target calling information.
The embodiment of the invention determines at least one source code class to be called as the target class and constructs the target calling information according to the target class, thereby calling the target class through the target calling information, solving the problems of low efficiency, high learning and maintenance cost and the like of the existing source code calling method, simplifying the operation flow of calling the source code, improving the efficiency of calling the source code and reducing the learning cost and the maintenance cost of calling the source code.
Optionally, the calling information constructing module 220 includes:
the implementation method acquisition unit is used for acquiring the implementation method of the target class package;
the target implementation method acquisition unit is used for reconstructing each implementation method to obtain a target implementation method;
the target implementation method encapsulation unit is used for repackaging the target implementation method;
a target compiled file obtaining unit, configured to compile the target reconstruction class to obtain a target compiled file;
and the target calling information acquisition unit is used for taking the target compiled file as the target calling information.
Optionally, the target implementation method obtaining unit is configured to: and taking the method signature included by the implementation method as the method signature of the target implementation method.
Optionally, the target call information obtaining unit is configured to: performing dependence processing on the target compiling file according to a set dependence mode; and taking the target compiling file after the dependency processing as the target calling information.
Optionally, the target compilation file is a JAR file.
The source code calling device can execute the source code calling method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method. For details of the technique not described in detail in this embodiment, reference may be made to the source code calling method provided in any embodiment of the present invention.
Since the source code invoking device described above is a device capable of executing the source code invoking method in the embodiment of the present invention, based on the source code invoking method described in the embodiment of the present invention, a person skilled in the art can understand a specific implementation manner of the source code invoking device of the embodiment and various variations thereof, and therefore, how the source code invoking device implements the source code invoking method in the embodiment of the present invention is not described in detail herein. As long as the device used by the source code calling method in the embodiment of the present invention is implemented by those skilled in the art, the scope of the present invention is intended to be protected.
EXAMPLE III
Fig. 3 is a schematic structural diagram of a computer device according to a third embodiment of the present invention. FIG. 3 illustrates a block diagram of a computer device 312 suitable for use in implementing embodiments of the present invention. The computer device 312 shown in fig. 3 is only an example and should not bring any limitations to the functionality and scope of use of the embodiments of the present invention.
As shown in FIG. 3, computer device 312 is in the form of a general purpose computing device. The components of computer device 312 may include, but are not limited to: one or more processors 316, a storage device 328, and a bus 318 that couples the various system components including the storage device 328 and the processors 316.
The computer device 312 may also communicate with one or more external devices 314 (e.g., keyboard, pointing device, camera, display 324, etc.), with one or more devices that enable a user to interact with the computer device 312, and/or with any devices (e.g., network card, modem, etc.) that enable the computer device 312 to communicate with one or more other computing devices. Such communication may occur through an Input/Output (I/O) interface 322. Also, computer device 312 may communicate with one or more networks (e.g., a Local Area Network (LAN), Wide Area Network (WAN), etc.) and/or a public Network, such as the internet, via Network adapter 320. As shown, network adapter 320 communicates with the other modules of computer device 312 via bus 318. It should be appreciated that although not shown in the figures, other hardware and/or software modules may be used in conjunction with the computer device 312, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, Redundant Arrays of Independent Disks (RAID) systems, tape drives, and data backup storage systems, to name a few.
That is, the processing unit implements, when executing the program: determining at least one target class to be called; wherein the target class is a source code class; constructing target calling information according to the target class; the target calling information comprises reference path information and class name information of the target class; and calling the target class through the target calling information.
Example four
An embodiment of the present invention further provides a computer storage medium storing a computer program, where the computer program is used to execute the source code calling method according to any one of the above embodiments of the present invention when executed by a computer processor: determining at least one target class to be called; wherein the target class is a source code class; constructing target calling information according to the target class; the target calling information comprises reference path information and class name information of the target class; and calling the target class through the target calling information.
Computer storage media for embodiments of the invention may employ any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a Read-Only Memory (ROM), an Erasable programmable Read-Only Memory (EPROM) or flash Memory), an optical fiber, a portable compact disc Read-Only Memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, 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.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, Radio Frequency (RF), etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the context of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions without departing from the scope of the invention. Therefore, although the present invention has been described in more detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims (10)
1. A method for calling a source code, comprising:
determining at least one target class to be called; wherein the target class is a source code class;
constructing target calling information according to the target class; the target calling information comprises reference path information and class name information of the target class;
and calling the target class through the target calling information.
2. The method of claim 1, wherein said constructing target invocation information according to said target class comprises:
acquiring an implementation method of the target class package;
reconstructing each implementation method to obtain a target implementation method;
repackaging the target implementation method to obtain a target reconstruction class;
compiling the object reconstruction class to obtain an object compilation file;
and taking the target compiling file as the target calling information.
3. The method of claim 2, wherein reconstructing each of the implementation methods to obtain a target implementation method comprises:
and taking the method signature included by the implementation method as the method signature of the target implementation method.
4. The method according to claim 2, wherein the using the target compilation file as the target calling information includes:
performing dependence processing on the target compiling file according to a set dependence mode;
and taking the target compiled file after the dependency processing as the target calling information.
5. The method of any of claims 2-4, wherein the object compilation file is a Java archive file.
6. A source code calling apparatus, comprising:
the target class determination module is used for determining at least one target class to be called; wherein the target class is a source code class;
the calling information construction module is used for constructing target calling information according to the target class; the target calling information comprises reference path information and class name information of the target class;
and the target class calling module is used for calling the target class through the target calling information.
7. The apparatus of claim 6, wherein the call information construction module comprises:
the implementation method acquisition unit is used for acquiring the implementation method of the target class package;
the target implementation method acquisition unit is used for reconstructing each implementation method to obtain a target implementation method;
the target implementation method encapsulation unit is used for repackaging the target implementation method;
a target compiled file obtaining unit, configured to compile the target reconstruction class to obtain a target compiled file;
and the target calling information acquisition unit is used for taking the target compiled file as the target calling information.
8. The apparatus of claim 7, wherein the target implementation method obtaining unit is configured to:
and taking the method signature included by the implementation method as the method signature of the target implementation method.
9. A computer device, characterized in that the computer device comprises:
one or more processors;
storage means for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement the source call method as recited in any of claims 1-5.
10. A computer storage medium on which a computer program is stored, the program, when executed by a processor, implementing a source code invocation method according to any of claims 1-5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910901436.0A CN110673834A (en) | 2019-09-23 | 2019-09-23 | Source code calling method and device, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910901436.0A CN110673834A (en) | 2019-09-23 | 2019-09-23 | Source code calling method and device, computer equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN110673834A true CN110673834A (en) | 2020-01-10 |
Family
ID=69077255
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910901436.0A Pending CN110673834A (en) | 2019-09-23 | 2019-09-23 | Source code calling method and device, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110673834A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113900896A (en) * | 2021-10-11 | 2022-01-07 | 北京博睿宏远数据科技股份有限公司 | Code operation monitoring method, device, equipment and storage medium |
CN113900896B (en) * | 2021-10-11 | 2024-04-26 | 北京博睿宏远数据科技股份有限公司 | Method, device, equipment and storage medium for monitoring code operation |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20070169110A1 (en) * | 2005-10-27 | 2007-07-19 | Nikhil Gupta | Method and system for dynamically providing native libraries and their dependencies |
CN108572853A (en) * | 2018-04-24 | 2018-09-25 | 北京奇虎科技有限公司 | Interface provision method, device and the computing device of system hidden method |
CN108647061A (en) * | 2018-04-24 | 2018-10-12 | 北京奇虎科技有限公司 | Call method, device and the computing device of system hidden method |
CN109298952A (en) * | 2018-08-27 | 2019-02-01 | 优视科技新加坡有限公司 | The call method and its device of application programming interface |
-
2019
- 2019-09-23 CN CN201910901436.0A patent/CN110673834A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20070169110A1 (en) * | 2005-10-27 | 2007-07-19 | Nikhil Gupta | Method and system for dynamically providing native libraries and their dependencies |
CN108572853A (en) * | 2018-04-24 | 2018-09-25 | 北京奇虎科技有限公司 | Interface provision method, device and the computing device of system hidden method |
CN108647061A (en) * | 2018-04-24 | 2018-10-12 | 北京奇虎科技有限公司 | Call method, device and the computing device of system hidden method |
CN109298952A (en) * | 2018-08-27 | 2019-02-01 | 优视科技新加坡有限公司 | The call method and its device of application programming interface |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113900896A (en) * | 2021-10-11 | 2022-01-07 | 北京博睿宏远数据科技股份有限公司 | Code operation monitoring method, device, equipment and storage medium |
CN113900896B (en) * | 2021-10-11 | 2024-04-26 | 北京博睿宏远数据科技股份有限公司 | Method, device, equipment and storage medium for monitoring code operation |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109032706B (en) | Intelligent contract execution method, device, equipment and storage medium | |
JP5415557B2 (en) | User script code conversion for debugging | |
US8756590B2 (en) | Binding data parallel device source code | |
CN110096338A (en) | Intelligent contract executes method, apparatus, equipment and medium | |
US9684786B2 (en) | Monitoring an application in a process virtual machine | |
KR20150024842A (en) | Adaptive portable libraries | |
CN110059456B (en) | Code protection method, code protection device, storage medium and electronic equipment | |
CN111740948B (en) | Data packet issuing method, dynamic updating method, device, equipment and medium | |
US9141351B2 (en) | Indicators for resources with idempotent close methods in software programs | |
US8930923B2 (en) | Generating debugging extension source code utilizing debugging information | |
CN110609687A (en) | Compiling method, device, electronic equipment and storage medium | |
US9176714B2 (en) | Re-using legacy libraries in software | |
US8806453B1 (en) | Integrating disparate programming languages to form a new programming language | |
CN110727476B (en) | Method, device, equipment and storage medium for generating authorization configuration file | |
US10620916B2 (en) | Read-only communication operator | |
US9141343B2 (en) | Indicators for resources with close methods that do not complete erroneously in software programs | |
US20180032424A1 (en) | System, method, and apparatus for crowd-sourced gathering of application execution events for automatic application testing and replay | |
CN116841559A (en) | Transcoding method, device, apparatus, medium and program product | |
US20130111432A1 (en) | Validation of a system model including an activity diagram | |
US9841960B2 (en) | Dynamic provision of debuggable program code | |
CN111258802A (en) | Method for capturing application program crash information and related equipment | |
US20170139681A1 (en) | Class splitting in object-oriented environments | |
US11068246B2 (en) | Control flow graph analysis | |
US10521206B2 (en) | Supporting compiler variable instrumentation for uninitialized memory references | |
CN110673834A (en) | Source code calling method and device, computer 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 |