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.

Fixes.java 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import org.aspectj.testing.Tester;
  2. public class Fixes {
  3. public static void main(String[] args) { new Fixes().realMain(args); }
  4. public void realMain(String[] args) {
  5. new TheObject().go();
  6. }
  7. }
  8. class TheObject {
  9. private int private_int;
  10. void go () {}
  11. }
  12. privileged aspect TheAspect pertarget(target(TheObject)) {
  13. private TheObject theObject;
  14. after() returning(TheObject obj): call(new()) {
  15. theObject = obj;
  16. }
  17. after() returning(): call(* realMain(..)) {
  18. start();
  19. postinc();
  20. preinc();
  21. postdec();
  22. predec();
  23. }
  24. void start() {
  25. theObject.private_int = 3;
  26. }
  27. void postinc() {
  28. enter("postinc");
  29. a(theObject.private_int,3);
  30. theObject.private_int++;
  31. a(theObject.private_int,4);
  32. }
  33. void preinc() {
  34. enter("preinc");
  35. a(theObject.private_int,4);
  36. ++theObject.private_int;
  37. a(theObject.private_int,5);
  38. }
  39. void postdec() {
  40. enter("postdec");
  41. a(theObject.private_int,5);
  42. theObject.private_int--;
  43. a(theObject.private_int,4);
  44. }
  45. void predec() {
  46. enter("predec");
  47. a(theObject.private_int,4);
  48. --theObject.private_int;
  49. a(theObject.private_int,3);
  50. }
  51. private String msg;
  52. void enter(String msg) {
  53. this.msg = msg;
  54. }
  55. void a(int a, int b) {
  56. Tester.checkEqual(a,b,msg);
  57. }
  58. }