Versions Compared

Key

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

...

Code Block
bgColor#ccccff
public static final FuncLoader m_functions;
// Initialize m_functions in a constructor

As Fields declared static final are also safe for multithreaded use (CON26-J. Do not publish partially initialized objects). On a cautionary note, however, simply changing the modifier to final may not prevent attackers from indirectly retrieving an incorrect value from the static final variable before its initialization . See (see MSC07-J. Eliminate class initialization cycles, ). Individual members of the referenced object can also be changed if it is mutable (see OBJ01-J. Be aware that a final reference may not always refer to immutable data for more details about such problems. Fields declared static final are also safe for multithreaded use (CON26-J. Do not publish partially initialized objects).

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.

...