JMH: accessing BenchmarkParams from @Setup method of @State class
<p><strong>Is it possible to access <code>BenchmarkParams</code> in the <code>@Setup</code> of a <code>@State(Scope.Benchmark)</code> class, if that class is passed into a <code>@Benchmark</code> as parameter?</strong></p>

<p>Minimal code example (actual usage is more complex, but this reproduces my issue):</p>

<pre><code>@State( Scope.Benchmark )
public class Test
{
    @Setup
    public void setUp( BenchmarkParams params ){}

    @Benchmark
    public void nothing( Test test ){}
}
</code></pre>

<p>There is a basic <a href="http://hg.openjdk.java.net/code-tools/jmh/file/13ae22114e22/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_31_InfraParams.java" rel="nofollow">JMH sample</a>, but not where the <code>@State</code> is passed into a <code>@Benchmark</code> method</p>

<p>I'd like to access <code>BenchmarkParams</code> in <code>@Setup</code> to retrieve/log per-benchmark configuration data that I create based on JMH <code>@Param</code> values</p>

<p>With the sample code, above:</p>

<ol>
<li>Define <code>@State(Scope.Benchmark)</code> class named <code>Test</code> &lt;--- works</li>
<li>Define <code>@Benchmark</code> method named <code>nothing()</code> &lt;--- works</li>
<li>Pass <code>@State</code> instance into <code>@Benchmark</code> method &lt;--- <strong>FAILS!</strong></li>
</ol>

<p>Here is the error:</p>

<pre><code>[ERROR]
/Users/.../jmh-benchmarks/target/generated-sources/annotations/test/generated/Test_nothing_jmhTest.java:[390,16]
method setUp in class test.Test cannot be applied to given
types;
  required: org.openjdk.jmh.infra.BenchmarkParams
  found:
org.openjdk.jmh.infra.generated.BenchmarkParams_jmhType,org.openjdk.jmh.infra.generated.BenchmarkParams_jmhType
  reason: actual and formal argument lists differ in length
</code></pre>

<p>Any help welcome!</p>

<p><strong>[EDIT 1]</strong></p>

<p>FYI, in my actual code there is also a <code>@State(Scope.Thread)</code> class, something more like:</p>

<pre><code>@State( Scope.Benchmark )
public abstract class TestBase
{
    @Setup
    public void setUp( BenchmarkParams params ){}
}

@State( Scope.Benchmark )
public class TestImpl extends TestBase
{
    @State( Scope.Thread )
    public static class ThreadState 
    {
            @Setup
            public void setUp( TestImpl state ){}
    }

    @Benchmark
    public void nothing( ThreadState state ){}
}
</code></pre>

<p><strong>[EDIT 2]</strong></p>

<p>As of JMH 1.3 this is no longer a problem</p>