[Paper Review] Extending Design by Contract for Aspect-Oriented Programming
This paper extends Design by Contract (DbC) to Aspect-Oriented Programming (AOP) by introducing a classification of aspects into agnostic, obedient, and rebellious types, which determines the correct runtime order for validating method and aspect assertions. The approach ensures correct blame assignment and behavioral subtyping in AOP systems, implemented in the Cona tool, enabling robust, verifiable contracts across both classes and aspects.
Design by Contract (DbC) and runtime enforcement of program assertions enables the construction of more robust software. It also enables the assignment of blame in error reporting. Unfortunately, there is no support for runtime contract enforcement and blame assignment for Aspect-Oriented Programming (AOP). Extending DbC to also cover aspects brings forward a plethora of issues related to the correct order of assertion validation. We show that there is no generally correct execution sequence of object assertions and aspect assertions. A further classification of aspects as agnostic, obedient, or rebellious defines the order of assertion validation that needs to be followed. We describe the application of this classification in a prototyped DbC tool for AOP named Cona, where aspects are used for implementing contracts, and contracts are used for enforcing assertions on aspects.
Motivation & Objective
- To address the lack of runtime contract enforcement and blame assignment in Aspect-Oriented Programming (AOP), which existing DbC methodologies fail to support.
- To resolve the ambiguity in the execution order of object and aspect assertions, which affects correctness and error reporting in AOP systems.
- To define a formal classification of aspects based on their behavioral impact on method contracts, enabling consistent runtime validation and subtyping guarantees.
- To extend DbC semantics to support contracts on advice (before/after/around) and ensure behavioral subtyping between original and aspect-enhanced methods.
- To implement and evaluate this extension in Cona, an AOP-aware DbC tool that enforces contracts via aspects and validates assertions in a type-safe, blame-aware manner.
Proposed method
- Proposes a three-way classification of aspects—agnostic, obedient, and rebellious—based on how they affect method behavior and contract enforcement order.
- Defines a strict execution sequence for contract validation: preconditions are checked before advice, and postconditions after, with order determined by aspect category.
- Introduces a behavioral subtyping rule: an advised method must be a behavioral substitute for its original counterpart, validated via assertions on both method and advice.
- Uses the Cona tool to implement the DbC extension, translating pre- and post-conditions on advice into runtime checks using AspectJ’s pointcut and advice mechanisms.
- Enforces blame assignment by tracing contract violations to either the method or the aspect, depending on the category and validation order.
- Ensures that aspects remain oblivious to the base system’s contracts, preserving modularity while enabling verification.
Experimental results
Research questions
- RQ1What is the correct runtime order for validating object and aspect assertions in AOP, and why is there no universally correct sequence?
- RQ2How can aspects be categorized such that their behavioral impact on method contracts determines a correct and consistent assertion validation order?
- RQ3How can behavioral subtyping be preserved when advice modifies method behavior, and how can this be enforced at runtime?
- RQ4How can blame for contract violations be accurately assigned when both methods and aspects contain assertions?
- RQ5Can a DbC mechanism be extended to AOP without modifying the base language or breaking modularity?
Key findings
- There is no universally correct execution order for validating object and aspect assertions, as the correct sequence depends on the aspect’s behavioral role.
- The classification of aspects into agnostic, obedient, and rebellious types determines the correct validation order and ensures behavioral subtyping.
- Agnostic aspects do not affect method behavior and are validated after the method; obedient aspects modify behavior in a way that requires pre- and post-conditions to be checked in sequence; rebellious aspects override behavior and require strict ordering to preserve subtyping.
- The Cona tool successfully enforces contracts on both methods and advice, enabling runtime assertion checking and accurate blame assignment in AOP systems.
- The approach allows aspects to implement contracts while contracts enforce assertions on aspects, creating a self-consistent verification mechanism.
- The classification system enables blame assignment without complex path analysis, simplifying error reporting in AOP applications.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.