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.
43 lines
948 B
43 lines
948 B
/*
|
|
* 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 javax.annotation.concurrent.ThreadSafe;
|
|
|
|
// Test may_alias treatment of arrays
|
|
// two arrays of types in a subtype relation may alias, and race
|
|
|
|
@ThreadSafe
|
|
class Parent {}
|
|
|
|
@ThreadSafe
|
|
class Child extends Parent {}
|
|
|
|
@ThreadSafe
|
|
class SubArr {
|
|
Child[] childArr = new Child[5];
|
|
Parent[] parentArr = childArr; // actual aliasing not required, but for documentation
|
|
String[] strArr = new String[5];
|
|
|
|
public Child RWrace() {
|
|
synchronized(this) {
|
|
parentArr[3] = null;
|
|
}
|
|
|
|
return childArr[4];
|
|
}
|
|
|
|
public String NOrace() {
|
|
synchronized(this) {
|
|
parentArr[3] = null;
|
|
}
|
|
|
|
return strArr[2];
|
|
}
|
|
|
|
}
|