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.

Driver.java 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import org.aspectj.testing.Tester;
  2. // PR#259 "throws Exception" clause is unnecessarily added to Driver.main method
  3. public class Driver {
  4. /*private*/ static String s = "";
  5. public static void main(String[] args) { test(); }
  6. public static void test() {
  7. Driver ts = new Driver();
  8. Tester.checkEqual(s, "-bound-around", "bound");
  9. }
  10. void bind() throws Exception { s += "-bound"; }
  11. public Driver() { bind(); }
  12. }
  13. aspect Aspect {
  14. pointcut bind(): within(Driver) && call(void Driver.bind());
  15. declare soft: Exception: bind();
  16. void around(): bind() {
  17. try {
  18. proceed();
  19. } catch (Exception e) { }
  20. Driver.s += "-around";
  21. }
  22. }
  23. /* HERE IS THE FIXED VERSION OF MARK'S TEST (the one in the bug
  24. database was broken):
  25. public class Driver
  26. {
  27. Driver() throws Exception { }
  28. public static void main(String[] args) {
  29. Driver ts = new Driver();
  30. Driver.bind("foo",ts);
  31. }
  32. static void bind(String s, Object o)
  33. {}
  34. static around() returns Driver: within(Driver) &&
  35. calls(Driver, new() ){
  36. Driver result = null;
  37. try {
  38. result = proceed();
  39. } catch (Exception e){ }
  40. return result;
  41. }
  42. static around(String name) returns void:
  43. within(Driver) &&
  44. calls(Driver, * bind(name,..)) {
  45. try {
  46. proceed(name + "0");
  47. } catch (Exception e) { }
  48. }
  49. static before(String[] args):
  50. within(Driver) && executions(void main(args)){
  51. System.out.println("...");
  52. }
  53. }
  54. */