State setup/tearDown order guaranties

Aleksey Shipilev shade at redhat.com
Wed Jan 17 09:21:33 UTC 2018


On 01/17/2018 04:21 AM, Alexei Osipov wrote:
> Are there any docs on execution order guaranties for "setup/tearDown" methods in @State objects with
> dependencies?
> [...]
> So I wonder if I'm doing something wrong or JMH just does not provide order guaranties for the case
> with @State(Scope.Thread) + @Setup(Level.Iteration). Any recommendations on what should I check?

You are not doing anything wrong: the @State dependencies should work as you would expect: all
states that are coming as arguments should have their helper methods executed. Except that there is
a JMH bug: it first runs all the helpers for Scope.Thread in DAG order, and then runs all the
helpers for Scope.{Benchmark|Iteration} in DAG order, which obviously breaks this assumption.

Let me handle this.

-Aleksey



More information about the jmh-dev mailing list