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.
39 lines
827 B
39 lines
827 B
/*
|
|
* Copyright (c) 2017-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
import javax.annotation.concurrent.ThreadSafe;
|
|
|
|
// Fields must encapsulate the class they are declared in, not
|
|
// the class they are potentially inherited into.
|
|
|
|
@ThreadSafe
|
|
class SuperFld {
|
|
|
|
private int f = 0;
|
|
public int getF() {
|
|
return f; // should *not* report read/write race with SubFld.setF()
|
|
}
|
|
|
|
protected int g = 0;
|
|
public int getG() {
|
|
return g; // must report read/write race with SubFld.setG()
|
|
}
|
|
|
|
}
|
|
|
|
@ThreadSafe
|
|
public class SubFld extends SuperFld {
|
|
|
|
private int f = 0;
|
|
synchronized public void setF() {
|
|
f = 5; // should *not* report
|
|
}
|
|
|
|
synchronized public void setG() {
|
|
g = 5; // must report
|
|
}
|
|
}
|