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.
59 lines
1.0 KiB
59 lines
1.0 KiB
5 years ago
|
/*
|
||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
|
*
|
||
|
* This source code is licensed under the MIT license found in the
|
||
|
* LICENSE file in the root directory of this source tree.
|
||
|
*/
|
||
|
|
||
|
import com.facebook.infer.annotation.Lockless;
|
||
|
|
||
|
class LocklessTests {}
|
||
|
|
||
|
interface Listener {
|
||
|
@Lockless
|
||
|
void locklessMethod();
|
||
|
|
||
|
void normalMethod();
|
||
|
}
|
||
|
|
||
|
class LocklessTestsA implements Listener {
|
||
|
// should warn
|
||
|
@Override
|
||
|
public void locklessMethod() {
|
||
|
synchronized (this) {
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// no warnings here
|
||
|
@Override
|
||
|
public void normalMethod() {
|
||
|
synchronized (this) {
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class LocklessTestsB implements Listener {
|
||
|
// should warn
|
||
|
@Lockless
|
||
|
@Override
|
||
|
public synchronized void locklessMethod() {}
|
||
|
|
||
|
// no warnings here
|
||
|
@Override
|
||
|
public synchronized void normalMethod() {}
|
||
|
}
|
||
|
|
||
|
class LocklessTestsC implements Listener {
|
||
|
private synchronized void takeLock() {}
|
||
|
|
||
|
// should warn
|
||
|
@Override
|
||
|
public void locklessMethod() {
|
||
|
takeLock();
|
||
|
}
|
||
|
|
||
|
// no warnings here
|
||
|
@Override
|
||
|
public synchronized void normalMethod() {}
|
||
|
}
|