This cannot be optimized based on the semantics of the Java Memory Model. The lock capture lock operation may be replaced by something else, but even an empty synchronized block has consequences for the visibility of actions taken by other threads acquiring the same lock.
In particular, there is a guarantee that all write operations performed by one thread, before releasing the lock, will be visible to another thread after it acquires the same lock.
Regarding your EDIT
This is a completely different case: a block is obtained at the object, which can be proved by analysis of the escape, which no other thread can ever extract. In this case, it does not matter what the contents of the synchronized block are: the point is used only in the used lock. The code may look like you posted it, or even like this:
Object o = new Object(); synchronized(o) {
This may be affected by a transformation known as locking: the JVM may pretend to never see a synchronized block. This is because the semantics of JMM apply only to cases of acquiring the same lock.
source share