You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ArgsAlone.java 803B

12345678910111213141516171819202122232425262728293031
  1. import org.aspectj.testing.Tester;
  2. public class ArgsAlone {
  3. public static void main(String[] args) {
  4. Tester.expectEvent("within 2 method-call");
  5. Tester.expectEvent("within 2 method-execution");
  6. new TargetClass().callInt(2);
  7. Tester.checkAllEvents();
  8. }
  9. }
  10. class TargetClass {
  11. void callInt(int i) {
  12. while (i > 0) { --i; }
  13. }
  14. }
  15. aspect Aspect {
  16. pointcut pc ()
  17. : (call(void TargetClass.callInt(int))
  18. || execution(void TargetClass.callInt(int)));
  19. before(int i)
  20. : !target(Aspect) && args(i) && !target(StringBuffer)
  21. //&& pc() // uncomment to avoid InternalCompilerError
  22. {
  23. Tester.event("within " + i
  24. + " " + thisJoinPointStaticPart.getKind());
  25. }
  26. }