From 830f02af1ff14968cae0c45e9f0c595d11a7831a Mon Sep 17 00:00:00 2001 From: yoff Date: Thu, 9 Oct 2025 09:37:31 +0200 Subject: [PATCH] java: fixes from the CI bots --- java/ql/lib/semmle/code/java/ConflictingAccess.qll | 6 +++--- java/ql/src/Likely Bugs/Concurrency/SafePublication.ql | 2 +- .../test/query-tests/ThreadSafe/examples/LockExample.java | 2 +- java/ql/test/query-tests/ThreadSafe/examples/Test.java | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/java/ql/lib/semmle/code/java/ConflictingAccess.qll b/java/ql/lib/semmle/code/java/ConflictingAccess.qll index 39bd7f0d383..1243a94d661 100644 --- a/java/ql/lib/semmle/code/java/ConflictingAccess.qll +++ b/java/ql/lib/semmle/code/java/ConflictingAccess.qll @@ -159,9 +159,9 @@ module Modification { predicate isThreadSafeType(Type t) { t.(RefType).getSourceDeclaration().getName().matches(["Atomic%", "Concurrent%"]) or - t.(RefType).getSourceDeclaration().getName() in ["ThreadLocal"] + t.(RefType).getSourceDeclaration().getName() = "ThreadLocal" or - // Anything in `java.itul.concurrent` is thread safe. + // Anything in `java.util.concurrent` is thread safe. // See https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/package-summary.html#MemoryVisibility t.(RefType).getPackage().getName() = "java.util.concurrent" or @@ -303,7 +303,7 @@ class ClassAnnotatedAsThreadSafe extends Class { ) } - /** Holds if `a` can be reached by a path from a public method and `e` is the expression in that method that stsarts the path. */ + /** Holds if `a` can be reached by a path from a public method and `e` is the expression in that method that starts the path. */ predicate publicAccess(Expr e, ExposedFieldAccess a) { exists(Method m | m.isPublic() | this.providesAccess(m, e, a)) } diff --git a/java/ql/src/Likely Bugs/Concurrency/SafePublication.ql b/java/ql/src/Likely Bugs/Concurrency/SafePublication.ql index 08cd3d5a577..5e2a89ce372 100644 --- a/java/ql/src/Likely Bugs/Concurrency/SafePublication.ql +++ b/java/ql/src/Likely Bugs/Concurrency/SafePublication.ql @@ -77,7 +77,7 @@ predicate isAssignedDefaultValue(Field f) { } predicate isSafelyPublished(Field f) { - f.isFinal() or // TODO: Consider non-primitive types + f.isFinal() or // NOTE: For non-primitive types, 'final' alone does not guarantee safe publication unless the object is immutable or safely constructed. Consider reviewing the handling of non-primitive fields for safe publication. f.isStatic() or f.isVolatile() or isThreadSafeType(f.getType()) or diff --git a/java/ql/test/query-tests/ThreadSafe/examples/LockExample.java b/java/ql/test/query-tests/ThreadSafe/examples/LockExample.java index 92886bbb5ff..8ce34922c5b 100644 --- a/java/ql/test/query-tests/ThreadSafe/examples/LockExample.java +++ b/java/ql/test/query-tests/ThreadSafe/examples/LockExample.java @@ -3,7 +3,7 @@ // If the variable is involved in several different monitors, we get an alert for each monitor that // is not correctly used. // A single alert can have many related locations, since each conflicting access which is not -// prpoerly synchronized is a related location. +// properly synchronized is a related location. // This leads to many lines in the .expected file. package examples; diff --git a/java/ql/test/query-tests/ThreadSafe/examples/Test.java b/java/ql/test/query-tests/ThreadSafe/examples/Test.java index 55fef174fc5..b2e7ac46c0b 100644 --- a/java/ql/test/query-tests/ThreadSafe/examples/Test.java +++ b/java/ql/test/query-tests/ThreadSafe/examples/Test.java @@ -5,14 +5,14 @@ import java.util.concurrent.locks.ReentrantLock; @ThreadSafe public class Test { /** - * Escaping field due to public visuability. + * Escaping field due to public visibility. */ int publicField; private int y; final int immutableField = 1; - // As of the below examples with synchronized as well. Except the incorretly placed lock. + // As of the below examples with synchronized as well. Except the incorrectly placed lock. private Lock lock = new ReentrantLock(); @@ -53,7 +53,7 @@ public class Test { } /** - * Incorretly locks y. + * Incorrectly locks y. * @param y */ public void setYWrongLock(int y) {