[infer][threadsafety] model tryLock() for java.util.concurrent.locks.Lock

Summary: we were just missing this model, adding it

Reviewed By: sblackshear

Differential Revision: D4701435

fbshipit-source-id: 9718305
master
Peter O'Hearn 8 years ago committed by Facebook Github Bot
parent 8397924886
commit 11937cb076

@ -55,9 +55,8 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
| Typ.Procname.Java java_pname ->
begin
match Typ.Procname.java_get_class_name java_pname, Typ.Procname.java_get_method java_pname with
| "java.util.concurrent.locks.Lock", "lock" ->
Lock
| ("java.util.concurrent.locks.ReentrantLock"
| ("java.util.concurrent.locks.Lock"
| "java.util.concurrent.locks.ReentrantLock"
| "java.util.concurrent.locks.ReentrantReadWriteLock$ReadLock"
| "java.util.concurrent.locks.ReentrantReadWriteLock$WriteLock"),
("lock" | "tryLock" | "lockInterruptibly") ->

@ -76,6 +76,13 @@ public class Locks {
mReentrantLock.unlock();
}
public void normalLockTryLockOk() {
if (mLock.tryLock()) {
f = 42;
mLock.unlock();
}
}
public void rReentrantLockTryLockOk() {
if (mReentrantLock.tryLock()) {
f = 42;
@ -83,6 +90,7 @@ public class Locks {
}
}
public void reentrantLockInterruptiblyOk() throws InterruptedException {
mReentrantLock.lockInterruptibly();
f = 42;

Loading…
Cancel
Save