An anonymous subclass of ThreadLocal only overrides initialValue, which ThreadLocal.withInitial takes as a lambda

tx0/java:thread-local-subclassstrictwarningstyle/conventionsdepth faststyle

What it finds

new ThreadLocal<T>() { protected T initialValue() { return ...; } } declares a class to supply a starting value. ThreadLocal.withInitial(() -> ...) does the same without the class.

Reported is an anonymous subclass of ThreadLocal whose only member is initialValue.

From the rule's source, thread_local_subclass.rs.

Example from the rule's tests
class Locals {  ThreadLocal<StringBuilder> a = new ThreadLocal<StringBuilder>() {tx0 reports: withInitial    protected StringBuilder initialValue() {      return new StringBuilder();    }  };  ThreadLocal<StringBuilder> b = ThreadLocal.withInitial(StringBuilder::new);}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/java:thread-local-subclass" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/java:thread-local-subclass] reason="..."

tx0 explain tx0/java:thread-local-subclass shows the same in the terminal. Found a false positive? Report it.