Chapter 6. Object Orientation (OBJ)

Rules

Image

Risk Assessment Summary

Image

OBJ00-J. Limit extensibility of classes and methods with invariants to trusted subclasses only

Many methods offer invariants, which can be any or all of the guarantees made about what the method can do, requirements about the required state of the object when the method is invoked, or guarantees about the state of the object when the method completes. For instance, the % operator, which computes the remainder of a number, provides the invariant that

0 < = abs(a % b) < abs(b), for ...

Get The CERT® Oracle® Secure Coding Standard for Java™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.