Java: update exception models and add test · itsallaboutpython/codeql@0854654 · GitHub
Skip to content

Commit 0854654

Browse files
Jami CogswellJami Cogswell
authored andcommitted
Java: update exception models and add test
1 parent 56acfdf commit 0854654

4 files changed

Lines changed: 29 additions & 8 deletions

File tree

java/ql/lib/ext/java.lang.model.yml

Lines changed: 4 additions & 8 deletions
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
public class Test {
2+
3+
void sink(Object o) { }
4+
5+
Object source() { return null; }
6+
7+
public void test() throws Exception {
8+
Exception e1 = new RuntimeException((String)source());
9+
sink((String)e1.getMessage()); // $hasValueFlow
10+
11+
Exception e2 = new RuntimeException((Throwable)source());
12+
sink((Throwable)e2.getCause()); // $hasValueFlow
13+
14+
Exception e3 = new IllegalArgumentException((String)source());
15+
sink((String)e3.getMessage()); // $hasValueFlow
16+
17+
Exception e4 = new IllegalStateException((String)source());
18+
sink((String)e4.getMessage()); // $hasValueFlow
19+
20+
Throwable t = new Throwable((Throwable)source());
21+
sink((Throwable)t.getCause()); // $hasValueFlow
22+
}
23+
}

java/ql/test/ext/TestModels/test.expected

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions

0 commit comments

Comments
 (0)