...
In this compliant solution, changeValue()
obtains a lock on a private static Object
that is inaccessible to the caller.
Exceptions
LCK00-J-EX0: A class may violate this rule when all of the following conditions are met:
...
- Neither the client class nor any other class in the system passes objects of the violating class to untrusted code.
- The violating class cannot invoke methods, directly or indirectly, from untrusted classes that violate this rule.
LCK00-J-EX1: When a superclass of the class documents that it supports client-side locking and synchronizes on its class object, the class can support client-side locking in the same way and document this policy.
LCK00-J-EX2: Package-private classes are exempt from this rule because their accessibility protects against untrusted callers. However, use of this exemption should be documented explicitly to ensure that trusted code within the same package neither reuses the lock object nor changes the lock object inadvertently.
...