<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
“Deterministic testing” might be a misleading term. I mean driving a single threaded construct through tests involving situations like timed waits, synchronization with other threads, IO errors and so on, but in a more natural way than you could achieve with
normal Java constructs. For instance: if a program wants to wait for five minutes, the test doesn’t have to wait. If a thread sleeps waiting for some signal to be fired then you can know immediately once it reaches that point in the program, fire the signal
and then resume it.
<div><br>
</div>
<div>Normally when testing code like that you face the problem of your test harness needing to synchronize with the code under test to ensure events happen at the right times, which in turn can mean a lot of test-related concerns intruding upon production code.
Our framework lets you single step a thread in a blocking manner up to the next wait and advance a virtualized clock which the waits respect. If you are deterministically testing two threads at once, you can single step one thread, do something, single step
another, and so on. So they advance “deterministically” in the test and you can white-box assert on their state at each suspension point. Of course, they still have to synchronize with each other in some way to be correct in production.</div>
<div><br>
</div>
<div>Does that explanation make sense?<br id="lineBreakAtBeginningOfMessage">
<div><br>
<blockquote type="cite">
<div>On 24 Jun 2025, at 18:05, Robert Engels <robaho@me.com> wrote:</div>
<br class="Apple-interchange-newline">
<div>
<div dir="auto">
<div dir="ltr"></div>
<div dir="ltr">As a side note - i would love to learn more about deterministic testing - seems like an oxymoron to me - at least in trying to modify the JVM to simulate determinism directly. I’ve never heard of anything like this working. Clearly, you can write
a deterministic simulator (tester) for event flows etc. but afaik these are done in a higher level environment. Even real time Java was never deterministic so I don’t see how this would be useful - but I’m curious. </div>
<div dir="ltr"><br>
<blockquote type="cite">On Jun 24, 2025, at 10:58 AM, Alan Bateman <alan.bateman@oracle.com> wrote:<br>
<br>
</blockquote>
</div>
<blockquote type="cite">
<div dir="ltr"> <br>
<br>
<div class="moz-cite-prefix">On 22/06/2025 23:24, Quinn Klassen wrote:<br>
</div>
<blockquote type="cite" cite="mid:CAPg4LcRkKajd+msvZpqpcF-WQJQU3zroufKVFhP_jOZwacgHQQ@mail.gmail.com">
<div dir="ltr">:
<div><br>
</div>
<div>For timed operations ideally I would like the virtual thread to request the scheduler it wants to do a timed operation and the scheduler decides how to accomplish this. That may be too high level an interface to add since it looks like more libraries use
`<span style="color:rgb(53,56,51);font-family:"DejaVu Sans",Arial,Helvetica,sans-serif;font-size:14px">java.util.concurrent.locks.LockSupport</span>`<span style="color:rgb(53,56,51);font-family:"DejaVu Sans",Arial,Helvetica,sans-serif;font-size:14px">. </span>This
is my first time looking at the implementation of some of these low level calls, but maybe it would be more realistic to allow a pluggable time source and interception of these parking utilities.</div>
</div>
<br>
</blockquote>
Can you say a bit more about what you are doing? Mike Hearn mentioned deterministic testing but I can't tell from your mails if this is what you are doing.<br>
<br>
In any case, the experimental interface for the scheduler is deliberately minimal. If a virtual thread waits in timed-Object.wait for example, then controls returns to scheduler. When the virtual thread can continue then its task will be queued to the scheduler
to execute. This may be triggered by an Object.notify, timeout + monitor reacquired, interrupted + object reacquired. So triggered by the VM or other parts of the runtime. Also timeout is just one of the cases that causes a thread to continue. It's the same
with LockSupport.parkNanos. I don't know if you are expecting the custom scheduler (essentially arbitrary code) to run at these critical times but right now, the scheduler is just used to execute tasks.<br>
<br>
-Alan<br>
<br>
<br>
</div>
</blockquote>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</body>
</html>