You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The rule exists since PMD 1.1 but doesn't really check for serialization despite its name:
The name of the rule is confusing too, since it's not checking that members should be serializable (which would be interesting on it's own), but rather if the getter / setters are in place. I suggest renaming this rule accordingly.
Taking into account, that transient fields can be ignored
Don't look at getters or setters - this is something for a different rule that actually checks Java Beans conformity
Deprecate the property prefix - if a class is serializable, all members have to be serializable as well, regardless of their name
That way, we don't need to need to add a new property like #403 suggests.
And since we only consider serializable classes, the rule should be less noisy (#1668).
Note: BeanMembersShouldSerialize can be suppressed with @SuppressWarnings("serial"), which actually doesn't make sense, since the rule doesn't do serializability checks (originally implemented per request https://sourceforge.net/p/pmd/bugs/784/)
Alternative
We could actually just create a new rule "NonSerializableClass" and deprecate "BeanMembersShouldSerialize" entirely. While the implementation will be completely different, the original intention (serializability) is the same of both rules.
It probably makes not so much a difference, since the rule was probably not used at all because it's so noisy...
The text was updated successfully, but these errors were encountered:
There are a two issues around the rule BeanMembersShouldSerialize:
The rule exists since PMD 1.1 but doesn't really check for serialization despite its name:
(#403 (comment))
I'm proposing the following changes:
java.io.Serializable
transient
fields can be ignoredprefix
- if a class is serializable, all members have to be serializable as well, regardless of their nameThat way, we don't need to need to add a new property like #403 suggests.
And since we only consider serializable classes, the rule should be less noisy (#1668).
Note: BeanMembersShouldSerialize can be suppressed with
@SuppressWarnings("serial")
, which actually doesn't make sense, since the rule doesn't do serializability checks (originally implemented per request https://sourceforge.net/p/pmd/bugs/784/)Alternative
We could actually just create a new rule "NonSerializableClass" and deprecate "BeanMembersShouldSerialize" entirely. While the implementation will be completely different, the original intention (serializability) is the same of both rules.
It probably makes not so much a difference, since the rule was probably not used at all because it's so noisy...
The text was updated successfully, but these errors were encountered: