Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-dev] Invariants

I have a general question about aspects (I am an absolute beginner, so please bear with me)

I am writing an aspect to capture the notion of class invariant, of the form:

  // In the code name below <ClassName> is a placeholder
  // for an actual class name

  aspect <ClassName>Invariant
  {
      pointcut PublicInterface (<ClassName> object):
          target(object)                    && 
          call (public * <ClassName>.*(..)) &&
          !within(<ClassName>Invariant)     ;   // To avoid infinite recursion
	
      after(<ClassName> object) returning: PublicInterface (object)
      {
          // Assertions expressed in terms of the <ClassName>
          // public interface
      }
}

- In order to implement the proper semantics of a class invariant, I also want to ensure that when an object calls methods from its public interface on itself (as opposed to on other instances of the same class), the invariant should not be checked, how do I achieve that?

- Other more general question, is there a reuse mechanism that would allow me to capture this general aspect "pattern" generically, then instantiate it for concrete classes and specify the accompanying invariant assertions for that class?

Frederic Deramat


Back to the top