I'm not sure if this is the correct forum for questions relating to Bill Venners' book, "Inside the JVM" (2nd ed)... which I just finished yesterday (except for the appendix). What an excellent book!
p.522 desribes the areturn instr. It says, "If the current method is synchronized and the current thread does not own the monitor acquired or reentered when the method was invoked, the virtual machine throws IllegalMonitorStateException". This idea doesn't make sense to me yet, given my understanding below...
Now, I understand that a synchronized statement is different from a synchronized method... a synchronized statement uses "monitorenter" and "monitorexit" in the bytecodes, but a synchronized method doesn't. Eg, on p509: "The Java virtual machine does not use any special opcodes to invoke or return from synchronized methods." Then p511 re-inforces this from an example: "If this method completes abruptly, just as if it completes normally, the virtual machine will release the lock on the 'this' object automatically".
So the question... If the current method is synchronized and has no monitorenter or monitorexit instrs (and for simplicity, does not itself invoke any methods), then how could an "IllegalMonitorStateException" possibly be thrown since the JVM itself (not the bytecodes) is responsible for automatically entering and the releasing the monitor belonging to the synchronized method?