Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] pertarget instantiation && within

Hi Adam,

I believe that
aspect XYZ pertarget(target(SomeClass) && !cflow(within(XYZ))) {
is what you want.

The reason why you are getting the infinite loop is that the aspect is
bound inside the constructor of SomeClass (which is *not* within(XYZ),
but is in its cflow).

On Sun, Apr 19, 2009 at 12:52 PM, Adam Przybylek <adam@xxxxxxxxxxx> wrote:
> I would like to create a new aspect instance for each new SomeClass object.
> The problem is that the responsibility of the aspect constructor is to
> create a new SomeClass object. Thus, an infinite recursion occures. So, I
> use the !within(XYZ) designator, but it doesn't work.
>
>> I am not sure if I understand the question. What is the use case you
>> are trying to implement?
>>
>> -Ramnivas
>>
>> 2009/4/18 Adam Przybylek <adam@xxxxxxxxxxx>:
>>>
>>> aspect XYZ pertarget(target(SomeClass) && !within(XYZ)) {
>>>  protected SomeClass sm;
>>>
>>>  public XYZ() {
>>>   sm = new SomeClass();
>>>  }
>>> }
>>>
>>> I would like not to instantiate the XYZ aspect when the object referred
>>> by
>>> sm is created. What do I do wrong?
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


Back to the top