< prev index next >
test/hotspot/jtreg/runtime/Monitor/NonOwnerOps.java
Print this page
rev 55977 : imported patch 8229212.cr0
rev 55979 : 8229212: clear up CHECK_OWNER confusion in objectMonitor.cpp
Reviewed-by: dholmes, coleenp
*** 29,93 ****
* @run main NonOwnerOps
*/
public class NonOwnerOps {
public static void main(String[] args) {
- boolean after;
int error_count = 0;
Object obj;
obj = new Object();
- after = false;
try {
obj.wait();
! after = true;
} catch (InterruptedException ie) {
System.err.println("ERROR: wait() by non-owner thread threw " +
"InterruptedException which is not expected.");
error_count++;
} catch (IllegalMonitorStateException imse) {
System.out.println("wait() by non-owner thread threw the " +
"expected IllegalMonitorStateException:");
System.out.println(" " + imse);
}
- if (after) {
- System.err.println("ERROR: wait() by non-owner thread did not " +
- "throw IllegalMonitorStateException.");
- error_count++;
- }
obj = new Object();
- after = false;
try {
obj.notify();
! after = true;
} catch (IllegalMonitorStateException imse) {
System.out.println("notify() by non-owner thread threw the " +
"expected IllegalMonitorStateException:");
System.out.println(" " + imse);
}
- if (after) {
- System.err.println("ERROR: notify() by non-owner thread did not " +
- "throw IllegalMonitorStateException.");
- error_count++;
- }
obj = new Object();
- after = false;
try {
obj.notifyAll();
! after = true;
} catch (IllegalMonitorStateException imse) {
System.out.println("notifyAll() by non-owner thread threw the " +
"expected IllegalMonitorStateException:");
System.out.println(" " + imse);
}
- if (after) {
- System.err.println("ERROR: notifyAll() by non-owner thread did " +
- "not throw IllegalMonitorStateException.");
- error_count++;
- }
if (error_count != 0) {
throw new RuntimeException("Test failed with " + error_count +
" errors.");
}
--- 29,80 ----
* @run main NonOwnerOps
*/
public class NonOwnerOps {
public static void main(String[] args) {
int error_count = 0;
Object obj;
obj = new Object();
try {
obj.wait();
! System.err.println("ERROR: wait() by non-owner thread did not " +
! "throw IllegalMonitorStateException.");
! error_count++;
} catch (InterruptedException ie) {
System.err.println("ERROR: wait() by non-owner thread threw " +
"InterruptedException which is not expected.");
error_count++;
} catch (IllegalMonitorStateException imse) {
System.out.println("wait() by non-owner thread threw the " +
"expected IllegalMonitorStateException:");
System.out.println(" " + imse);
}
obj = new Object();
try {
obj.notify();
! System.err.println("ERROR: notify() by non-owner thread did not " +
! "throw IllegalMonitorStateException.");
! error_count++;
} catch (IllegalMonitorStateException imse) {
System.out.println("notify() by non-owner thread threw the " +
"expected IllegalMonitorStateException:");
System.out.println(" " + imse);
}
obj = new Object();
try {
obj.notifyAll();
! System.err.println("ERROR: notifyAll() by non-owner thread did " +
! "not throw IllegalMonitorStateException.");
! error_count++;
} catch (IllegalMonitorStateException imse) {
System.out.println("notifyAll() by non-owner thread threw the " +
"expected IllegalMonitorStateException:");
System.out.println(" " + imse);
}
if (error_count != 0) {
throw new RuntimeException("Test failed with " + error_count +
" errors.");
}
< prev index next >