arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1311.4934cs.SE
收藏

动态包接口-扩展版

Dynamic Package Interfaces - Extended Version

Shahram Esmaeilsabzali, Rupak Majumdar, Thomas Wies, Damien Zufferey

摘要:

面向对象编程的一个标志是通过一组交互对象执行计算的能力。这种风格的一个常见表现是包的概念,它将一组常用的类组合在一起。使用包的一个挑战是确保客户端在调用包的方法时遵循包的隐式协议。违反协议可能导致运行时错误或潜在的不变量违反。这些协议可以跨不同的、可能无限多的对象进行扩展,并在文档中非正式地指定。因此,很难确保客户端不违反协议。我们引入动态包接口(DPI),一种形式主义,明确地捕捉一个包的协议。包的DPI是一组有限的规则,它们共同指定包的任何交互对象集如何通过方法调用进行演变,以及在什么条件下可能发生错误。我们已经开发了一个动态的工具,自动计算一个包的DPI的近似值,给定一组抽象谓词。DPI的一个关键属性是,一个包的对象的配置的无限数量被概括在一个抽象域中。这使用了许多包行为单调的观察结果:如果向配置中添加更多对象,配置上的方法调用的语义本质上不会改变。我们已经利用单调性,并设计了算法来获得简洁而通用的DPI。我们已经使用我们的工具来计算具有复杂协议的几个常用Java包的DPI,例如JDBC,HashSet和ArrayList。

英文摘要:

A hallmark of object-oriented programming is the ability to perform computation through a set of interacting objects. A common manifestation of this style is the notion of a package, which groups a set of commonly used classes together. A challenge in using a package is to ensure that a client follows the implicit protocol of the package when calling its methods. Violations of the protocol can cause a runtime error or latent invariant violations. These protocols can extend across different, potentially unboundedly many, objects, and are specified informally in the documentation. As a result, ensuring that a client does not violate the protocol is hard. We introduce dynamic package interfaces (DPI), a formalism to explicitly capture the protocol of a package. The DPI of a package is a finite set of rules that together specify how any set of interacting objects of the package can evolve through method calls and under what conditions an error can happen. We have developed a dynamic tool that automatically computes an approximation of the DPI of a package, given a set of abstraction predicates. A key property of DPI is that the unbounded number of configurations of objects of a package are summarized finitely in an abstract domain. This uses the observation that many packages behave monotonically: the semantics of a method call over a configuration does not essentially change if more objects are added to the configuration. We have exploited monotonicity and have devised heuristics to obtain succinct yet general DPIs. We have used our tool to compute DPIs for several commonly used Java packages with complex protocols, such as JDBC, HashSet, and ArrayList.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑