Abstract
Aspect-oriented programming (AOP) has the good characteristic called obliviousness that enables a programmer to design a class without considering crosscutting concerns. On the other hand, it is not necessarily easy for the programmer to know the overall behavior of a woven program because weaving modifies the behavior of a method defined in a class. Unexpected errors might be embedded in the woven program. To tackle this problem, we propose WbC (Weaving by Contract), a technique for verifying the correctness of weaving based on contracts. Contracts in WbC consist of pre-conditions, post-conditions, and invariants of weaving. By introducing WbC, we can specify how a program should behave before and after weaving. We also provide a language called COW (COntract Writing language) for supporting WbC. In COW, a programmer describes contracts by predicate logic that represents the behavior of a program as a property of control and data flow. WbC can restrict weaving to keep the intention of the programmer.