Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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
bgColor#ccccff
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.

...