An enum has an instance field that is not final, making its constants shared mutable state

tx0/java:mutable-enum-fieldrecommendedwarningsmell, concurrency

What it finds

The constants of an enum exist once per program and are shared by every thread and every caller. An instance field that is not final makes them shared mutable state: a change made through one use of Color.RED shows up everywhere, without any synchronization.

From the rule's source, mutable_enum_field.rs.

Example from the rule's tests
enum Level {  LOW, HIGH;   private int hits;tx0 reports: hits can change, and every use of the enum constant shares it  private final String label = "x";  private static int total;}
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 recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/java:mutable-enum-field" = "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:mutable-enum-field] reason="..."

tx0 explain tx0/java:mutable-enum-field shows the same in the terminal. Found a false positive? Report it.