Reviewed By: jeremydubreil Differential Revision: D4383239 fbshipit-source-id: c194d08master
parent
f7917987df
commit
4cb03f4670
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package codetoanalyze.java.checkers;
|
||||
|
||||
import android.support.annotation.UiThread;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target({ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
@interface AnyThread {
|
||||
}
|
||||
|
||||
@Target({ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
@interface ForUiThread {
|
||||
}
|
||||
|
||||
@Target({ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
@interface ForNonUiThread {
|
||||
}
|
||||
|
||||
public class UiThreads {
|
||||
|
||||
@UiThread
|
||||
void uiThread() {}
|
||||
|
||||
@AnyThread
|
||||
void anyThread() {}
|
||||
|
||||
@ForUiThread
|
||||
void forUiThread() {}
|
||||
|
||||
@ForNonUiThread
|
||||
void forNonUiThread() {}
|
||||
|
||||
@ForUiThread
|
||||
void callForNonUiThreadBad1() {
|
||||
forNonUiThread();
|
||||
}
|
||||
|
||||
@UiThread
|
||||
void callForNonUiThreadBad2() {
|
||||
forNonUiThread();
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
void callUiThreadBad1() {
|
||||
uiThread();
|
||||
}
|
||||
|
||||
@ForNonUiThread
|
||||
void callUiThreadBad2() {
|
||||
uiThread();
|
||||
}
|
||||
|
||||
@ForUiThread
|
||||
void callUiThreadOk() {
|
||||
uiThread();
|
||||
}
|
||||
|
||||
@UiThread
|
||||
void callForUiThreadOk() {
|
||||
forUiThread();
|
||||
}
|
||||
|
||||
@ForNonUiThread
|
||||
void callAnyThreadOk1() {
|
||||
anyThread();
|
||||
}
|
||||
|
||||
@ForUiThread
|
||||
void callAnyThreadOk2() {
|
||||
anyThread();
|
||||
}
|
||||
|
||||
@UiThread
|
||||
void callAnyThreadOk3() {
|
||||
anyThread();
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
void callForNonUiThreadOk() {
|
||||
forNonUiThread();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue