Files
Bartek Paciaandintellij-monorepo-bot dc65540767 IDEA-384866 add the "New in 2026.1" label to IncorrectLazyConstantUsageInspection
suggested by bvh in IJ-CR-192061


(cherry picked from commit ab89de66f82fca75b4f607ee1532a1538c00b1c0)

IJ-CR-192061

GitOrigin-RevId: 623cd03c11a02b7ea8a1e845450ccf6d2acbe729
2026-02-24 14:03:25 +00:00

19 lines
675 B
HTML

<html>
<body>
Reports fields of type <code>java.lang.LazyConstant</code> that are not <code>final</code>.
<p>
Per <a href="https://openjdk.org/jeps/526">JEP 526: Lazy Constants</a>, lazy constants must be stored in a <code>final</code> field to enable constant-folding optimizations by the JVM.
</p>
<p>Correct usage:</p>
<pre><code>
private final LazyConstant&lt;Logger&gt; logger = LazyConstant.of(() -&gt; Logger.create(OrderController.class));
</code></pre>
<p>Incorrect usage (will be reported):</p>
<pre><code>
private LazyConstant&lt;String&gt; x = LazyConstant.of(() -&gt; "expensive string");
</code></pre>
<p><small>New in 2026.1</small></p>
</body>
</html>