Skip to content

Commit 821b1de

Browse files
committed
java: inline char pred
1 parent 01ddc11 commit 821b1de

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

java/ql/lib/semmle/code/java/ConflictingAccess.qll

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,6 @@ module Modification {
151151
}
152152
}
153153

154-
/** Holds if the class is annotated as `@ThreadSafe`. */
155-
Class annotatedAsThreadSafe() { result.getAnAnnotation().getType().getName() = "ThreadSafe" }
156-
157154
/** Holds if the type `t` is thread-safe. */
158155
predicate isThreadSafeType(Type t) {
159156
t.getErasure().getName().matches(["Atomic%", "Concurrent%"])
@@ -164,7 +161,7 @@ predicate isThreadSafeType(Type t) {
164161
// See https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/package-summary.html#MemoryVisibility
165162
t.getTypeDescriptor().matches("Ljava/util/concurrent/%;")
166163
or
167-
t = annotatedAsThreadSafe()
164+
t instanceof ClassAnnotatedAsThreadSafe
168165
}
169166

170167
/** Holds if the expression `e` is a thread-safe initializer. */
@@ -178,7 +175,7 @@ predicate isThreadSafeInitializer(Expr e) {
178175
*/
179176
class ExposedFieldAccess extends FieldAccess {
180177
ExposedFieldAccess() {
181-
this.getField() = annotatedAsThreadSafe().getAField() and
178+
this.getField() = any(ClassAnnotatedAsThreadSafe c).getAField() and
182179
not this.getField().isVolatile() and
183180
// field is not a lock
184181
not isLockType(this.getField().getType()) and
@@ -212,7 +209,7 @@ predicate orderedLocations(Location a, Location b) {
212209
* Provides predicates to check for concurrency issues.
213210
*/
214211
class ClassAnnotatedAsThreadSafe extends Class {
215-
ClassAnnotatedAsThreadSafe() { this = annotatedAsThreadSafe() }
212+
ClassAnnotatedAsThreadSafe() { this.getAnAnnotation().getType().getName() = "ThreadSafe" }
216213

217214
/** Holds if `a` and `b` are conflicting accesses to the same field and not monitored by the same monitor. */
218215
predicate unsynchronised(ExposedFieldAccess a, ExposedFieldAccess b) {

0 commit comments

Comments
 (0)