Add a test for an issue which I believe is caused by failure to identify
an asynchronous method.
Unfortunately I am unable to actually produce a failing test; instead an
exception message is generated during test execution. This seems to be an
issue with the test runner mechanism.
@@ -167,6 +167,13 @@ public class VMTest {
assertEquals("ok", acl.instanceState);
}
+ @Test
+ public void asyncWait() {
+ AsyncClinitClass acl = new AsyncClinitClass();
+ acl.doWait();
+ assertEquals("ok", acl.instanceState);
+ }
+
@Test
@SkipJVM
public void loopAndExceptionPhi() {
@@ -249,8 +256,23 @@ public class VMTest {
instanceState += "ok";
try {
Thread.sleep(1);
+ } catch (InterruptedException ie) {
+ throw new RuntimeException(ie);
}
- catch (InterruptedException ie) {
+ }
+
+ public synchronized void doWait() {
+ new Thread(() -> {
+ synchronized (AsyncClinitClass.this) {
+ notify();
+ }
+ }).start();
+
+ try {
+ Thread.sleep(1);
+ wait();
+ } catch (InterruptedException ie) {
+ instanceState = "error";
throw new RuntimeException(ie);
}
}
