From c985950989482af485b0a16b479942770bfdcf57 Mon Sep 17 00:00:00 2001
From: Reinier Zwitserloot new Object()
as most snippets showing this pattern in action use. Lombok does this because a new object is NOT
serializable, but 0-size array is. Therefore, using @Synchronized
will not prevent your object from being serialized.
+ Having at least one @Synchronized
method in your class means there will be a lock field, but if you later remove all such methods,
+ there will no longer be a lock field. That means your predetermined serialVersionUID
changes. We suggest you always add
+ a serialVersionUID
to your classes if you intend to store them long-term via java's serialization mechanism. If you do so, removing
+ all @Synchronized
annotations from your method will not break serialization.
+
If you'd like to know why a field is not automatically generated when you choose your own name for the lock object: Because otherwise making a typo in the field name will result in a very hard to find bug!
-- cgit