@@ -0,0 +1 @@ | |||
all.ajsym |
@@ -0,0 +1,8 @@ | |||
figures/Debug.java | |||
figures/Figure.java | |||
figures/FigureElement.java | |||
figures/Main.java | |||
figures/composites/Line.java | |||
figures/composites/Square.java | |||
figures/primitives/planar/Point.java | |||
figures/primitives/solid/SolidPoint.java |
@@ -0,0 +1,4 @@ | |||
package editor; | |||
class Editor { } |
@@ -0,0 +1,8 @@ | |||
Checks.class | |||
Debug.class | |||
Element.class | |||
Figure.class | |||
FigureElement.class | |||
Main.class | |||
Main$TestGUI.class | |||
Test.class |
@@ -0,0 +1,7 @@ | |||
package figures; | |||
aspect Debug { | |||
} | |||
@@ -0,0 +1,92 @@ | |||
package figures; | |||
import figures.primitives.planar.Point; | |||
import java.awt.Canvas; | |||
aspect Figure { | |||
//pointcut sendSuccess(): cflow(setX()) && !handler(Exception); | |||
public String Point.getName() { | |||
return Point.name; | |||
} | |||
public int figures.primitives.planar.Point.DEFAULT_X = 0; | |||
public pointcut constructions(): call(Point.new(int, int)) || call(SolidPoint.new(int, int, int)); | |||
public pointcut moves(FigureElement fe): target(fe) && | |||
(call(String Point.getName()) || | |||
call(void FigureElement.incrXY(int, int)) || | |||
call(void Point.setX(int)) || | |||
call(void Point.setY(int)) || | |||
call(void SolidPoint.setZ(int))); | |||
pointcut mainExecution(): | |||
execution(int main(*)); | |||
pointcut runtimeHandlers(): mainExecution() | |||
|| handler(RuntimeException); | |||
public pointcut mumble(): runtimeHandlers(); | |||
before(int newValue): set(int *.*) && args(newValue) { } | |||
before(): get(int *.*) { } | |||
before(): constructions() { | |||
System.out.println("> before construction, jp: " + thisJoinPoint.getSignature()); | |||
} | |||
before(FigureElement fe): moves(fe) { | |||
System.out.println("> about to move FigureElement at X-coord: "); | |||
} | |||
after(): initialization(Point.new(..)) || staticinitialization(Point) { | |||
System.out.println("> Point initialized"); | |||
} | |||
// should be around | |||
after(): mumble() { | |||
System.err.println(">> in after advice..."); | |||
//proceed(); | |||
} | |||
after(FigureElement fe): target(fe) && | |||
(call(void FigureElement.incrXY(int, int)) || | |||
call(void Point.setX(int)) || | |||
call(void Point.setY(int)) || | |||
call(void SolidPoint.setZ(int))) { | |||
System.out.println("> yo."); | |||
} | |||
after(FigureElement fe): | |||
target(fe) && | |||
(call(void FigureElement.incrXY(int, int)) || | |||
call(void Line.setP1(Point)) || | |||
call(void Line.setP2(Point)) || | |||
call(void Point.setX(int)) || | |||
call(void Point.setY(int))) { } | |||
declare parents: Point extends java.io.Serializable; | |||
declare parents: Point implements java.util.Observable; | |||
// AMC - this next line doesn't make sense!! Can these tests ever | |||
// have been run??? | |||
//declare soft: Point: call(* *(..)); | |||
} | |||
aspect Checks { | |||
pointcut illegalNewFigElt(): call(FigureElement+.new(..)) && | |||
!withincode(* Main.main(..)); | |||
// pointcut illegalNewFigElt(): execution(FigureElement+.new(..)); | |||
declare error: illegalNewFigElt(): | |||
"Illegal figure element constructor call."; | |||
declare warning: illegalNewFigElt(): | |||
"Illegal figure element constructor call."; | |||
} |
@@ -0,0 +1,9 @@ | |||
package figures; | |||
public interface FigureElement extends Element { | |||
public void incrXY(int dx, int dy); | |||
} | |||
interface Element { } |
@@ -0,0 +1,56 @@ | |||
package figures; | |||
import figures.primitives.planar.Point; | |||
import figures.primitives.solid.SolidPoint; | |||
class Main { | |||
private static Point startPoint; | |||
public static void main(String[] args) { | |||
try { | |||
System.out.println("> starting..."); | |||
startPoint = makeStartPoint(); | |||
//startPoint.setX(3); new Point(0, 0); | |||
// SolidPoint sp1 = new SolidPoint(1, 3, 3); | |||
// sp1.setZ(1); | |||
// p1.incrXY(3, 3); | |||
} catch (RuntimeException re) { | |||
re.printStackTrace(); | |||
} | |||
System.out.println("> finished."); | |||
} | |||
/** @deprecated use something else */ | |||
public static Point makeStartPoint() { | |||
//return new Point(1, 2); | |||
return null; | |||
} | |||
/** This should produce a deprecation warning with JDK > 1.2 */ | |||
static class TestGUI extends javax.swing.JFrame { | |||
TestGUI() { | |||
this.disable(); | |||
} | |||
} | |||
/** This should produce a porting-deprecation warning. */ | |||
//static pointcut mainExecution(): execution(void main(*)); | |||
} | |||
privileged aspect Test { | |||
pointcut testptct(): call(* *.*(..)); | |||
before(Point p, int newval): target(p) && set(int Point.xx) && args(newval) { | |||
System.err.println("> new value of x is: " + p.x + ", setting to: " + newval); | |||
} | |||
before(int newValue): set(int Point.*) && args(newValue) { | |||
if (newValue < 0) { | |||
throw new IllegalArgumentException("too small"); | |||
} | |||
} | |||
} |
@@ -0,0 +1,3 @@ | |||
BoundedLine.class | |||
Line.class | |||
Square.class |
@@ -0,0 +1,6 @@ | |||
package figures.composites; | |||
class Line { } | |||
class BoundedLine extends Line { } |
@@ -0,0 +1,6 @@ | |||
package figures.composites; | |||
class Square { | |||
private String name = "Square"; | |||
} |
@@ -0,0 +1,4 @@ | |||
StrictlyBoundedPoint.class | |||
PointBoundsException.class | |||
Point.class | |||
BoundedPoint.class |
@@ -0,0 +1,73 @@ | |||
package figures.primitives.planar; | |||
import figures.*; | |||
import java.util.Collection; | |||
public class Point implements FigureElement { | |||
static int xx = -1; | |||
private int x; | |||
private int y; | |||
transient int currVal = 0; | |||
public static String name; | |||
{ | |||
y = -1; | |||
} | |||
static { | |||
xx = -10; | |||
} | |||
int c; int b; int a; | |||
{ | |||
x = 0; | |||
y = 0; | |||
} | |||
static { | |||
Point.name = "2-Dimensional Point"; | |||
} | |||
public Point(int x, int y) { | |||
this.x = x; | |||
this.y = y; | |||
} | |||
int getCurrVal() { | |||
return currVal; | |||
} | |||
/** | |||
* @see Figure#moves | |||
*/ | |||
public int getX() { return x; } | |||
public int getY() { return y; } | |||
public void setX(int x) { this.x = x; } | |||
public void setY(int x) { this.y = x; } | |||
public void incrXY(int dx, int dy) { | |||
setX(getX() + dx); | |||
setY(getY() + dy); | |||
} | |||
public void check(int dx, int dy) | |||
throws ArithmeticException, PointBoundsException { | |||
if (dx < 0 || dy < 0) throw new PointBoundsException(); | |||
} | |||
} | |||
class PointBoundsException extends Exception { } | |||
class BoundedPoint extends Point { | |||
public BoundedPoint(int x, int y) { super(x, y); } | |||
} | |||
class StrictlyBoundedPoint extends BoundedPoint { | |||
public StrictlyBoundedPoint(int x, int y) { super(x, y); } | |||
} | |||
@@ -0,0 +1 @@ | |||
SolidPoint.class |
@@ -0,0 +1,24 @@ | |||
package figures.primitives.solid; | |||
import java.util.Collection; | |||
import java.lang.String; | |||
import figures.primitives.planar.*; | |||
public class SolidPoint extends Point { | |||
private int z; | |||
public SolidPoint(int x, int y, int z) { | |||
super(x, y); | |||
this.z = z; | |||
} | |||
public int getZ() { return z; } | |||
public void setZ(int z) { this.z = z; } | |||
public void incrXY(int dx, int dy) { | |||
super.incrXY(dx, dy); | |||
setZ(getZ() + dx + dy); | |||
} | |||
} |
@@ -0,0 +1 @@ | |||
inheritance.ajsym |
@@ -0,0 +1,22 @@ | |||
package inheritance; | |||
public abstract class A { | |||
public abstract void bar(); | |||
public void foo() { } | |||
public String toString() { | |||
// mumble | |||
return ""; | |||
} | |||
} | |||
class B extends A { | |||
public void bar() { } | |||
public void foo() { } | |||
} |
@@ -0,0 +1 @@ | |||
A.java |