6320351 included changes to the way synchronized methods were unlocked to make the exception paths and jvmpi support simpler to implement. This broke the unlocking of synchonized methods when exceptions are thrown inside jsrs because the synthetic block handling the unlocking wasn't seen when processing exception edges while parsing jsrs. Here's a test case for this which must be compiled with a javac that uses jsr/ret for finally blocks.
public class SyncJSR {
private int count = 0;
private int[] ia = new int[1];
public synchronized void calc() {
try {
count++;
} finally {
// always throws a NullPointerException
ia[0] = 1;
}
}
public void calcCatch() {
try {
calc();
} catch (NullPointerException ex) {
// catch the exception thrown in calc()
}
}
public static void main(String[] args) {
SyncJSR obj = new SyncJSR();
for (int i = 0; i < 200000; i++) {
obj.calcCatch();
}
obj.ia = null;
obj.calcCatch();
try {
// Usually, this crashes the VM if the object was not unlocked correctly
obj.wait(1000);
} catch (Exception ex) {
}
}
}
public class SyncJSR {
private int count = 0;
private int[] ia = new int[1];
public synchronized void calc() {
try {
count++;
} finally {
// always throws a NullPointerException
ia[0] = 1;
}
}
public void calcCatch() {
try {
calc();
} catch (NullPointerException ex) {
// catch the exception thrown in calc()
}
}
public static void main(String[] args) {
SyncJSR obj = new SyncJSR();
for (int i = 0; i < 200000; i++) {
obj.calcCatch();
}
obj.ia = null;
obj.calcCatch();
try {
// Usually, this crashes the VM if the object was not unlocked correctly
obj.wait(1000);
} catch (Exception ex) {
}
}
}
- relates to
-
JDK-6320351 new register allocator for c1
-
- Resolved
-