Project: AspectJ
Bug 112756 ajdt compiler generate false warnings
Reported: 2005-10-16 23:56:55 | Status: resolved fixed

I was working on aspect that should raise an error for junit test methods that didn't use any assertions. Apparently I had to use pointcut like "call(void Assert+.assert*(..))" on which ajdt compiler complained about using "assert" keyword. I don't think such warning should be shown in such case. Anyway, here is the complete aspect code. import junit.framework.Test; import junit.framework.Assert; import junit.framework.AssertionFailedError; public aspect AssertionCounter { private ThreadLocal counts = new ThreadLocal(); public pointcut testMethodExecution() : execution(void Test+.test*()); public pointcut assertCall() : cflow(testMethodExecution()) && call(void Assert+.assert*(..)); void around() : testMethodExecution() { counts.set( new Counter()); proceed(); if(((Counter) counts.get()).getCount()==0) { throw new AssertionFailedError("No assertions had been called"); } } before() : assertCall() { ((Counter) counts.get()).inc(); } }

Files changed in fix:
tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java