mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
Java: update exception models and add test
This commit is contained in:
23
java/ql/test/ext/TestModels/Test.java
Normal file
23
java/ql/test/ext/TestModels/Test.java
Normal file
@@ -0,0 +1,23 @@
|
||||
public class Test {
|
||||
|
||||
void sink(Object o) { }
|
||||
|
||||
Object source() { return null; }
|
||||
|
||||
public void test() throws Exception {
|
||||
Exception e1 = new RuntimeException((String)source());
|
||||
sink((String)e1.getMessage()); // $hasValueFlow
|
||||
|
||||
Exception e2 = new RuntimeException((Throwable)source());
|
||||
sink((Throwable)e2.getCause()); // $hasValueFlow
|
||||
|
||||
Exception e3 = new IllegalArgumentException((String)source());
|
||||
sink((String)e3.getMessage()); // $hasValueFlow
|
||||
|
||||
Exception e4 = new IllegalStateException((String)source());
|
||||
sink((String)e4.getMessage()); // $hasValueFlow
|
||||
|
||||
Throwable t = new Throwable((Throwable)source());
|
||||
sink((Throwable)t.getCause()); // $hasValueFlow
|
||||
}
|
||||
}
|
||||
0
java/ql/test/ext/TestModels/test.expected
Normal file
0
java/ql/test/ext/TestModels/test.expected
Normal file
2
java/ql/test/ext/TestModels/test.ql
Normal file
2
java/ql/test/ext/TestModels/test.ql
Normal file
@@ -0,0 +1,2 @@
|
||||
import java
|
||||
import TestUtilities.InlineFlowTest
|
||||
Reference in New Issue
Block a user