The agent jar
.threads(n) switches threads between steps and at the locks you name.
A race inside the code under test, between a read of a field and a write to it, is out of its
reach, unless the code is rewritten to let it switch there. proptastic-agent does that, as a
Java agent, to the packages you name. Races in plain code is the
guide; this page is the reference.
Attaching it
Section titled “Attaching it”-javaagent:proptastic-agent.jar=com/example/,org/acme/;pointsAfter =, the packages and classes to rewrite, comma-separated. A package ends in /, . or
.* and covers every class under it: com/example/, com.example.*. A name whose last part
starts with a capital, com/example/Ledger, is that one class and the classes nested in it. Any
other name is a package, so com.example works too. Dots are read as slashes. A name no class
that loaded matched, a misspelt class or one that never loaded, is said on stderr as the JVM ends:
proptastic agent: no class that loaded matched com/example/Ledgr, so nothing was rewritten there; a package ends in /, as com/example/After ;, the
modes, comma-separated: points for .threads(n)’s switch points, which is the default when
there are none, and coverage for a search’s probes. Both can run at once, ;points,coverage.
It needs JDK 24 or later in the test JVM: it rewrites with the JDK’s own ClassFile API. On an older JDK it rewrites nothing and says so.
What it rewrites
Section titled “What it rewrites”In the classes of the packages named, a switch point:
- before each read and write of a field, but a class’s own final fields, and none in a constructor;
- before each read and write of an array’s element,
counts[0]++on a finalint[]among them, but the stores that fill an array the method has only just made, an initializer’s or a varargs call’s, and again none in a constructor; - at each monitor or lock taken or let go,
synchronizedandjava.util.concurrent’s locks, which a thread waits for while another holds it; - around each wait and signal,
wait/notifyand conditions: a wait lets its lock go until signalled, and a timed one wakes when no thread could run; - at each call that waits but can be tried, taken in the code’s place: a blocking queue’s
put,takeand timedofferandpoll, aStampedLock’swriteLockandreadLock, and a lock held through another of its views, as aReentrantReadWriteLock’s are. Each is tried, and while it can’t go on, the thread waits for another to move, then tries again; a read lock is held by many threads at once; - at each park and unpark,
LockSupport’s: a park waits for its unpark, one given first lets it go on at once, and a timed one wakes when no thread could run; - before each other call into
java.util.concurrent, aStampedLock’sunlockWriteamong them; - before each
VarHandleaccess and fence,getVolatile,setRelease,compareAndSet,getAndAdd,fullFenceand the rest, as the JDK makes the read or write where no point can go.
It rewrites the packages named and no others, so name your own code’s: the JDK’s own classes and
proptastic’s are never meant to be rewritten. A preemption names its point,
paused before it writes Counter.count, or for an element, by what its array holds,
paused before it writes an element of int[]; a lock or monitor is named by the field that holds
it, else by its class.
Coverage
Section titled “Coverage”With coverage, the agent adds a probe at each method’s entry and at each place control can jump
to: each side of a branch, each switch case, each exception handler. A search counts the branches
each input reaches, in 65,536 counters, and keeps the inputs that reach something new
(Coverage-guided fuzzing). It also notes the values the code compares with,
two ints, two longs, a String.equals, for the search to try. A probe is named by its class,
its method and its place, so the same branch has the same name in every run.
proptastic fuzz attaches the agent itself, with coverage, to the packages --cover names, or
the properties’ own; you don’t add it to the build for that.
Off a schedule
Section titled “Off a schedule”The rewritten code calls io.proptastic.Points, and with coverage, io.proptastic.Probes and
io.proptastic.Compares. Off a schedule and off a search, in every other test and in a plain run,
each call does the plain thing at once, and the counts are never read, so a rewritten class behaves
as it was written.
Limits
Section titled “Limits”- 100 switch points a step in the rewritten code, an array’s elements counted with fields: a
step that loops over an array spends one at each element. Past them, the rest of the step runs
without switching, so the search still finishes, and a pass whose step went past them says so
with a
!line. - One thread at a time, in program order. It explores interleavings, not the reorderings a weak memory model allows.
- A real
waitis polled: a waiting thread checks for its turn every millisecond, so code that waits a lot runs slower on a schedule. - Only the packages you name. A race inside a library you didn’t name happens between its points, not at them.
- No points where the JDK does the work. A field read or written through a method handle
(
findGetter,findSetter,unreflectGetterand the like), by reflection (Field.get,Field.set) or throughUnsafehas no point at the access. A method handle to a method of your own needs none:invokeandinvokeExactrun that method, with its points. - No points in hidden classes. A class defined at run time with
Lookup.defineHiddenClassis never offered to the agent, so it runs as written. - It says what it can tell. When the rewritten code defines a hidden class, makes a field
handle or reaches a field by reflection, the next pass says so once, after its claim:
! Minted.mint defines a hidden class, which the agent can't rewrite: a race there can be missed.Unsafe, and a hidden class a library you didn’t name defines, it can’t tell. - A park never wakes early. A park waits for its unpark, or a timed one for no thread to be able to run. A real park can return for no reason, so code that takes its return to mean it was unparked can pass here and still fail for real.
- What it doesn’t schedule blocks for real. A
CountDownLatch, aSemaphore, aCyclicBarrier, aFuture’sget, aSynchronousQueue, aDelayQueueand a blocking deque’s ownputFirstandtakeLastget a point before their calls, then block for real: with one thread running at a time, the thread that would let one go on can’t run. After ten seconds the run fails, saying so:thread 1 is blocked in CountDownLatch.await, which proptastic doesn't schedule, and that it’s proptastic’s limit, not a deadlock in the code.