Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] intercept Class but not SubClass

Thanks Ron.

Actually, it is understandable as a solution, but maybe not the way users want to think about it.

The whole "trick" is needed because (as I understand it), in declare parents:
- MyClass means "MyClass only"
- MyClass+ means "MyClass + subtypes"

and in the this PCD:
- MyClass means "MyClass + subtypes".

Isn't this a semantic mismatch?
There is no direct means in the this PCD to refer to "MyClass only".

Ideally, for avoiding confusion for users, both ways should be similar, independently of whether they are doing an inter-type declaration or specifying a type pattern in a PCD. But if the idea is not to change the current semantics of the type pattern within the this PCD (so that a change does not break old code), then a possibility would be to add a way to say "and not its subclasses", something like:

pointcut baseConstruction() :
  execution(MyClass.new()) && !this(MyClass-);

And then you don't need to be adding a marker interface and all.

?

Regards,

-- Eric



Back to the top