aboutsummaryrefslogtreecommitdiffstats
path: root/docs/teaching/exercises/answers
diff options
context:
space:
mode:
authorehilsdal <ehilsdal>2004-11-10 06:03:33 +0000
committerehilsdal <ehilsdal>2004-11-10 06:03:33 +0000
commit90da53cec2fb59df3743822ae79a5b34655a106a (patch)
tree0b50d12403b79b7f40f528d7e2b81d6dc710f9ef /docs/teaching/exercises/answers
parentc9363fd12ac1d276af0bb63b87e893c7cef50ecf (diff)
downloadaspectj-90da53cec2fb59df3743822ae79a5b34655a106a.tar.gz
aspectj-90da53cec2fb59df3743822ae79a5b34655a106a.zip
revised with info from OOPSLA 2004:
renaming support.Log.log to support.Log.write renaming test.Test to test.CoreTest (r)ing aspectj clearing up a few random things
Diffstat (limited to 'docs/teaching/exercises/answers')
-rw-r--r--docs/teaching/exercises/answers/Answer3a.java2
-rw-r--r--docs/teaching/exercises/answers/Answer3b.java8
-rw-r--r--docs/teaching/exercises/answers/Answer3c.java5
-rwxr-xr-xdocs/teaching/exercises/answers/Answer3d.java16
-rwxr-xr-xdocs/teaching/exercises/answers/Answer3e.java17
-rw-r--r--docs/teaching/exercises/answers/Answer4b.java4
-rw-r--r--docs/teaching/exercises/answers/Answer4c.java8
-rw-r--r--docs/teaching/exercises/answers/Answer4d.java13
-rw-r--r--docs/teaching/exercises/answers/Answer4e.java15
9 files changed, 52 insertions, 36 deletions
diff --git a/docs/teaching/exercises/answers/Answer3a.java b/docs/teaching/exercises/answers/Answer3a.java
index 3bbfb1e98..c4d4d5d81 100644
--- a/docs/teaching/exercises/answers/Answer3a.java
+++ b/docs/teaching/exercises/answers/Answer3a.java
@@ -16,6 +16,6 @@ import support.Log;
aspect Answer3a {
before(): execution(public * *(..)) && within(figures.*) {
- Log.log(thisJoinPoint.toString());
+ Log.write(thisJoinPoint);
}
}
diff --git a/docs/teaching/exercises/answers/Answer3b.java b/docs/teaching/exercises/answers/Answer3b.java
index b88e45780..7e05ec62e 100644
--- a/docs/teaching/exercises/answers/Answer3b.java
+++ b/docs/teaching/exercises/answers/Answer3b.java
@@ -21,9 +21,11 @@ import figures.FigureElement;
aspect Answer3b {
before(Object o):
execution(public * *(..))
- && within(figures.*) && target(o)
- && !withincode(public String toString(..)) // don't overflow!
+ && !execution(public String toString(..))
+ // or perhaps !cflow(adviceexecution())
+ && within(figures.*)
+ && target(o)
{
- Log.log(thisJoinPoint.toString() + " at " + o);
+ Log.write(thisJoinPoint + " at " + o);
}
}
diff --git a/docs/teaching/exercises/answers/Answer3c.java b/docs/teaching/exercises/answers/Answer3c.java
index 33483bc21..a8b7164f0 100644
--- a/docs/teaching/exercises/answers/Answer3c.java
+++ b/docs/teaching/exercises/answers/Answer3c.java
@@ -18,7 +18,8 @@ import figures.*;
aspect Answer3c {
before():
- execution(void Group.add(FigureElement)) && args(Point) {
- Log.log("adding Point");
+ execution(void Group.add(FigureElement))
+ && args(Point) {
+ Log.write("adding Point");
}
}
diff --git a/docs/teaching/exercises/answers/Answer3d.java b/docs/teaching/exercises/answers/Answer3d.java
index 6a3238b5f..426076602 100755
--- a/docs/teaching/exercises/answers/Answer3d.java
+++ b/docs/teaching/exercises/answers/Answer3d.java
@@ -18,13 +18,15 @@ import figures.*;
aspect Answer3d {
- boolean Point.inGroup = false;
+ private boolean Point.inGroup = false;
- before(Point p): execution(void Group.add(FigureElement)) && args(p) {
- if (p.inGroup) {
- throw new IllegalStateException();
- } else {
- p.inGroup = true;
- }
+ before(Point p):
+ execution(void Group.add(FigureElement))
+ && args(p) {
+ if (p.inGroup) {
+ throw new IllegalStateException();
+ } else {
+ p.inGroup = true;
+ }
}
}
diff --git a/docs/teaching/exercises/answers/Answer3e.java b/docs/teaching/exercises/answers/Answer3e.java
index 8e0018df8..2b3882026 100755
--- a/docs/teaching/exercises/answers/Answer3e.java
+++ b/docs/teaching/exercises/answers/Answer3e.java
@@ -18,13 +18,16 @@ import figures.*;
aspect Answer3e {
- Group Point.containingGroup = null;
+ private Group Point.containingGroup = null;
- before(Group g, Point p): execution(void Group.add(FigureElement)) && this(g) && args(p) {
- if (p.containingGroup != null) {
- throw new IllegalStateException(p.containingGroup.toString());
- } else {
- p.containingGroup = g;
- }
+ before(Group g, Point p):
+ execution(void Group.add(FigureElement))
+ && this(g)
+ && args(p) {
+ if (p.containingGroup != null) {
+ throw new IllegalStateException(p.containingGroup.toString());
+ } else {
+ p.containingGroup = g;
+ }
}
}
diff --git a/docs/teaching/exercises/answers/Answer4b.java b/docs/teaching/exercises/answers/Answer4b.java
index 33649c4e1..657312083 100644
--- a/docs/teaching/exercises/answers/Answer4b.java
+++ b/docs/teaching/exercises/answers/Answer4b.java
@@ -20,8 +20,8 @@ aspect Answer4b {
private Rectangle Group.cache = null;
Rectangle around(Group g):
- execution(Rectangle Group.getBounds()) && this(g)
- {
+ execution(Rectangle Group.getBounds())
+ && this(g) {
if (g.cache == null) {
g.cache = proceed(g);
}
diff --git a/docs/teaching/exercises/answers/Answer4c.java b/docs/teaching/exercises/answers/Answer4c.java
index 75e1123dd..172859658 100644
--- a/docs/teaching/exercises/answers/Answer4c.java
+++ b/docs/teaching/exercises/answers/Answer4c.java
@@ -20,15 +20,17 @@ aspect Answer4c {
private Rectangle Group.cache = null;
Rectangle around(Group g):
- execution(Rectangle Group.getBounds()) && this(g)
- {
+ execution(Rectangle Group.getBounds())
+ && this(g) {
if (g.cache == null) {
g.cache = proceed(g);
}
return g.cache;
}
- before(Group g): call(void move(int, int)) && target(g) {
+ before(Group g):
+ call(void move(int, int))
+ && target(g) {
g.cache = null;
}
}
diff --git a/docs/teaching/exercises/answers/Answer4d.java b/docs/teaching/exercises/answers/Answer4d.java
index 58d31d44c..6b0b63c20 100644
--- a/docs/teaching/exercises/answers/Answer4d.java
+++ b/docs/teaching/exercises/answers/Answer4d.java
@@ -22,21 +22,24 @@ aspect Answer4d {
private Group Point.enclosingGroup = null;
before(Point p, Group g):
- execution(void add(FigureElement)) && args(p) && target(g)
- {
+ execution(void add(FigureElement))
+ && args(p)
+ && target(g) {
p.enclosingGroup = g;
}
Rectangle around(Group g):
- execution(Rectangle Group.getBounds()) && this(g)
- {
+ execution(Rectangle Group.getBounds())
+ && this(g) {
if (g.cache == null) {
g.cache = proceed(g);
}
return g.cache;
}
- before(Point p): set(* Point.*) && target(p) {
+ before(Point p):
+ set(* Point.*)
+ && target(p) {
if (p.enclosingGroup != null) {
p.enclosingGroup.cache = null;
}
diff --git a/docs/teaching/exercises/answers/Answer4e.java b/docs/teaching/exercises/answers/Answer4e.java
index 2a6e0aefd..6ee534ff6 100644
--- a/docs/teaching/exercises/answers/Answer4e.java
+++ b/docs/teaching/exercises/answers/Answer4e.java
@@ -21,22 +21,25 @@ aspect Answer4e {
private Rectangle Group.cache = null;
private Group FigureElement.enclosingGroup = null;
- before(FigureElement p, Group g):
- execution(void add(FigureElement)) && args(p) && target(g)
- {
+ before(FigureElement p, Group g):
+ execution(void add(FigureElement))
+ && args(p)
+ && target(g) {
p.enclosingGroup = g;
}
Rectangle around(Group g):
- execution(Rectangle Group.getBounds()) && this(g)
- {
+ execution(Rectangle Group.getBounds())
+ && this(g) {
if (g.cache == null) {
g.cache = proceed(g);
}
return g.cache;
}
- before(Point p): set(* Point.*) && target(p) {
+ before(Point p):
+ set(* Point.*)
+ && target(p) {
FigureElement fe = p;
while (fe.enclosingGroup != null) {
fe.enclosingGroup.cache = null;