@GuardedBy 注解。
示例:
private Object state;
@GuardedBy("lock") //未知的保护引用
public void bar() {
state = new Object();
}
支持的 @GuardedBy 注解为:
net.jcip.annotations.GuardedByjavax.annotation.concurrent.GuardedByorg.apache.http.annotation.GuardedBycom.android.annotations.concurrency.GuardedByandroidx.annotation.GuardedBycom.google.errorprone.annotations.concurrent.GuardedBy