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.

Figure.java 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. package figures;
  2. import figures.primitives.planar.Point;
  3. import java.awt.Canvas;
  4. aspect Figure {
  5. //pointcut sendSuccess(): cflow(setX()) && !handler(Exception);
  6. public String Point.getName() {
  7. return Point.name;
  8. }
  9. public int figures.primitives.planar.Point.DEFAULT_X = 0;
  10. public pointcut constructions(): call(Point.new(int, int)) || call(SolidPoint.new(int, int, int));
  11. public pointcut moves(FigureElement fe): target(fe) &&
  12. (call(String Point.getName()) ||
  13. call(void FigureElement.incrXY(int, int)) ||
  14. call(void Point.setX(int)) ||
  15. call(void Point.setY(int)) ||
  16. call(void SolidPoint.setZ(int)));
  17. pointcut mainExecution():
  18. execution(int main(*));
  19. pointcut runtimeHandlers(): mainExecution()
  20. || handler(RuntimeException);
  21. public pointcut mumble(): runtimeHandlers();
  22. before(int newValue): set(int *.*) && args(newValue) { }
  23. before(): get(int *.*) { }
  24. before(): constructions() {
  25. System.out.println("> before construction, jp: " + thisJoinPoint.getSignature());
  26. }
  27. before(FigureElement fe): moves(fe) {
  28. System.out.println("> about to move FigureElement at X-coord: ");
  29. }
  30. after(): initialization(Point.new(..)) || staticinitialization(Point) {
  31. System.out.println("> Point initialized");
  32. }
  33. // should be around
  34. after(): mumble() {
  35. System.err.println(">> in after advice...");
  36. //proceed();
  37. }
  38. after(FigureElement fe): target(fe) &&
  39. (call(void FigureElement.incrXY(int, int)) ||
  40. call(void Point.setX(int)) ||
  41. call(void Point.setY(int)) ||
  42. call(void SolidPoint.setZ(int))) {
  43. System.out.println("> yo.");
  44. }
  45. after(FigureElement fe):
  46. target(fe) &&
  47. (call(void FigureElement.incrXY(int, int)) ||
  48. call(void Line.setP1(Point)) ||
  49. call(void Line.setP2(Point)) ||
  50. call(void Point.setX(int)) ||
  51. call(void Point.setY(int))) { }
  52. declare parents: Point extends java.io.Serializable;
  53. declare parents: Point implements java.util.Observable;
  54. // AMC - this next line doesn't make sense!! Can these tests ever
  55. // have been run???
  56. //declare soft: Point: call(* *(..));
  57. }
  58. aspect Checks {
  59. pointcut illegalNewFigElt(): call(FigureElement+.new(..)) &&
  60. !withincode(* Main.main(..));
  61. // pointcut illegalNewFigElt(): execution(FigureElement+.new(..));
  62. declare error: illegalNewFigElt():
  63. "Illegal figure element constructor call.";
  64. declare warning: illegalNewFigElt():
  65. "Illegal figure element constructor call.";
  66. }