Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import org.aspectj.testing.Tester;
  2. import org.aspectj.lang.*;
  3. /** @testcase PR#658 simple call join point tests for JoinPoint SourceLocation context */
  4. public class SourceLocationCall {
  5. public static void main(String[] args) {
  6. new SourceLocationCall().maincall();
  7. }
  8. public void maincall(){}
  9. }
  10. aspect Tracing {
  11. static void check(String label, JoinPoint jp, JoinPoint.StaticPart sp) {
  12. // System.err.println("checking " + label + " " + jp + " " + sp
  13. // + " - " + jp.getSourceLocation()
  14. // + " - " + sp.getSourceLocation() );
  15. if (null == jp) {
  16. Tester.check(false, "null JoinPoint@" + label);
  17. } else {
  18. Tester.check(null != jp.getSourceLocation(),
  19. "null jp source location@" + label);
  20. }
  21. if (null == sp) {
  22. Tester.check(false, "null JoinPoint.StaticPart@"+label);
  23. } else {
  24. Tester.check(null != sp.getSourceLocation(),
  25. "null sp source location@" + label);
  26. }
  27. }
  28. pointcut trace1()
  29. : call(void SourceLocationCall.maincall(..));
  30. // ok
  31. //: within(SourceLocationCall) ;
  32. //: cflow(execution(void SourceLocationCall.main(String[]))) && !within(Tracing) ;
  33. //: within(SourceLocationCall) && call(* *(..));
  34. //: execution(* SourceLocationCall.*(..));
  35. //: call(void SourceLocationCall.main*(..)) && within(*);
  36. // fail
  37. //: call(void SourceLocationCall.main*(..));
  38. //: call(* SourceLocationCall.*(..));
  39. //: call(void SourceLocationCall.*(..));
  40. // same result for static calls and instance calls
  41. // same result for before and after
  42. before() : trace1() {
  43. check("before() : trace1()", thisJoinPoint, thisJoinPointStaticPart);
  44. }
  45. after() : trace1() {
  46. check("after() : trace1()", thisJoinPoint, thisJoinPointStaticPart);
  47. }
  48. before(): call(void SourceLocationCall.main(..)) {
  49. Tester.check(thisJoinPoint.getSourceLocation() == null, "main call");
  50. Tester.check(thisJoinPoint.getThis() == null, "main call");
  51. }
  52. }