On 3/3/2011 12:43 AM, javax.swing.JSnarker wrote:
On 02/03/2011 10:53 PM, Peter Duniho wrote:
It does, and yes???if those assumptions are valid, it can address the
problem even without interfering with other code. But so what? It
doesn't change the fact that there's a way to write the code such that
it _looks_ correct, but which actually is not.
That's always going to be possible in any nontrivial programming language.
It might be useful if the compiler emitted a warning when synchronizing
on a non-final instance variable.
Java never synchronizes on any variable, whether instance or
local, final or fragile. Java synchronizes on object instances,
not on references to those instances.
If this distinction seems nit-picky and pettifogging, consider
that the bug under discussion was *caused* by a failure to notice
exactly this distinction.