I have a Collections.synchronizedList of WeakReference, _components;
I wrote something like the following, expecting the complier to complain:
public boolean addComponent2(Component e) {
synchronized (_components) {
return _components.add(new WeakReference<Component>(e));
}
}
But the compiler is perfectly satisfied. Note that List.add() returns TRUE. So ok, any exit from a synchronized block releases the lock, but doesn't this LOOK strange? It's kind of like a "hole" in the block, similar to using return in a loop.
Would you be happy maintaining code like this?