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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
import org.aspectj.testing.Tester;
import java.lang.reflect.*;
import java.util.*;
public class InterfaceMethods {
public static void main(String[] args) {
new InterfaceMethods().realMain(args);
}
final static Object[] tuples = new Object[] {
"clone", null, null,
"equals", new Class[]{Object.class}, new Object[]{""},
"finalize", null, null,
"getClass", null, null,
"hashCode", null, null,
"notify", null, null,
"notifyAll", null, null,
"toString", null, null,
"wait", null, null,
"waitL", new Class[]{long.class}, new Object[]{new Long(3L)},
"waitLI", new Class[]{long.class, int.class}, new Object[]{new Long(4L), new Integer(5)},
};
final List list = new Vector();
{
for (int i = 0; i < tuples.length; i += 3) {
List tuple = new Vector();
tuple.add(tuples[i]+ "New");
tuple.add(tuples[i+1] == null ? new Class[]{} : tuples[i+1]);
tuple.add(tuples[i+2] == null ? new Object[]{} : tuples[i+2]);
list.add(tuple);
}
}
public void realMain(String[] argv) {
Iterator iter = list.iterator();
while (iter.hasNext()) {
List tuple = (List) iter.next();
String name = (String) tuple.get(0);
Class[] params = (Class[]) tuple.get(1);
Object[] args = (Object[]) tuple.get(2);
boolean ran = false;
Throwable caught = null;
try {
Object o = new SomeClass();
o.getClass().getMethod(name, params).invoke(o, args);
ran = true;
} catch (Throwable t) {
caught = t;
} finally {
Tester.check(ran, name + " didn't run" + (caught != null ? ":"+caught : ""));
}
}
}
}
interface SomeType {}
class SomeClass implements SomeType {
// public Object cloneNew() { try { return clone(); } catch (Throwable t) {} return null; }
// public boolean equalsNew(Object o) { return equals(o); }
// public void finalizeNew() { try { finalize(); } catch (Throwable t) {} }
// public Class getClassNew() { return getClass(); }
// public int hashCodeNew() { return hashCode(); }
// public void notifyNew() { try { notify(); } catch (Throwable t) {} }
// public void notifyAllNew() { try { notifyAll(); } catch (Throwable t) {} }
// public String toStringNew() { return toString(); }
// public void waitNew() { try { wait(); } catch (Throwable t) {} }
// public void waitLNew(long l) { try { wait(l); } catch (Throwable t) {} }
// public void waitLINew(long l, int i) { try { wait(l,i); } catch (Throwable t) {} }
}
aspect AspectToIntroduce_clone {
introduction SomeType {
public Object cloneNew() { try { return clone(); } catch (Throwable t) {} return null; }
}
}
aspect AspectToIntroduce_equals {
introduction SomeType {
public boolean equalsNew(Object o) { return equals(o); }
}
}
aspect AspectToIntroduce_finalize {
introduction SomeType {
public void finalizeNew() { try { finalize(); } catch (Throwable t) {} }
}
}
aspect AspectToIntroduce_getClass {
introduction SomeType {
public Class getClassNew() { return getClass(); }
}
}
aspect AspectToIntroduce_hashCode {
introduction SomeType {
public int hashCodeNew() { return hashCode(); }
}
}
aspect AspectToIntroduce_notify {
introduction SomeType {
public void notifyNew() { try { notify(); } catch (Throwable t) {} }
}
}
aspect AspectToIntroduce_notifyAll {
introduction SomeType {
public void notifyAllNew() { try { notifyAll(); } catch (Throwable t) {} }
}
}
aspect AspectToIntroduce_toString {
introduction SomeType {
public String toStringNew() { return toString(); }
}
}
aspect AspectToIntroduce_wait {
introduction SomeType {
public void waitNew() { try { wait(); } catch (Throwable t) {} }
}
}
aspect AspectToIntroduce_waitL {
introduction SomeType {
public void waitLNew(long l) { try { wait(l); } catch (Throwable t) {} }
}
}
aspect AspectToIntroduce_waitLI {
introduction SomeType {
public void waitLINew(long l, int i) { try { wait(l,i); } catch (Throwable t) {} }
}
}
|