Behavioural models are a valuable tool for software verification, testing, monitoring, publishing etc. However, they are rarely provided by the software developers and have to be extracted either from the source or from the compiled code. In the context of Java programs, a number of approaches exist for building behavioural models. Most of these approaches rely on the analysis of the compiled bytecode. Instead, we are looking to extract behavioural models in the form of Finite State Machines (FSMs) from the Java source code to ensure that the obtained FSMs can be easily understood by the software developers and, if necessary, updated or integrated into the original source code, e.g. in the form of annotations. Modern software systems are huge, rely on external libraries and interact with their environment. Hence, extracting useful behavioural models requires abstraction. In this paper, we present an initial approach to this problem by focusing on the extraction of FSMs modelling library APIs. We focus on the analysis of Java code involving the use of collections. To this end, we encode the operational semantics of collection operations using patterns of Boolean predicates. These patterns are instantiated based on the analysis of the source code of API implementation methods to form an encoding of the possible FSM transitions. A SAT solver is then used to determine the enabledness conditions (guards) of these transitions.
翻译:行为模型是软件验证、测试、监控、发布等过程中的重要工具。然而,这些模型很少由软件开发人员提供,而必须从源代码或编译代码中提取。在Java程序环境中,已有多种构建行为模型的方法。这些方法大多依赖于对编译字节码的分析。相比之下,我们旨在从Java源代码中提取以有限状态机(FSM)形式呈现的行为模型,以确保获得的FSM能够被软件开发人员轻松理解,并在必要时以注释等形式更新或集成到原始源代码中。现代软件系统规模庞大,依赖外部库并与运行环境交互,因此提取有效行为模型需要抽象化处理。本文提出了一种初始方法,专注于提取用于建模库API的FSM。我们重点分析涉及集合使用的Java代码。为此,我们利用布尔谓词模式对集合操作的操作语义进行编码。基于API实现方法源代码的分析,这些模式被实例化以形成可能的FSM转换编码。随后使用SAT求解器确定这些转换的使能条件(守卫条件)。