I rolled back to IDEA 3273, and this actually seems stable. I’m impressed by JetBrain’s customer support, though. It turns out I actually had been able to create bug reports — about four or five of them. They are investigating the issue, but told me to disable native Perforce support. I haven’t tried it yet, I want to get the issue I’m working on right now out of the way, but I will tinker around with it later.
Right now I’m writing an instrumentation strategy that takes a synchronized (non-native) method and converts it to a non-synchronized method with a synchronized block in it that locks this
or this.getClass()
. Right now, it converts the function
public synchronized void test(ThisTest t) {
try {
System.out.println(t);
return;
}
catch(RuntimeException e) {
e.printStackTrace();
}
}
and its bytecode
[ 0] getstatic 0006
[ 3] aload\_1
[ 4] invokevirtual 0007
[ 7] return
[ 8] astore\_2
[ 9] aload\_2
[10] invokevirtual 0009
[13] return
[14] --
Exception from PC 0 to 7, handler at PC 8, catch RuntimeException
to this bytecode:
[ 0] * aload\_0 // this
[ 1] * monitorenter
[ 2] getstatic 0006
[ 5] aload\_1
[ 6] invokevirtual 0007
[ 9] * aload\_0
[10] * monitorexit
[11] return
[12] astore\_2
[13] aload\_2
[14] invokevirtual 0009
[17] * aload\_0
[18] * monitorexit
[19] return
[20] * aload\_0
[21] * monitorexit
[22] * athrow
[23]
Exception from PC 0 to 9, handler at PC 12, catch RuntimeException
Exception from PC 0 to 19, handler at PC 20, catch all
Inserted bytecode has been marked with a *
in front. The last five lines are part of an exception handler for anything Throwable
to make sure the lock gets released even if an exception ripples up the stack.
I’ll still have to make sure the exception table is right. That brought up another question, though: Should athrow
be considered a “return instruction”? It probably should be… it’s a place where control flow can exit a function.
Update
Fixed errors. See more recent post.