You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
1.5 KiB
75 lines
1.5 KiB
7 years ago
|
/*
|
||
|
* Copyright (c) 2017 - present Facebook, Inc.
|
||
|
* All rights reserved.
|
||
|
*
|
||
|
* This source code is licensed under the BSD style license found in the
|
||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||
|
*/
|
||
|
|
||
|
|
||
|
import com.facebook.infer.annotation.ThreadSafe;
|
||
|
|
||
|
@ThreadSafe
|
||
|
class DeepOwnership {
|
||
|
DeepOwnership next;
|
||
|
static DeepOwnership global;
|
||
|
|
||
|
void globalNotOwnedBad() {
|
||
|
global.next = null;
|
||
|
}
|
||
|
|
||
|
void reassignBaseToGlobalBad(){
|
||
|
DeepOwnership x = new DeepOwnership();
|
||
|
x = global;
|
||
|
x.next = null;
|
||
|
}
|
||
|
|
||
|
void FN_reassignPathToGlobalBad() {
|
||
|
DeepOwnership x = new DeepOwnership();
|
||
|
x.next = global;
|
||
|
x.next.next = null;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
void deepIntraOk(){
|
||
|
DeepOwnership x = new DeepOwnership();
|
||
|
x.next.next = null; // doesn't warn here
|
||
|
}
|
||
|
|
||
|
void deepInterOk(){
|
||
|
DeepOwnership x = new DeepOwnership();
|
||
|
deepPrivate(x.next);
|
||
|
}
|
||
|
|
||
|
private void deepPrivate(DeepOwnership y){
|
||
|
y.next = null;
|
||
|
}
|
||
|
|
||
|
DeepOwnership deepFromOwnedThisOk(){
|
||
|
return new DeepOwnership();
|
||
|
}
|
||
|
|
||
|
DeepOwnership arr[];
|
||
|
|
||
|
DeepOwnership(){
|
||
|
next.next = null;
|
||
|
arr[0] = null;
|
||
|
}
|
||
|
|
||
|
private void loseOwnershipOfNext() {
|
||
|
synchronized (this) {
|
||
|
this.next = global;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void FN_loseOwnershipInCalleeBad() {
|
||
|
DeepOwnership x = new DeepOwnership();
|
||
|
x.next = new DeepOwnership();
|
||
|
loseOwnershipOfNext();
|
||
|
x.next.next = null; // doesn't warn here
|
||
|
}
|
||
|
|
||
|
}
|