Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Wildcard return type on around advice

Title: Wildcard return type on around advice

Hi,

I would like to create around advice for access of objects that extend certain type:

    pointcut myPointcut(Object owner) :

             target(owner)

             get(private MyObject+ my.pckg.*.*);


    ???? around(Object owner) : myPointcut(owner) {

             proceed(owner).doSomthingOnMyObject();

    }


The return type of the around advice is a problem here, it should be an exact match to the type in the join points.

This is a compiler error I got when attempting to declare MyObject as the return type of the advice: "[error] This method must return a result of type MyObject"

I want to intercept every get access to members of "owner" that extend a certain type - and to define one type of advice for all of them.

btw, this can be easily done with "set" access.

My current solution uses the same pointcut, "after" advice and accesses the member using reflection (to the field named: thisJoinPointStaticPart.getSignature().getName())

Is there currently any way to define a wildcard return type? Will this ever be supported? Is there a better way to do this?

Thanks,

/Nitzan


Back to the top