[threadsafety] Treat clone() as aquiring ownership

Reviewed By: sblackshear

Differential Revision: D4961331

fbshipit-source-id: 60a9a36
master
Peter O'Hearn 8 years ago committed by Facebook Github Bot
parent 6ff421ca65
commit 3db1f9e94c

@ -350,6 +350,9 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
| ("java.lang.Class" | "java.lang.reflect.Constructor"), "newInstance" -> | ("java.lang.Class" | "java.lang.reflect.Constructor"), "newInstance" ->
(* reflection can perform allocations *) (* reflection can perform allocations *)
true true
| "java.lang.Object" , "clone" ->
(* cloning is like allocation *)
true
| "java.lang.ThreadLocal", "get" -> | "java.lang.ThreadLocal", "get" ->
(* ThreadLocal prevents sharing between threads behind the scenes *) (* ThreadLocal prevents sharing between threads behind the scenes *)
true true

@ -376,6 +376,15 @@ public class Ownership {
c.f = new Object(); c.f = new Object();
} }
void cloningAquiresOwnershipOk(){
Ownership ow;
try {
ow = (Ownership) this.clone();
ow.field = null;
}
catch (CloneNotSupportedException e) {}
}
} }

Loading…
Cancel
Save