mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
java: add SafePublication query (P2)
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
| SafePublication.java:5:9:5:9 | z | The class $@ is marked as thread-safe, but this field is not safely published. | SafePublication.java:2:14:2:28 | SafePublication | SafePublication |
|
||||
| SafePublication.java:6:9:6:9 | w | The class $@ is marked as thread-safe, but this field is not safely published. | SafePublication.java:2:14:2:28 | SafePublication | SafePublication |
|
||||
| SafePublication.java:7:9:7:9 | u | The class $@ is marked as thread-safe, but this field is not safely published. | SafePublication.java:2:14:2:28 | SafePublication | SafePublication |
|
||||
| SafePublication.java:11:10:11:10 | d | The class $@ is marked as thread-safe, but this field is not safely published. | SafePublication.java:2:14:2:28 | SafePublication | SafePublication |
|
||||
| SafePublication.java:12:10:12:10 | e | The class $@ is marked as thread-safe, but this field is not safely published. | SafePublication.java:2:14:2:28 | SafePublication | SafePublication |
|
||||
| SafePublication.java:14:11:14:13 | arr | The class $@ is marked as thread-safe, but this field is not safely published. | SafePublication.java:2:14:2:28 | SafePublication | SafePublication |
|
||||
| SafePublication.java:17:10:17:11 | cc | The class $@ is marked as thread-safe, but this field is not safely published. | SafePublication.java:2:14:2:28 | SafePublication | SafePublication |
|
||||
@@ -0,0 +1,29 @@
|
||||
@ThreadSafe
|
||||
public class SafePublication {
|
||||
int x;
|
||||
int y = 0;
|
||||
int z = 3; //$ Alert
|
||||
int w; //$ Alert
|
||||
int u; //$ Alert
|
||||
long a;
|
||||
long b = 0;
|
||||
long c = 0L;
|
||||
long d = 3; //$ Alert
|
||||
long e = 3L; //$ Alert
|
||||
|
||||
int[] arr = new int[3]; //$ Alert
|
||||
float f = 0.0f;
|
||||
double dd = 00.0d;
|
||||
char cc = 'a'; //$ Alert
|
||||
char ok = '\u0000';
|
||||
|
||||
public SafePublication(int a) {
|
||||
x = 0;
|
||||
w = 3; // not ok
|
||||
u = a; // not ok
|
||||
}
|
||||
|
||||
public void methodLocal() {
|
||||
int i;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
query: Likely Bugs/Concurrency/SafePublication.ql
|
||||
postprocess: utils/test/InlineExpectationsTestQuery.ql
|
||||
2
java/ql/test/query-tests/SafePublication/ThreadSafe.java
Normal file
2
java/ql/test/query-tests/SafePublication/ThreadSafe.java
Normal file
@@ -0,0 +1,2 @@
|
||||
public @interface ThreadSafe {
|
||||
}
|
||||
Reference in New Issue
Block a user