-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathA.java
More file actions
48 lines (40 loc) · 1.12 KB
/
A.java
File metadata and controls
48 lines (40 loc) · 1.12 KB
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
import java.util.Map;
import java.util.function.*;
public class A {
Object source(String state) {
return null;
}
void sink(Object x, String state) {}
void stateBarrier(Object x, String state) {}
Object step(Object x, String s1, String s2) {
return null;
}
void check(Object x) {}
void test1() {
Object x = source("A");
check(x); // $ pFwd=A-A pRev=A-B
x = step(x, "A", "B");
check(x); // $ pFwd=A-B pRev=A-A pRev=B-B
sink(x, "A");
sink(x, "B"); // $ flow=A
}
void test2(Supplier<Boolean> b) {
Object x = b.get() ? source("A") : source("B");
check(x); // $ pFwd=A-A pFwd=B-B pRev=B-B pRev=B-C pRev=C-C
x = b.get() ? x : step(x, "B", "C");
check(x); // $ pFwd=A-A pFwd=B-B pFwd=B-C pRev=B-B pRev=C-C
stateBarrier(x, "A");
check(x); // $ pFwd=B-B pFwd=B-C pRev=A-A pRev=B-B pRev=C-C
sink(x, "A");
sink(x, "B"); // $ flow=B
sink(x, "C"); // $ flow=B
}
void test3(Map m) {
// Test implicit reads
Object x = source("A");
m.put("k", x);
sink(m, "A"); // $ flow=A
Object y = step(m, "A", "B");
sink(y, "B"); // $ flow=A
}
}