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

  • Authors:
  • Jooyong Yi; Robby;Xianghua Deng;Abhik Roychoudhury

  • Affiliations:
  • National University of Singapore, Singapore, Singapore;Kansas State University, Manhattan, KS, USA;Kansas State University, Manhattan, KS, USA;National University of Singapore, Singapore, Singapore

  • Venue:
  • Proceedings of the 12th annual international conference on Aspect-oriented software development
  • Year:
  • 2013

Quantified Score

Hi-index 0.00

Visualization

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.