Inside Java™ 2 Platform Security: Architecture, API Design, and Implementation, Second Edition
by Li Gong, Gary Ellison, Mary Dageforde
9.3. Static Fields
A static field is a per class field in the sense that its value is shared by all objects instantiated from the same class. Use of static fields is a minefield that can cause unintended interactions between supposedly independent subsystems. Static fields offer even less protection than per object fields; in the latter case, you must have an object’s reference in order to access the field, whereas in the former case, anyone can access the field simply by using the class name directly.
As a result, directly exposed, non-final public static variables are extremely problematic for security. Never design a class with such variables. Instead, declare them as static private, with appropriate public static accessor methods. You still ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access