...
It is also permissible to use a wrapper method to retrieve the value of m_functions
. This has encapsulation advantages as it restricts its accessibility to private
(see OBJ00-J. Declare data members as private and provide accessible wrapper methods). However, it is unnecessary when m_functions
needs to be treated like a world-accessible constant.
Noncompliant Code Example serialVersionUID
This noncompliant code example uses a public static
non-final serialVersionUID
field in a class designed for serialization.
...
Code Block | ||
---|---|---|
| ||
class DataSerializer implements Serializable { private static final long serialVersionUID = 1973473122623778747L; } |
The serialization mechanism internally uses the serialVersionUID
field so no accessible wrapper methods are required.
Risk Assessment
Unauthorized modifications of public static
variables can result in unexpected behavior and violation of class invariants.
...