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.
92 lines
1.5 KiB
92 lines
1.5 KiB
/*
|
|
* 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.
|
|
*/
|
|
|
|
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();
|
|
}
|
|
}
|