ebtokyo
ebtokyo

Reputation: 2379

AspectJ declare parents on complex hierarchy

There is a possibility in AspectJ to modify the class hierarchy using declare statements :

declare parents : TypePattern extends Type;

From http://eclipse.org/aspectj/doc/released/adk15notebook/annotations-decp.html

Basically it allow you to "insert" a class in the hierarchy, here I insert X class :

 1. Child extends Parent                   -->   Child extends X extends Parent 
 2. Child extends SomeClass extends Parent -->   Child extends X extends SomeClass extends X extends Parent

However I am looking for a notation that will allow me to resolve the second case to :

 2. Child extends SomeClass extends Parent  -->   Child extends SomeClass extends X extends Parent

My problem is I have Child extends X and SomeClass extends X. Do you know AspectJ notation that would solve this problem ?

Upvotes: 0

Views: 926

Answers (1)

Andrew Eisenberg
Andrew Eisenberg

Reputation: 28757

Does this not work?

declare parents : Child extends SomeClass;
declare parents : SomeClass extends X;
declare parents : X extends Parent;

I guess I am not exactly sure what your goal is.

Upvotes: 0

Related Questions