Files
openide/java/java-impl/resources/inspectionDescriptions/AtomicFieldUpdaterNotStaticFinal.html
Leonid Shalupov 40795fe787 IJI-2422: community/java: move resources under resources root
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
2025-02-05 04:43:28 +00:00

31 lines
1.1 KiB
HTML

<html>
<body>
Reports fields of types:
<ul>
<li><code>java.util.concurrent.atomic.AtomicLongFieldUpdater</code></li>
<li><code>java.util.concurrent.atomic.AtomicIntegerFieldUpdater</code></li>
<li><code>java.util.concurrent.atomic.AtomicReferenceFieldUpdater</code></li>
</ul>
that are not <code>static final</code>.
Because only one atomic field updater is needed for updating a <code>volatile</code> field in all instances
of a class, it can almost always be <code>static</code>.
<p>Making the updater <code>final</code> allows the JVM to optimize access for improved performance.</p>
<p><b>Example:</b></p>
<pre><code>
class Main {
private volatile int id;
private AtomicIntegerFieldUpdater&lt;Main&gt; idFieldUpdater = AtomicIntegerFieldUpdater.newUpdater(Main.class, "id");
}
</code></pre>
<p>After the quick-fix is applied:</p>
<pre><code>
class Main {
private volatile int id;
private static final AtomicIntegerFieldUpdater&lt;Main&gt; idFieldUpdater = AtomicIntegerFieldUpdater.newUpdater(Main.class, "id");
}
</code></pre>
<!-- tooltip end -->
</body>
</html>