I assume your class is a bean that by definition implements Serializable
. A transient variable will be excluded from the serialization process. If you serialize and then deserialize the bean the value will be actually have the default value.
PMD assumes you are dealing with a serializable bean here. For a bean it is expected to have getters/setters for all member variables. As you have omitted these, you imply that your member variable is not part of the bean ….and so does not need to be serialized. If that is the case you should exclude it from the serialization. Which you do by marking the variable as “transient”.