Versions Compared

Key

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

...

Code Block
bgColor#ccccff
public class MyClass {

    private static byte[] data;
    public static byte[] getData() {
        return data.clone();
    }

    public static void setData(byte[] b) {
        securityCheck();
       data = b.clone();
    }
}

However as a cautionary note, simply changing the modifier to final may not prevent attackers from indirectly causing an incorrect value to be stored in the static variable. See Eliminate Class Initialization Cycles for more on this problem.

Risk Assessment

Unauthorized modifications to public static variables can result in unexpected behavior and can bypass important security checks and/or invoke malicious code.

...