summaryrefslogtreecommitdiffstats
path: root/tests/java5/annotations/ajdkExamples/AnnotationsInSignaturePatterns.aj
blob: 86bfbe4154229f725f1c9f6bfb4028d5dc1ecb97 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import org.xyz.*; import anns.*;
//import org.abc.*;
import java.util.List;

public aspect AnnotationsInSignaturePatterns {
	
	declare warning : set(@SensitiveData * *) : "@SensitiveData * *";
	declare warning : set(@SensitiveData List org.xyz..*.*) : "@SensitiveData List org.xyz..*.*";
	declare warning : set((@SensitiveData *) org.xyz..*.*) : "(@SensitiveData *) org.xyz..*.*";
	declare warning : set(@Foo (@Goo *) (@Hoo *).*) : "@Foo (@Goo *) (@Hoo *).*";
	declare warning : set(@Persisted @Classified * *) : "@Persisted @Classified * *";
	
	declare warning : execution(@Oneway * *(..)) : "@Oneway * *(..)";
	declare warning : execution(@Transaction * (@Persisted org.xyz..*).*(..)) : "@Transaction * (@Persisted org.xyz..*).*(..)";
	declare warning : execution(* *.*(@Immutable *,..)) : "* *.*(@Immutable *,..)";
	
	declare warning : within(@Secure *) : "within(@Secure *)";
	declare warning : staticinitialization(@Persisted *) : "staticinitialization(@Persisted *)";
	declare warning : call(@Oneway * *(..)) : "call(@Oneway * *(..))";
	declare warning : execution(public (@Immutable *) org.xyz..*.*(..)) : "execution(public (@Immutable *) org.xyz..*.*(..))";
	declare warning : set(@Cachable * *) : "set(@Cachable * *)";
	declare warning : handler(!@Catastrophic *) : "handler(!@Catastrophic *)";

}

@interface Foo {}
@interface Goo {}
@interface Hoo {}

class A {
	
	@SensitiveData int x = 1;
	
	@Persisted int y = 2;
	
	@Classified int z = 3;
	
	@Persisted @Classified int a = 99;
}


@Goo class G {
	
	@Oneway void g() {}
	void g2() {}
	
}
@Hoo class H {
	
	 @Foo G g = new G();
	 
	 void doIt(II i) {}
	 void doIt(II i, G g) {}
	 void doIt(II i, G g, H h) {}
	 void doIt(G g, H h) {
	 	g.g();
	 }
} 

@Immutable class II {}

@Secure class S {
	int i = 1;
}

@Persisted class P {}

@Catastrophic class NastyException extends Exception {}

class OKException extends Exception {}

class InError {

	public void ab() {
		try {
			a();
			b();
		} catch (NastyException nEx) {
			; 
		} catch (OKException okEx) {
			;
		}				
	}
	
	private void a() throws NastyException {
		throw new NastyException();
	}
	
	private void b() throws OKException {
		throw new OKException();
	}
}