-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathA.java
More file actions
99 lines (78 loc) · 1.89 KB
/
A.java
File metadata and controls
99 lines (78 loc) · 1.89 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
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
public class A {
static void sink(Object x) { }
static Object source(String srctag) { return null; }
static class C1 {
C1() { }
C1(Object x) {
foo(x);
}
void wrapFoo1(Object x) {
foo(x);
}
void wrapFoo2(Object x) {
this.foo(x);
}
void foo(Object x) {
Object c1 = x;
sink(c1); // $ hasValueFlow=c.1 hasValueFlow=c.2 hasValueFlow=c.3 hasValueFlow=C1 hasValueFlow=C1.1 hasValueFlow=C1.2 hasValueFlow=C1.3
}
}
static class C2 extends C1 {
C2() { }
C2(Object x) {
super(x);
}
void foo(Object x) {
Object c2 = x;
sink(c2); // $ hasValueFlow=2 hasValueFlow=c.1 hasValueFlow=c.2 hasValueFlow=c.3 hasValueFlow=C2 hasValueFlow=C2.1 hasValueFlow=C2.2 hasValueFlow=C2.3
}
void callWrapFoo2() {
wrapFoo2(source("2"));
}
}
static void wrapFoo3(C1 c1, Object x) {
c1.foo(x);
}
void test(C1 c) {
c.wrapFoo1(source("c.1"));
c.wrapFoo2(source("c.2"));
wrapFoo3(c, source("c.3"));
new C1(source("C1"));
new C1().wrapFoo1(source("C1.1"));
new C1().wrapFoo2(source("C1.2"));
wrapFoo3(new C1(), source("C1.3"));
new C2(source("C2"));
new C2().wrapFoo1(source("C2.1"));
new C2().wrapFoo2(source("C2.2"));
wrapFoo3(new C2(), source("C2.3"));
}
static class Sup {
void wrap(Object x) {
tgt(x);
}
void tgt(Object x) {
sink(x); // $ hasValueFlow=s
}
}
static class A1 extends Sup {
void tgt(Object x) {
sink(x); // $ hasValueFlow=s hasValueFlow=s12
}
}
static class A2 extends Sup {
void tgt(Object x) {
sink(x); // $ hasValueFlow=s hasValueFlow=s12
}
}
static class A3 extends Sup {
void tgt(Object x) {
sink(x); // $ hasValueFlow=s
}
}
void test2(Sup s) {
s.wrap(source("s"));
if (s instanceof A1 || s instanceof A2) {
s.wrap(source("s12"));
}
}
}