WO2018028027A1 - 基于重构技术实现开放终端应用数据与功能的方法 - Google Patents
基于重构技术实现开放终端应用数据与功能的方法 Download PDFInfo
- Publication number
- WO2018028027A1 WO2018028027A1 PCT/CN2016/099878 CN2016099878W WO2018028027A1 WO 2018028027 A1 WO2018028027 A1 WO 2018028027A1 CN 2016099878 W CN2016099878 W CN 2016099878W WO 2018028027 A1 WO2018028027 A1 WO 2018028027A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- application
- control flow
- data
- function
- runtime
- 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.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/36—Software reuse
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45504—Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
- G06F9/45516—Runtime code conversion or optimisation
- G06F9/45525—Optimisation or modification within the same instruction set architecture, e.g. HP Dynamo
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/31—Programming languages or programming paradigms
- G06F8/315—Object-oriented languages
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/43—Checking; Contextual analysis
- G06F8/433—Dependency analysis; Data or control flow analysis
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/72—Code refactoring
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/74—Reverse engineering; Extracting design information from source code
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/448—Execution paradigms, e.g. implementations of programming paradigms
- G06F9/4488—Object-oriented
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45504—Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
- G06F9/45508—Runtime interpretation or emulation, e g. emulator loops, bytecode interpretation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
Definitions
- the invention is a method for transforming data and functions of an existing terminal application into an application programming interface (API) that can be externally called by using program analysis and reconstruction technology, thereby realizing open application data and functions of the terminal. It belongs to the field of software technology and is suitable for software maintenance.
- API application programming interface
- the application programming interface economy is an emerging driving force that can help business leaders transform their businesses, build new ecosystems, and monetize core assets to meet the market challenges of today's digital transformation.
- the data and functionality in end applications are potentially valuable and require further development to realize their potential value.
- the open application's data and functionality require developers to manually modify and refactor the original system.
- third-party development teams such as corporate office applications, government smart city applications.
- these enterprises and government-owned applications have very important data and functions, because the owners of these applications often lack corresponding development teams, they need to re-contact the original third-party development when opening the application data and functions. The team will encounter problems such as high development costs and long development cycles.
- the core idea is to modify the runtime environment of the application, obtain the control flow information of the application runtime when the user uses the corresponding function and data of the application, and reconstruct the original control flow.
- the method analyzes the runtime control flow and the application static code by programmatically, and strips the sub-control flow irrelevant to the function and data of the application, for example, implementing a sub-control flow of a user interface (UI); retaining and application functions, data A set of sub-control flows and their contexts that are directly related. In a specific context, by recreating the set of sub-control flows, the corresponding functions can be applied and the application data can be obtained.
- UI user interface
- the method realizes the control flow of the runtime when the user uses the application specific function and acquires the application specific data through the monitoring of the application environment level level; by combining the control flow analysis and the static code analysis, the function and data irrelevant are stripped off.
- Sub-control flow promotion generated external connection The efficiency of the port; by recreating the specific context at the application runtime level, reusing the original application code to ensure application functionality, and obtaining the correctness of the application data.
- a method for implementing open terminal application data and functions based on a reconstruction technology the steps of which include:
- the application owner specifies the data and functions of the terminal application to be provided externally;
- step 2 2) using a control flow acquisition method at the application runtime environment level to obtain a set of control flows and their runtime contexts when using the functions and data specified in step 1);
- step 2) programmatically analyzing the control flow and the runtime context acquired in step 2), generating a context dependency of each function in the control flow and an awakening relationship between the set of control flows;
- step 4 through the analysis result obtained in step 3), reconstructing the control flow of the application obtained in step 2), and generating a set of externally callable application programming interfaces (APIs);
- APIs application programming interfaces
- step 4 By calling the API generated in step 4), the original functions and data of the application can be used to implement the functions and data of the open application.
- control flow at the application runtime environment level described in step 2) is an ordered set of function calls.
- runtime context described in step 2) includes parameters for each function call in the control flow, and data that each function reads and writes in memory.
- step 2) includes:
- step 3 includes:
- step 4 the method of reconstructing the control flow of the application in step 4) is:
- each control flow is divided into three sub-control flows of user interface correlation, computational logic correlation and other input and output correlation, and an example of the context of each sub-control flow start, ie sub-control The parameters of the function when the stream function is called, and the data in memory it depends on;
- step c) The developer selects the appropriate sub-control flow according to the example given in step b) above, and implements the functions and data in the application as a set of externally callable application programming interfaces.
- the invention proposes a method for converting data and functions of an existing application into a service by means of an interface externally, and can automatically obtain a control flow and a runtime context through a program in the absence of a document and a lack of a developer.
- the original control flow is reconstructed.
- the present invention combines the advantages of the prior art, innovatively combines control flow analysis with static code analysis, stripping off application-independent, data-independent sub-control flows to improve the efficiency of the generated external interface;
- the level reproduces the specific context, reuses the original application code to ensure application functionality, and obtains the correctness of the application data.
- Figure 1 is an example of the original control flow obtained.
- Figure 2 is an example of a control flow that complements the data dependencies of a function and the wake-up relationship between control flows.
- FIG. 3(a), 3(b) and 3(c) are examples of control flow reconstruction methods, wherein FIG. 3(a) is the original control flow of the application, and FIG. 3(b) is the generation efficiency-driven reconstruction.
- the post-control flow, Figure 3(c) shows the post-reconstructed control flow driven by the efficiency.
- the present invention provides a method of translating data and functions of an existing application into an externally interfaced manner.
- the method includes three parts: 1. Implementing the application runtime control flow and its context acquisition method; 2. Controlling the data dependency relationship in the flow and controlling the flow wakeup relationship; 3. Applying the control flow reconstruction method.
- the core idea is to modify the original control flow of the application and retain the application processing core processing logic to achieve the purpose of correctly and efficiently transforming the data and functions of the existing application into an external interface.
- the control flow of the application runtime is an ordered set of function calls.
- it can support the record runtime function call order (ie, control flow).
- Each function call in this set of control flows has a runtime context corresponding to it.
- the runtime context consists of two parts: 1. the parameters of each function call; 2. the data in the heap shared by all global functions.
- the Stack and Heap structures of the application runtime environment can be modified to support serialization of data (ie, context) in the stack and heap structure at runtime.
- control flow can be divided into three parts: user interface related, computational logic related, and other input and output related to files, networks, and so on.
- control flow constructed in (2) developers can reconstruct the original control flow with different goals.
- developers can refactor the original control flow with the goal of generating application programming interface efficiency.
- the parts related to the user interface in the application are often read input and presentation output, which is not only easy for developers to read but also easy to understand. Therefore, based on the original control flow, adding read and write to the user interface can quickly implement the required data and functions as an application programming interface.
- the application programming interface generated in this way is complicated to calculate due to the need to perform user interface rendering. In some scenarios, it may result in inefficient execution and difficulty in meeting high-concurrency API call requirements.
- a feasible control flow reconfiguration scheme is to retain the non-removable functions and some of the computational logic-related functions.
- the context information required for different control flow reconstruction schemes is different. With the required context complexity as an indicator, developers can find a feasible and efficient control flow reconstruction scheme.
- the Android Runtime By modifying the running environment of the Android application, the Android Runtime (Android Runtime) enables it to obtain the above application runtime control flow and context.
- the memory data of the Android runtime is stored in a heap data structure in units of objects.
- the control function corresponding to the query function can be obtained by using the query function of the application on the modified Android runtime, as shown in FIG. 1 .
- the rounded rectangle with letters in Figure 1 represents the function call; the function call overlaps the call relationship between the functions, such as the C function is called in the B function (that is, the C function call is generated); the hexagon represents the runtime Object; the dashed line between the object and the function call indicates that the function call takes the object as a parameter.
- the control flow in Figure 1 triggers the main thread to call the A function through the interface click query.
- the A function wakes up the background thread by acquiring the input on the user interface (object 1), and calls the B function to further sort the input data; then, the main line Enter the sleep state; then the B function calls the C function to construct the corresponding data query statement (object 2), and wakes up the data query thread to call the D function to initiate the query; at this time, the background thread enters the sleep state again; the D function calls the E function to get the query.
- the background thread is re-awakened; the F function sorts the output of E (object 3) and wakes up the main thread call.
- control flow information obtained above lacks the data dependency of the function call, such as reading and writing static fields (Static Field), etc., which will make it difficult for developers to reproduce the complete runtime context, resulting in failure to generate the correct application. Programming interface.
- control flow information obtained above also lacks the wake-up relationship between the threads, which results in the above diagrams corresponding to five control flows instead of one complete control flow.
- control flow As described in the above specific implementation scheme, we divide the control flow into three parts related to user interface correlation, computational logic correlation, and other input and output related to files, networks, etc., and the control flow can be simplified as shown in Fig. 3(a).
- a control flow reconstruction scheme aiming at the efficiency of application programming interface generation is shown in Figure 3(b).
- the reconstruction scheme is based on the original control flow, and adds read and write operations (H functions) to the user interface elements, that is, completes the required application programming interface.
- a control flow reconstruction scheme aiming at application programming interface execution efficiency is shown in Figure 3(c).
- the refactoring scheme completely removes user interface related function calls (A function and G function) and part of input data processing logic (B function and C function), retains core database query logic (D function and E function) and output result processing.
- Logic F function
- the developer constructs the context (object 2) required for the execution of these three functions according to the context information of the original control flow obtained.
- the implementation encapsulates the query function as an externally callable application programming interface.
- the function selected by the developer relies on data complexity, such as calling native C/C++ code through the runtime dynamic link library and relying on data in the Android Runtime in C/C++ code, it can be implemented.
- data complexity such as calling native C/C++ code through the runtime dynamic link library and relying on data in the Android Runtime in C/C++ code
- the above embodiment is directed to the implementation of the Android application and the Android Runtime.
- the method can also be implemented for different bytecodes, intermediate code and source code and its runtime environment, such as .Net framework application and its runtime; Java application and Java virtual machine; Javascript application and its JS interpreter, etc. .
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computing Systems (AREA)
- Stored Programmes (AREA)
Abstract
一种基于重构技术实现开放终端应用数据与功能的方法。通过修改应用的运行时环境,获取用户在使用应用相应功能、数据时的应用运行时控制流信息,并对原有控制流进行重构。通过程序化分析运行时控制流和应用静态代码,剥离与应用的功能、数据无关的子控制流,保留与应用功能、数据直接相关的一组子控制流及其上下文环境。在特定的上下文环境下,重现这组子控制流,从而实现应用相应功能、获取应用数据。可用于开放基于Java、C#和JavaScript实现的不同类型的终端应用中的功能与数据。
Description
本发明是一种利用程序分析与重构技术实现将现有终端应用的数据和功能转化为可由外部调用的应用编程接口(Application Programming Interface,API),从而实现将终端应用数据与功能开放的方法,属于软件技术领域,适用于软件维护。
应用编程接口经济是新兴的推动力量,能够帮助企业领导者实现企业转型,构建新的生态系统,实现核心资产货币化,以应对当今数字转型过程中的市场挑战。终端应用中的数据和功能潜藏了巨大的价值,亟需进一步开发,以实现其潜在价值。然而,开放应用的数据和功能需要开发人员对原系统进行手工的修改与重构。对于大量的企业和政府单位,他们往往是通过第三方开发团队定制应用,如企业的办公应用、政府的智慧城市应用等。这些企业、政府所拥有的应用虽然有着非常重要的数据和功能,却因为这些应用的所有者往往缺少相应的开发团队,导致他们在开放应用的数据和功能时需要重新联系原有的第三方开发团队,会遇到开发成本高、开发周期长等问题。
综上所述,需要一种支持将现有终端应用的数据和功能转换为应用编程接口的方法。它可以帮助应用所有者在开发文档缺失、开发人员缺位的情况下,快速地将现有应用的数据和功能对外开放。应用所有者利用本发明提出的一种程序控制流捕捉与重构方法,可以高效地复用原有应用代码,从而实现快速将现有应用的数据与功能生成相应的应用编程接口。
发明内容
本发明的目的是将现有应用的数据和功能对外以接口的方式提供服务。其核心思想是通过修改应用的运行时环境,获取用户在使用应用相应功能、数据时的应用运行时控制流信息,并对原有控制流进行重构。本方法通过程序化分析运行时控制流和应用静态代码,剥离与应用的功能、数据无关的子控制流,例如,实现用户接口(User Interface,UI)的子控制流;保留与应用功能、数据直接相关的一组子控制流及其上下文环境。在特定的上下文环境下,重现这组子控制流,即可实现应用相应功能、获取应用数据。本方法通过应用运行环境级别的监控,实现获取用户在使用应用特定功能、获取应用特定数据时的运行时的控制流;通过结合控制流分析与静态代码分析,剥离与应用的功能、数据无关的子控制流提升生成的对外接
口的效率;通过在应用运行环境级别重现特定的上下文环境、复用原应用代码以保证应用功能、获取应用数据的正确性。
本发明采用的技术方案如下:
一种基于重构技术实现开放终端应用数据与功能的方法,其步骤包括:
1)由应用所有者指定终端应用中欲对外提供接口的数据与功能;
2)利用应用运行环境级别的控制流获取方法,获取在使用步骤1)中指定的功能、数据的运行时的一组控制流及其运行时上下文;
3)对步骤2)获取的控制流及运行时上下文进行程序化分析,生成控制流中每个函数的上下文依赖及这组控制流之间的唤醒关系;
4)通过步骤3)获取的分析结果,重构步骤2)中获取的应用的控制流,生成一组外部可调用的应用编程接口(Application Programming Interface,API);
5)通过调用步骤4)中生成的API可使用应用的原有功能、数据,实现开放应用的功能、数据。
进一步地,步骤2)所述的应用运行环境级别的控制流为一组有序的函数调用。
进一步地,步骤2)所述的运行时上下文包括控制流中每个函数调用的参数,和每个函数在内存所读取、写入的数据。
进一步地,步骤2)所述的应用运行环境级别的控制流获取方法包括:
a)修改应用运行环境的内存管理部分,使其支持运行时对内存中的数据(即上下文)进行序列化;
b)修改应用运行环境的实现函数调用相关模块,使其支持记录运行时函数调用次序(即控制流);
c)在上述a)、b)步骤实现的应用运行环境中运行相应的应用,即可获取使用指定的功能、数据时的运行时控制流及其序列化后的上下文信息。
进一步地,步骤3)中的程序化分析方法包括:
a)以应用字节码或代码作为输入,利用静态分析方法,分析每个函数的数据依赖,并结合运行时的上下文信息,将静态分析结果映射至控制流中的每个函数,生成控制流中每个函数调用与上下文的数据依赖关系;
b)以控制流中与控制流切换相关的函数作为输入,分析各个控制流之间的切换,生成控制流之间的唤醒关系,从而构造出跨多个线程的控制流。
进一步地,步骤4)中的重构应用的控制流的方法是:
a)根据函数的对外产生的行为将控制流中的函数分为三类:1.用户界面相关;2.计算逻辑相关;3.其他输入、输出相关;
b)通过程序分析,将每个控制流切分为用户界面相关、计算逻辑相关和其他输入输出相关三个部分的子控制流,同时给出每个子控制流起始的上下文示例,即子控制流函数调用时的函数的参数,及其所依赖的内存中的数据;
c)开发人员根据上述步骤b)给出的示例,选择合适的子控制流,将应用中的功能、数据实现为一组外部可调用的应用编程接口。
本发明提出了一种将现有应用的数据和功能转化为对外以接口的方式提供服务的方法,可以在文档缺失、开发人员缺位的情况下,通过程序自动获取控制流及运行时上下文,并对原控制流进行重构。本发明结合了现有技术的优点,创新性地结合控制流分析与静态代码分析,剥离与应用的功能、数据无关的子控制流以提升生成的对外接口的效率;同时又通过在应用运行环境级别重现特定的上下文环境、复用原应用代码以保证应用功能、获取应用数据的正确性。
图1是获取的原始控制流示例。
图2是补充了函数的数据依赖及控制流之间唤醒关系的控制流示例。
图3(a)、图3(b)和图3(c)是控制流重构方法示例,其中图3(a)为应用的原始控制流,图3(b)为生成效率驱动的重构后控制流,图3(c)为执行效率驱动的重构后控制流。
为使本发明的上述目的、特征和优点能够更加明显易懂,下面通过具体实施例和附图,对本发明做进一步说明。
本发明提供了一种将现有应用的数据和功能转化为对外以接口的方式提供服务的方法。该方法包含三部分内容:1、实现应用运行时控制流及其上下文获取方法;2、控制流中数据依赖关系及控制流唤醒关系;3、应用控制流重构方法。其核心思想是通过修改应用的原有的控制流,保留应用功能核心处理逻辑,达到将现有应用的数据和功能正确并高效地转化为对外以接口的方式提供服务的目的。
本发明的具体技术方案如下:
(1)应用运行时控制流及运行时上下文获取方法。
应用运行时的控制流为一组有序的函数调用。通过修改应用运行环境的帧(Frame)结构,可使其支持记录运行时函数调用次序(即控制流)。这组控制流中的每个函数调用都有与其对应的运行时上下文。运行时上下文包括两部分:1.每个函数调用时的参数;2.全局所有函数共享的堆中的数据。为获取上述上下文,可通过修改应用运行环境的栈(Stack)、堆(Heap)结构,使其支持在运行时对栈、堆结构中的数据(即上下文)进行序列化。通过在进行以上修改后的应用运行环境中运行相应的应用,即可获取使用指定的功能、数据时的运行时控制流及其序列化后的上下文信息。
(2)应用控制流关系及函数数据依赖关系生成方法
除了基本的控制流以外,还需要控制流中每个函数的数据依赖关系及控制流唤醒关系,以便开发人员理解完整控制流,并重现控制流上下文。我们以应用字节码或代码作为输入,利用静态分析方法,分析每个函数的数据依赖,并结合运行时的上下文信息,生成控制流中每个函数调用与内存中数据的依赖关系。
其次,我们以控制流中与线程唤醒相关的函数作为输入,分析各个控制流之间的唤醒关系,从而构造出跨多个线程的控制流。
(3)应用控制流重构方法
控制流可分为用户界面相关、计算逻辑相关和文件、网络等其他输入、输出相关的三个部分。利用(2)中构造的控制流,开发人员可以以不同的目标对原始控制流进行重构。
一方面,开发人员可以以应用编程接口生成效率为目标,对原始控制流进行重构。应用中与用户界面相关的部分往往是读取输入、呈现输出,不仅便于开发人阅读、而且便于理解。因此,以原始控制流为基础,增加对用户界面的读取、写入,即可快速实现将所需的数据与功能封装为应用编程接口。以这种方式生成的应用编程接口由于需要执行用户界面渲染等计算较复杂的,在部分场景下,会导致在执行效率低下,难以满足高并发量的API调用需求。
另一方面,开发人员还可以以应用编程接口执行效率为目标,对原始控制流进行重构。本质上,用户界面相关的函数在整个控制流中仅是提供输入和输出接口的作用,可以完全去除;与输入输出相关的函数往往必须保留(除了部分日志类型输出)。一个可行的控制流重构方案为保留了不可去除的函数及部分计算逻辑相关的函数。不同的的控制流重构方案所需的上下文信息有所区别,以所需的上下文复杂程度作为指标,开发人员可找出一组可行的、高效的控制流重构方案。
实施例:
本节给出开放安卓应用中功能、数据的实现。下面以一个查询数据功能为例,介绍重构
过程示例和重构后的运行时体系结构示例。
通过修改安卓应用的运行环境,安卓运行时(Android Runtime),使其支持获取上述的应用运行时控制流和上下文。特别地,安卓运行时的内存数据是以对象为单位,保存在一个堆数据结构中。在该修改后的安卓运行时上使用该应用的查询功能,即可得到该查询功能所对应的控制流,如图1所示。图1中带字母的圆角矩形表示函数调用;函数调用上下相叠表示函数之间的调用关系,如B函数中调用了C函数(即产生了C函数调用);六边形表示运行时的对象;对象与函数调用之间的虚线表示该函数调用以该对象作为参数。图1中的控制流为用户通过界面点击查询触发主线程调用A函数,A函数通过获取用户界面上的输入(对象1),唤醒后台线程,调用B函数对输入数据进行进一步整理;随即,主线进入休眠状态;随后由B函数调用C函数构造出相应的数据查询语句(对象2),并唤醒数据查询线程调用D函数发起查询;此时后台线程再次进入休眠状态;D函数调用E函数得到查询结果,重新唤醒后台线程;F函数整理E的输出结果(对象3)并唤醒主线程调用。一方面,上述获取的控制流信息缺少函数调用的数据依赖,例如读、写静态字段(Static Field)等,这将会导致开发人员难以重现完整的运行时上下文环境,导致无法生成正确的应用编程接口。另一方面,上述获取的控制流信息还缺少线程之间的唤醒关系,这会导致上述图中将会对应为五个控制流,而不是一个完整的控制流。
为此,我们以安卓应用的Dalvik格式的字节码作为输入,通过静态程序分析,分析出每个函数的数据依赖,并结合运行时的上下文,更精确地描述获取的控制流中的函数调用的数据依赖。其次,我们以控制流中与线程唤醒相关的函数作为输入,构造各个控制流之间的唤醒关系。最终,得出补充了函数数据依赖关系及线程之间唤醒关系的控制流,如图2所示。开发人员可对此控制流开始行进重构。
如上述具体实现方案所述,我们将控制流分为用户界面相关、计算逻辑相关和文件、网络等其他输入、输出相关的三个部分,控制流可简化为如图3(a)所示。
一种以应用编程接口生成效率为目标的控制流重构方案如图3(b)所示。该重构方案以原始控制流为基础,增加对用户界面元素的读取、写入操作(H函数),即完成所需的应用编程接口。
一种以应用编程接口执行效率为目标的控制流重构方案如图3(c)所示。该重构方案完全去除用户界面相关的函数调用(A函数和G函数)和部分输入数据处理逻辑(B函数和C函数),保留核心的数据库查询逻辑(D函数和E函数)和输出结果处理逻辑(F函数),开发人员根据获取的原始控制流的上下文信息,构造这三个函数执行所需的上下文环境(对象2),即可
实现将该查询功能封装为一个对外可调用的应用编程接口。
特别地,如果开发人员选取的函数依赖数据复杂,例如会通过运行时动态链接库调用原生C/C++代码,并在C/C++代码中依赖安卓运行时(Android Runtime)中的数据,则可实现为在服务器端以虚拟化的方式运行安卓虚拟机,以实现复杂的上下文环境的重现,保证重构后控制流的正确性。
以上实施例针对是对安卓应用及安卓运行时(Android Runtime)进行的实施。本方法也可针对不同的字节码、中间代码和源代码及其运行时环境,例如.Net framework应用及其运行时;Java应用及Java虚拟机;Javascript应用及其JS解释器等进行相应实施。
以上实施例仅用以说明本发明的技术方案而非对其进行限制,本领域的普通技术人员可以对本发明的技术方案进行修改或者等同替换,而不脱离本发明的精神和范围,本发明的保护范围应以权利要求书所述为准。
Claims (8)
- 一种基于重构技术实现开放终端应用数据与功能的方法,其特征在于,包括以下步骤:1)由应用所有者指定终端应用中欲对外提供接口的数据与功能;2)利用应用运行环境级别的控制流获取方法,获取在使用步骤1)中指定的功能、数据的运行时的一组控制流及其运行时上下文;3)对步骤2)获取的控制流及运行时上下文进行程序化分析,生成控制流中每个函数的上下文依赖及这组控制流之间的唤醒关系;4)通过步骤3)获取的分析结果,重构步骤2)中获取的应用的控制流,生成一组外部可调用的应用编程接口;5)通过调用步骤4)中生成的应用编程接口使用应用的原有数据和功能,从而将应用的数据和功能对外开放。
- 如权利要求1所述的方法,其特征在于:步骤2)所述的应用运行环境级别的控制流为一组有序的函数调用。
- 如权利要求1所述的方法,其特征在于:步骤2)所述的运行时上下文包括控制流中每个函数调用的参数,和每个函数在内存所读取、写入的数据。
- 如权利要求1所述的方法,其特征在于:步骤2)所述应用运行环境级别的控制流获取方法包括:a)修改应用运行环境的内存管理部分,使其支持运行时对内存中的数据进行序列化;b)修改应用运行环境的实现函数调用相关模块,使其支持记录运行时函数调用次序;c)在步骤a)、b)实现的应用运行环境中运行相应的应用,即可获取使用指定的功能、数据时的运行时控制流及其序列化后的上下文信息。
- 如权利要求4所述的方法,其特征在于:步骤2)通过修改应用运行环境的帧结构,使其支持记录运行时函数调用次序,即控制流;通过修改应用运行环境的栈、堆结构,使其支持在运行时对栈、堆结构中的数据即上下文进行序列化。
- 如权利要求1所述的方法,其特征在于,步骤3)所述程序化分析的方法包括:a)以应用字节码或代码作为输入,利用静态分析方法分析每个函数的数据依赖,并结合运行时的上下文信息,将静态分析结果映射至控制流中的每个函数,生成控制流中每个函数调用与上下文的数据依赖关系;b)以控制流中与控制流切换相关的函数作为输入,分析各个控制流之间的切换,生成控制流之间的唤醒关系,从而构造出跨多个线程的控制流。
- 如权利要求1所述的方法,其特征在于,步骤4)中重构应用的控制流的方法是:a)根据函数的对外产生的行为将控制流中的函数分为三类:用户界面相关;计算逻辑相关;其他输入输出相关;b)通过程序分析,将每个控制流切分为用户界面相关、计算逻辑相关和其他输入输出相关三个部分的子控制流,同时给出每个子控制流起始的上下文示例,即子控制流函数调用时的函数的参数,及其所依赖的内存中的数据;c)开发人员根据上述步骤b)给出的示例,选择合适的子控制流,将应用中的功能、数据实现为一组外部可调用的应用编程接口。
- 如权利要求7所述的方法,其特征在于,步骤4)中开发人员以应用编程接口生成效率为目标,对原始控制流进行重构;或者开发人员以应用编程接口执行效率为目标,对原始控制流进行重构。
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| US15/776,432 US10496423B2 (en) | 2016-08-12 | 2016-09-23 | Method for opening up data and functions of terminal application based on reconstruction technology |
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201610663995.9 | 2016-08-12 | ||
| CN201610663995 | 2016-08-12 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2018028027A1 true WO2018028027A1 (zh) | 2018-02-15 |
Family
ID=60593766
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2016/099878 Ceased WO2018028027A1 (zh) | 2016-08-12 | 2016-09-23 | 基于重构技术实现开放终端应用数据与功能的方法 |
Country Status (3)
| Country | Link |
|---|---|
| US (1) | US10496423B2 (zh) |
| CN (1) | CN107479866B (zh) |
| WO (1) | WO2018028027A1 (zh) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112328241A (zh) * | 2020-03-16 | 2021-02-05 | 北京五八信息技术有限公司 | 一种应用程序开发中创建Android库模块依赖关系的方法及装置 |
Families Citing this family (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107479866B (zh) * | 2016-08-12 | 2020-11-06 | 北京大学 | 基于重构技术实现开放终端应用数据与功能的方法 |
| CN108845996A (zh) * | 2018-04-02 | 2018-11-20 | 北京大学 | 一种聚合安卓应用程序内部搜索功能的元搜索引擎实现方法和总控系统 |
| CN109101271A (zh) * | 2018-07-27 | 2018-12-28 | 郑州云海信息技术有限公司 | 一种程序扩展方法及相关装置 |
| CN109491708A (zh) * | 2018-11-21 | 2019-03-19 | 北京锐安科技有限公司 | 文档生成方法、系统、设备和介质 |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101620536A (zh) * | 2009-08-17 | 2010-01-06 | 用友软件股份有限公司 | 一种调用功能函数的方法和装置 |
| CN101650648A (zh) * | 2008-08-14 | 2010-02-17 | 鸿富锦精密工业(深圳)有限公司 | 动态调用功能模块的系统及方法 |
| CN101847100A (zh) * | 2010-06-08 | 2010-09-29 | 用友软件股份有限公司 | 扩展软件应用的方法和装置 |
| CN102750144A (zh) * | 2012-05-31 | 2012-10-24 | 华亚微电子(上海)有限公司 | 功能模块的生成工具 |
| CN105303122A (zh) * | 2015-10-13 | 2016-02-03 | 北京大学 | 基于重构技术实现敏感数据云端锁定的方法 |
Family Cites Families (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US3167284A (en) * | 1962-08-24 | 1965-01-26 | Lynch James | Fishing rod carrier for a bicycle |
| CN104636256B (zh) * | 2015-02-17 | 2017-10-24 | 中国农业银行股份有限公司 | 一种内存访问异常的检测方法及装置 |
| CN107479866B (zh) * | 2016-08-12 | 2020-11-06 | 北京大学 | 基于重构技术实现开放终端应用数据与功能的方法 |
-
2016
- 2016-08-30 CN CN201610772875.2A patent/CN107479866B/zh active Active
- 2016-09-23 US US15/776,432 patent/US10496423B2/en active Active
- 2016-09-23 WO PCT/CN2016/099878 patent/WO2018028027A1/zh not_active Ceased
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101650648A (zh) * | 2008-08-14 | 2010-02-17 | 鸿富锦精密工业(深圳)有限公司 | 动态调用功能模块的系统及方法 |
| CN101620536A (zh) * | 2009-08-17 | 2010-01-06 | 用友软件股份有限公司 | 一种调用功能函数的方法和装置 |
| CN101847100A (zh) * | 2010-06-08 | 2010-09-29 | 用友软件股份有限公司 | 扩展软件应用的方法和装置 |
| CN102750144A (zh) * | 2012-05-31 | 2012-10-24 | 华亚微电子(上海)有限公司 | 功能模块的生成工具 |
| CN105303122A (zh) * | 2015-10-13 | 2016-02-03 | 北京大学 | 基于重构技术实现敏感数据云端锁定的方法 |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112328241A (zh) * | 2020-03-16 | 2021-02-05 | 北京五八信息技术有限公司 | 一种应用程序开发中创建Android库模块依赖关系的方法及装置 |
| CN112328241B (zh) * | 2020-03-16 | 2023-12-12 | 北京五八信息技术有限公司 | 一种应用程序开发中创建Android库模块依赖关系的方法及装置 |
Also Published As
| Publication number | Publication date |
|---|---|
| US20190155628A1 (en) | 2019-05-23 |
| US10496423B2 (en) | 2019-12-03 |
| CN107479866A (zh) | 2017-12-15 |
| CN107479866B (zh) | 2020-11-06 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN110096338B (zh) | 智能合约执行方法、装置、设备及介质 | |
| CN111090433B (zh) | 一种数据处理的方法、装置和存储介质 | |
| CN102246150B (zh) | 转换用户脚本代码来进行调试 | |
| US20110225565A1 (en) | Optimal incremental workflow execution allowing meta-programming | |
| CN107479866B (zh) | 基于重构技术实现开放终端应用数据与功能的方法 | |
| CN107274186A (zh) | 在区块链中获得智能合约接口的方法和设备 | |
| WO2020248511A1 (zh) | 一种基于运行时模型实现对终端应用控制的方法 | |
| CN101604241A (zh) | 一种嵌入式系统的代码生成方法 | |
| Lucassen et al. | Behavior-driven requirements traceability via automated acceptance tests | |
| CN101154259A (zh) | 通用自动化脱壳引擎与方法 | |
| CN103034486B (zh) | 移动终端操作系统基于全系统扩展调用图的自动优化方法 | |
| CN103995698A (zh) | 一种面向业务的应用表单敏捷开发方法及系统 | |
| CN112286521A (zh) | 一种任务流程处理方法、存储介质及处理器 | |
| CN109918075A (zh) | 利用打包插件的sdk打包方法、打包插件及相应终端 | |
| US10795704B2 (en) | Serialization of objects to java bytecode | |
| CN113448874A (zh) | 一种单元测试脚本的生成方法及装置 | |
| US20090077563A1 (en) | Systems And Methods For Grid Enabling Computer Jobs | |
| CN106843875B (zh) | 跨平台移植Python程序的方法和装置 | |
| CN111124386B (zh) | 基于Unity的动画事件处理方法、装置、设备和存储介质 | |
| CN110825373B (zh) | 一种移动端动态化方法及装置 | |
| CN100478879C (zh) | Xml语言描述的业务逻辑映射到应用语言的方法 | |
| CN114327400B (zh) | 一种基于java动态代理的敏捷开发方法及介质 | |
| US20130061204A1 (en) | Generated object model for test automation | |
| CN114579141A (zh) | require框架转化为VUE框架的方法及装置 | |
| CN116185826A (zh) | 一种测试方法、装置、设备及存储介质 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 16912482 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 16912482 Country of ref document: EP Kind code of ref document: A1 |