From 90da53cec2fb59df3743822ae79a5b34655a106a Mon Sep 17 00:00:00 2001 From: ehilsdal Date: Wed, 10 Nov 2004 06:03:33 +0000 Subject: 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 --- docs/teaching/exercises/README.txt | 37 ++++++++-- docs/teaching/exercises/answers/Answer3a.java | 2 +- docs/teaching/exercises/answers/Answer3b.java | 8 ++- docs/teaching/exercises/answers/Answer3c.java | 5 +- docs/teaching/exercises/answers/Answer3d.java | 16 +++-- docs/teaching/exercises/answers/Answer3e.java | 17 +++-- docs/teaching/exercises/answers/Answer4b.java | 4 +- docs/teaching/exercises/answers/Answer4c.java | 8 ++- docs/teaching/exercises/answers/Answer4d.java | 13 ++-- docs/teaching/exercises/answers/Answer4e.java | 15 ++-- docs/teaching/exercises/index.html | 100 +++++++++++++++----------- docs/teaching/exercises/support/Log.java | 16 +---- docs/teaching/exercises/tests/CoreTest.java | 79 ++++++++++++++++++++ docs/teaching/exercises/tests/Test.java | 79 -------------------- 14 files changed, 222 insertions(+), 177 deletions(-) create mode 100644 docs/teaching/exercises/tests/CoreTest.java delete mode 100644 docs/teaching/exercises/tests/Test.java (limited to 'docs/teaching/exercises') diff --git a/docs/teaching/exercises/README.txt b/docs/teaching/exercises/README.txt index d06249316..fd1686d4b 100755 --- a/docs/teaching/exercises/README.txt +++ b/docs/teaching/exercises/README.txt @@ -1,9 +1,34 @@ AspectJ Figures Exercises ------------------------------ +This file is really out-of-date. We're in the middle of recovery +from OOPSLA 2004, and we need to move stuff around in this +package. In particular, we need to build in a new structure. + +One idea is that we should have _four_ projects within the +workspace, one for each problem set. There's still a bit of work +necessary to avoid duplicating code here (in CVS) even though we +want to duplicate code in the generated workspaces. + +------------------------------ +Generated Structure + +We want a particular _generated_ structure for users. We're +eventually going to dump to a zip file or a CD. + +Folder: aj-: + /eclipse (arch) + /workspace (noarch) + /packages (noarch) + j2sdk for win, linux + aspectj for everybody + +------------------------------ +------------------------------ + THIS FILE IS OUT-OF-DATE !!! (2003-3-17) -These exercises are designed to be used with AspectJ 1.0.6. +These exercises are designed to be used with AspectJ 1.0.6. THEY MUST NOT BE DISTRIBUTED ELECTRONICALLY WITHOUT THINKING FIRST!!! There may be licence issues with just sticking the junit jar in there @@ -17,7 +42,7 @@ To build distribution zips, use ant -f build.xml. This will create EV-allcontent.zip -- the exercises bundled with the answers -If you don't want to be bothered with specifying where AspectJ is, +If you don't want to be bothered with specifying where AspectJ is, feel free to just do ant -f build.xml answers.zip. By default it will build both exercises and answers. @@ -52,12 +77,12 @@ files, but they might want to be refreshed every now and again. Printing It would be really nice to have an automated solution to generate the -documents, but no such luck. +documents, but no such luck. * index.html should print out with useful page breaks. It should be - separated into four chunks if possible. + separated into four chunks if possible. -* answers in four chunks. +* answers in four chunks. * quick reference sheets. @@ -88,5 +113,5 @@ scripts under CVS. ---- Instructors Since the only difference is the answers, just overwrite the -extraction directory with answers.zip. +extraction directory with answers.zip. 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; diff --git a/docs/teaching/exercises/index.html b/docs/teaching/exercises/index.html index 84b11cd20..a23899c8d 100644 --- a/docs/teaching/exercises/index.html +++ b/docs/teaching/exercises/index.html @@ -3,21 +3,28 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + + id="copyright" or class="presenter". If you're in an A4 + country, don't forget to modify the paper size. - + The gif included at the end is somewhat fragile, + so be careful with different paper sizes. + TODO: There is currently something weird about PDF generation + from this: If generated from a windows machine, it will + generate mac-unfriendly PDF because of the requested windows + font. If the PDF is only used for immediate printing, + that's fine, but if it's used for distribution, bad. +--> - Hands-on Programming with AspectJ — Exercises + Hands-on Programming with AspectJ® — Exercises