Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 992a015

Browse files
authored
Merge pull request #415 from aschackmull/java/obinit-extraction
Java: Account for extraction of calls to <obinit>.
2 parents 9ee4d3b + 46bebc8 commit 992a015

7 files changed

Lines changed: 45 additions & 4 deletions

File tree

java/ql/src/definitions.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ class LocationOverridingImportStaticTypeMember extends ImportStaticTypeMember {
158158
}
159159

160160
Element definition(Element e, string kind) {
161-
e.(MethodAccess).getMethod().getSourceDeclaration() = result and kind = "M"
161+
e.(MethodAccess).getMethod().getSourceDeclaration() = result and
162+
kind = "M" and
163+
not result instanceof InitializerMethod
162164
or
163165
e.(TypeAccess).getType().(RefType).getSourceDeclaration() = result and kind = "T"
164166
or
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
public class C {
2+
3+
private Elem s1 = new Elem();
4+
private final Elem s2 = new Elem();
5+
private Elem s3;
6+
private static Elem s4 = new Elem();
7+
8+
public static void main(String[] args){
9+
C c = new C();
10+
c.func();
11+
}
12+
13+
private C() {
14+
this.s3 = new Elem();
15+
}
16+
17+
public void func(){
18+
sink(s1);
19+
sink(s2);
20+
sink(s3);
21+
sink(s4);
22+
}
23+
24+
public static void sink(Object o) { }
25+
26+
public static class Elem { }
27+
}

java/ql/test/library-tests/dataflow/fields/flow.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@
1515
| B.java:4:14:4:23 | new Elem(...) | B.java:8:10:8:22 | b2.box1.elem2 |
1616
| B.java:12:14:12:23 | new Elem(...) | B.java:15:10:15:22 | b2.box1.elem1 |
1717
| B.java:12:14:12:23 | new Elem(...) | B.java:16:10:16:22 | b2.box1.elem2 |
18+
| C.java:3:21:3:30 | new Elem(...) | C.java:18:10:18:11 | s1 |
19+
| C.java:4:27:4:36 | new Elem(...) | C.java:19:10:19:11 | s2 |
20+
| C.java:6:28:6:37 | new Elem(...) | C.java:21:10:21:11 | s4 |
21+
| C.java:14:15:14:24 | new Elem(...) | C.java:20:10:20:11 | s3 |

java/ql/test/library-tests/structure/EnclosingCallables.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
| structure/A.java:15:17:15:17 | A | --none-- |
77
| structure/A.java:16:2:16:4 | int | --none-- |
88
| structure/A.java:21:2:21:4 | int | --none-- |
9+
| structure/A.java:24:7:24:7 | <obinit>(...) | D |
910
| structure/A.java:24:17:24:17 | B | --none-- |
1011
| structure/A.java:25:4:25:13 | new (...) | <obinit> |
1112
| structure/A.java:25:8:25:8 | C | <obinit> |

java/ql/test/library-tests/structure/EnclosingStatements.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
| structure/A.java:15:17:15:17 | A | --none-- |
77
| structure/A.java:16:2:16:4 | int | --none-- |
88
| structure/A.java:21:2:21:4 | int | --none-- |
9+
| structure/A.java:24:7:24:7 | <obinit>(...) | stmt on line 24 |
910
| structure/A.java:24:17:24:17 | B | --none-- |
1011
| structure/A.java:25:4:25:13 | new (...) | stmt on line 25 |
1112
| structure/A.java:25:8:25:8 | C | stmt on line 25 |

java/ql/test/library-tests/successors/TestLoopBranch/TestSucc.expected

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,19 @@
229229
| TestLoopBranch.java:105:7:105:11 | ... + ... | TestLoopBranch.java:105:3:105:11 | ...=... |
230230
| TestLoopBranch.java:105:11:105:11 | y | TestLoopBranch.java:105:7:105:11 | ... + ... |
231231
| TestLoopBranch.java:106:3:106:9 | stmt | TestLoopBranch.java:7:14:7:14 | f |
232-
| TestLoopBranch.java:109:9:109:22 | super(...) | TestLoopBranch.java:111:3:111:10 | stmt |
232+
| TestLoopBranch.java:109:9:109:22 | <obinit>(...) | TestLoopBranch.java:111:3:111:10 | stmt |
233+
| TestLoopBranch.java:109:9:109:22 | stmt | TestLoopBranch.java:109:9:109:22 | <obinit>(...) |
234+
| TestLoopBranch.java:109:9:109:22 | super(...) | TestLoopBranch.java:109:9:109:22 | stmt |
233235
| TestLoopBranch.java:110:2:113:2 | stmt | TestLoopBranch.java:109:9:109:22 | super(...) |
234236
| TestLoopBranch.java:111:3:111:9 | ...=... | TestLoopBranch.java:112:3:112:10 | stmt |
235237
| TestLoopBranch.java:111:3:111:10 | stmt | TestLoopBranch.java:111:8:111:9 | 33 |
236238
| TestLoopBranch.java:111:8:111:9 | 33 | TestLoopBranch.java:111:3:111:9 | ...=... |
237239
| TestLoopBranch.java:112:3:112:9 | ...=... | TestLoopBranch.java:109:9:109:22 | TestLoopBranch |
238240
| TestLoopBranch.java:112:3:112:10 | stmt | TestLoopBranch.java:112:8:112:9 | 44 |
239241
| TestLoopBranch.java:112:8:112:9 | 44 | TestLoopBranch.java:112:3:112:9 | ...=... |
240-
| TestLoopBranch.java:115:9:115:22 | super(...) | TestLoopBranch.java:117:3:117:9 | stmt |
242+
| TestLoopBranch.java:115:9:115:22 | <obinit>(...) | TestLoopBranch.java:117:3:117:9 | stmt |
243+
| TestLoopBranch.java:115:9:115:22 | stmt | TestLoopBranch.java:115:9:115:22 | <obinit>(...) |
244+
| TestLoopBranch.java:115:9:115:22 | super(...) | TestLoopBranch.java:115:9:115:22 | stmt |
241245
| TestLoopBranch.java:116:2:119:2 | stmt | TestLoopBranch.java:115:9:115:22 | super(...) |
242246
| TestLoopBranch.java:117:3:117:8 | ...=... | TestLoopBranch.java:118:3:118:9 | stmt |
243247
| TestLoopBranch.java:117:3:117:9 | stmt | TestLoopBranch.java:117:8:117:8 | i |

java/ql/test/library-tests/successors/TestThrow2/TestSucc.expected

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
| TestThrow2.java:3:7:3:16 | <obinit>(...) | TestThrow2.java:3:7:3:16 | TestThrow2 |
2+
| TestThrow2.java:3:7:3:16 | stmt | TestThrow2.java:3:7:3:16 | <obinit>(...) |
13
| TestThrow2.java:3:7:3:16 | stmt | TestThrow2.java:3:7:3:16 | super(...) |
24
| TestThrow2.java:3:7:3:16 | stmt | TestThrow2.java:5:2:11:2 | stmt |
3-
| TestThrow2.java:3:7:3:16 | super(...) | TestThrow2.java:3:7:3:16 | TestThrow2 |
5+
| TestThrow2.java:3:7:3:16 | super(...) | TestThrow2.java:3:7:3:16 | stmt |
46
| TestThrow2.java:5:2:11:2 | stmt | TestThrow2.java:6:3:10:3 | stmt |
57
| TestThrow2.java:6:3:10:3 | stmt | TestThrow2.java:6:7:8:3 | stmt |
68
| TestThrow2.java:6:7:8:3 | stmt | TestThrow2.java:7:4:7:13 | stmt |

0 commit comments

Comments
 (0)