Since final classes cannot be subclassed, the use of the return value of getClass as a lock object inside a final class is safe. Anonymous classes are a special kind of final classes. So, the use of getClass inside an anonymous class is safe. If our detector reports too many false positives in these cases, we can have the detector check for these corner cases.
Since final classes cannot be subclassed, the use of the return value of
getClass
as a lock object inside a final class is safe. Anonymous classes are a special kind of final classes. So, the use ofgetClass
inside an anonymous class is safe. If our detector reports too many false positives in these cases, we can have the detector check for these corner cases.