Past expression: encapsulating pre-states at post-conditions by means of AOP

Jooyong Yi, Robby, Xianghua Deng, Abhik Roychoudhury
{"title":"Past expression: encapsulating pre-states at post-conditions by means of AOP","authors":"Jooyong Yi, Robby, Xianghua Deng, Abhik Roychoudhury","doi":"10.1145/2451436.2451453","DOIUrl":null,"url":null,"abstract":"Providing a pair of pre and post-condition for a method or a procedure is a typical way of program specification. When specifying a post-condition, it is often necessary to compare the post-state value of a variable with its pre-state value. To access a pre-sate value at a post-condition, most contract languages such as Eiffel and JML provide an old expression; old(x) returns a pre-state value of variable x. However, old expressions pose several problems, most notably the lack of encapsulation; old(x) does not encapsulate an object graph rooted from the pre-state value of x. Thus, method-call expressions like x.equals(old(x)) should generally not be used, and instead each field of x should be compared individually as in x.f1==old(x.f1) & x.f2==old(x.f2). In this paper, we first describe this lack of encapsulation and other problems of old expressions in more detail. Then, to address those problems, we propose our novel past expression along with its formal semantics. We also describe how our past expression can be supported during runtime assertion checking. We explain the involved problems, and show how we solve them. We implement our solution by means of AOP where we exploit various primitive pointcuts including our custom branch pointcut.","PeriodicalId":353153,"journal":{"name":"Aspect-Oriented Software Development","volume":"54 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2013-03-24","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"3","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Aspect-Oriented Software Development","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1145/2451436.2451453","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 3

Abstract

Providing a pair of pre and post-condition for a method or a procedure is a typical way of program specification. When specifying a post-condition, it is often necessary to compare the post-state value of a variable with its pre-state value. To access a pre-sate value at a post-condition, most contract languages such as Eiffel and JML provide an old expression; old(x) returns a pre-state value of variable x. However, old expressions pose several problems, most notably the lack of encapsulation; old(x) does not encapsulate an object graph rooted from the pre-state value of x. Thus, method-call expressions like x.equals(old(x)) should generally not be used, and instead each field of x should be compared individually as in x.f1==old(x.f1) & x.f2==old(x.f2). In this paper, we first describe this lack of encapsulation and other problems of old expressions in more detail. Then, to address those problems, we propose our novel past expression along with its formal semantics. We also describe how our past expression can be supported during runtime assertion checking. We explain the involved problems, and show how we solve them. We implement our solution by means of AOP where we exploit various primitive pointcuts including our custom branch pointcut.
过去表达式:通过AOP封装后置条件的预状态
为方法或过程提供一对前置和后置条件是程序规范的一种典型方式。在指定后置条件时,通常需要将变量的后置状态值与其前置状态值进行比较。为了在后置条件下访问预安全值,大多数契约语言(如Eiffel和JML)提供旧表达式;old(x)返回变量x的预状态值。然而,旧表达式带来了几个问题,最明显的是缺乏封装;old(x)不会封装一个基于x的预状态值的对象图。因此,通常不应该使用像x.equals(old(x))这样的方法调用表达式,而是应该单独比较x的每个字段,如x.f1==old(x.f1) & x.f2==old(x.f2)。在本文中,我们首先更详细地描述了旧表达式缺乏封装和其他问题。然后,为了解决这些问题,我们提出了新的过去式表达及其形式语义。我们还描述了在运行时断言检查期间如何支持过去表达式。我们解释所涉及的问题,并展示我们如何解决它们。我们通过AOP实现我们的解决方案,在AOP中我们利用各种基本的切入点,包括我们的自定义分支切入点。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术官方微信