I've been trying for a few days now (way too long) to write a pointcut for Object.equals(), but with no success.
I've tried about everything. I'm using LTW with @Aspect. Here's what I've tried:
Code:@Pointcut("execution(boolean equals(Object))") public void equalsMethod() {}I even tried all methods, and this didn't even pick up the call to Object's equals:Code:@Pointcut("call(boolean equals(Object))") public void equalsMethod() {}
I'm beginning to wonder if advice on Object's methods are not possible with AspectJ. The only time I have been able to see anything making it into my pointcuts is when I override the equals method in on my classes which are being weaved by the LTW.Code:@Pointcut("execution(* *(..))") public void allMethods() {}
Here's my entire aspect:
Code:@Aspect public class NodeEntityEqualsAspect { private Log logger = LogFactory.getLog(NodeEntityEqualsAspect.class); public static NodeEntityEqualsAspect aspectOf() { return new NodeEntityEqualsAspect(); } @Around("equalsMethod()") public Object evaluateEquals(ProceedingJoinPoint jp) throws Throwable { Throwable exception = null; Object retVal = null; try { logger.debug("proceed with original method invocation..."); retVal = jp.proceed(); } catch (Throwable e) { exception = e; throw e; } return retVal; } @Pointcut("execution(boolean Object.equals(Object))") public void equalsMethod() { } }


Reply With Quote