Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] static pointcut for "super"

I would like to create an aspect to declare an error if a particular method is called on the super from a subtype.  Something like:

public class SuperClass {
   public final void dontCallThisFromBase() { }
}

public class BaseClass extends SuperClass {
   public void doSomething() {
      super.dontCallThisFromBase(); // would love to be a compiler error
   }
}

public class UnrelatedClass {
   public void unrelatedMethod() {
      new SuperClass().dontCallThisFromBase(); // this is ok
   }
}

I'm having a hard time matching the join point with the super... any thoughts?  Or should this work and I'm just doing something stupid?

I first wanted to create a general @CantCallFromSubclass attribute that I could throw on the declaration of dontCallThisFromBase() -- but that doesn't seem to be possible... so plan B was just creating a specific aspect for this specific case.. but I'm running into trouble there too.

Thanks,

Steve Ash

Back to the top