summaryrefslogtreecommitdiffstats
path: root/ajdoc/testdata/figures-demo/figures/Enforcement.java
blob: 95ea2e78020264db43fb1adcd9e700915564ad67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
 * (c) Copyright 2001 MyCorporation.
 * All Rights Reserved.
 */
 
package figures;

public aspect Enforcement {

	before(int newValue): set(int Point.*) && args(newValue) {
		if (newValue < 0) {
				throw new IllegalArgumentException("> val: " + newValue + " is too small");
		}	
	}

	declare warning: call(void Canvas.updateHistory(..)) && !within(Enforcement): "";

	after() returning: call(void FigureElement+.set*(..)) {
		//Canvas.updateHistory();	
	}

	declare error: 
		set(private * FigureElement+.*) &&
		!(withincode(* FigureElement+.set*(..)) || withincode(FigureElement+.new(..))):
			"should only assign to fileds from set methods";

}





















//  	before(int newValue): set(int Point.*) && args(newValue) {
//  		if (newValue < 0) {
//  			throw new IllegalArgumentException("> value: " + newValue + " too small");
//  		}
//  	}
//
//	declare warning: call(void Canvas.updateHistory(..)) && !within(Enforcement): 
//		"found call";
//
//	after() returning: call(void FigureElement+.set*(..)) {
//			Canvas.updateHistory();
//	}
//	
//	declare error: 
//		set(private * FigureElement+.*) &&
//		!(withincode(* FigureElement+.set*(..)) || withincode(FigureElement+.new(..))):
//		"should only assign to fields from set methods";