A field is transient in a class that cannot be serializable

tx0/java:transient-without-serializationstrictwarningsmell

What it finds

transient only tells Java serialization to skip a field. In a class that implements nothing and extends nothing, which therefore is not Serializable, the keyword has no effect and suggests a role the class does not have.

Reported is a transient field in a class without supertypes.

From the rule's source, transient_without_serialization.rs.

Example from the rule's tests
import java.io.Serializable; class Plain {  private transient int cache;tx0 reports: transient has no effect} class Stored implements Serializable {  private transient int cache;}
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:transient-without-serialization" = "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:transient-without-serialization] reason="..."

tx0 explain tx0/java:transient-without-serialization shows the same in the terminal. Found a false positive? Report it.