Fix FP for always-locked fields

This commit is contained in:
Owen Mansel-Chan
2025-03-13 15:03:32 +00:00
parent dc2cbf7402
commit a8e993c942
2 changed files with 5 additions and 3 deletions

View File

@@ -68,7 +68,9 @@ predicate alwaysLocked(Field f) {
or
exists(RefType thisType |
forex(VarAccess access |
access = f.getAnAccess() and not access.getEnclosingCallable() instanceof InitializerMethod
access = f.getAnAccess() and
not access.getEnclosingCallable() instanceof Constructor and
not access.getEnclosingCallable() instanceof InitializerMethod
|
locallySynchronizedOnThis(access, thisType)
)

View File

@@ -14,10 +14,10 @@ class FieldAlwaysLocked {
protected synchronized void checkOut() {
Object o;
if (field.size() > 0) {
Enumeration e = field.keys(); // $ SPURIOUS: Alert
Enumeration e = field.keys();
while (e.hasMoreElements()) {
o = e.nextElement();
field.remove(o); // $ SPURIOUS: Alert
field.remove(o);
}
}
}