Initialization of @Param's in nested @State classes

Gleb Smirnov me at gvsmirnov.ru
Mon Nov 17 15:38:48 UTC 2014


Thanks, it works for me, too.

On a barely related note, the instruction on Building the "Bleeding Edge"
JMH advises the readers to set dependency version to 1.0-SNAPSHOT, which is
misleading (should be 1.4-SNAPSHOT right now).

It might be prudent to fix this, unless it is a challenge for a
Benchmarking Master wannabe. In that case I have ruined the challenge
somewhat, sorry about that.

Gleb
On Mon, 17 Nov 2014 at 5:15 pm Aleksey Shipilev <aleksey.shipilev at oracle.com>
wrote:

> Should be fixed now with:
>  http://hg.openjdk.java.net/code-tools/jmh/rev/c60c03ff0993
>
> -Aleksey.
>
> On 11/15/2014 06:19 PM, Aleksey Shipilev wrote:
> > Thanks, so recorded:
> >  https://bugs.openjdk.java.net/browse/CODETOOLS-7901105
> >
> > -Aleksey.
> >
> > On 11/15/2014 06:13 PM, Gleb Smirnov wrote:
> >> Hi All,
> >>
> >> Given the following test case:
> >>
> >> public class NestedStateBenchmark {
> >>
> >>     @State(Scope.Benchmark)
> >>     public static class NestedState {
> >>         @Param({"0", "1"})
> >>         public int foo;
> >>     }
> >>
> >>     @State(Scope.Thread)
> >>     public static class OuterState {
> >>         public int bar;
> >>
> >>         @Setup
> >>         public void setup(NestedState nestedState) {
> >>             this.bar = -nestedState.foo;
> >>         }
> >>     }
> >>
> >>     @Benchmark
> >>     public int measure(OuterState state) {
> >>         return state.bar;
> >>     }
> >> }
> >>
> >> One would expect the `measure` method to be returning 0 or 1, with
> >> respect to
> >> the param `foo`.
> >>
> >> However, what actually happens is the benchmark crashing with the
> following
> >> exception:
> >>
> >> java.lang.IllegalStateException: The value for the parameter "foo" is
> >> not set.
> >>         at
> >> org.openjdk.jmh.runner.InfraControlL2.getParam(InfraControl.java:190)
> >>         at
> >> org.openjdk.jmh.runner.InfraControl.getParam(InfraControl.java:39)
> >>         at
> >> generated.NestedStateBenchmark_measure._jmh_tryInit_f_nestedstate3_G(
> NestedStateBenchmark_measure.java:331)
> >>         at
> >> generated.NestedStateBenchmark_measure.measure_Throughput(
> NestedStateBenchmark_measure.java:57)
> >>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >>         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> >>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> Source)
> >>         at java.lang.reflect.Method.invoke(Unknown Source)
> >>         at
> >> org.openjdk.jmh.runner.LoopBenchmarkHandler$BenchmarkTask.call(
> LoopBenchmarkHandler.java:199)
> >>         at
> >> org.openjdk.jmh.runner.LoopBenchmarkHandler$BenchmarkTask.call(
> LoopBenchmarkHandler.java:181)
> >>         at java.util.concurrent.FutureTask.run(Unknown Source)
> >>         at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown
> Source)
> >>         at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
> >> Source)
> >>         at java.lang.Thread.run(Unknown Source)
> >>
> >> This is a bug, a person familiar with the matter said
> >> (https://twitter.com/shipilev/status/533565238407618560)
> >>
> >> Reproducible with JMH 1.3.
> >
> >
>
>
>


More information about the jmh-dev mailing list