Files
openide/java/java-impl/resources/inspectionDescriptions/StaticGuardedByInstance.html
2025-02-05 04:43:28 +00:00

27 lines
1.0 KiB
HTML

<html>
<body>
Reports <code>@GuardedBy</code> annotations on <code>static</code> fields or methods in which the guard is either a non-static field or
<code>this</code>.
<p>Guarding a static element with a non-static element may result in
excessive concurrency, multiple threads may be able to access the guarded field simultaneously by locking in different object contexts.</p>
<p>Example:</p>
<pre><code>
private ReadWriteLock lock = new ReentrantReadWriteLock();
@GuardedBy("lock")
public static void bar() {
// ...
}
</code></pre>
<!-- tooltip end -->
<p>Supported <code>@GuardedBy</code> annotations are:</p>
<ul>
<li><code>net.jcip.annotations.GuardedBy</code></li>
<li><code>javax.annotation.concurrent.GuardedBy</code></li>
<li><code>org.apache.http.annotation.GuardedBy</code></li>
<li><code>com.android.annotations.concurrency.GuardedBy</code></li>
<li><code>androidx.annotation.GuardedBy</code></li>
<li><code>com.google.errorprone.annotations.concurrent.GuardedBy</code></li>
</ul>
</body>
</html>