Infra Params
Aleksey Shipilev
aleksey.shipilev at oracle.com
Fri Jul 22 12:25:03 UTC 2016
Hi Alex,
Thanks for the test case!
On 07/08/2016 01:42 PM, Alex Averbuch wrote:
> I have a minimal example for reproducing this error, it goes like this:
>
> (1) Define @State(Scope.Benchmark) class named Test <--- OK
> (2) Define @Benchmark method named nothing() <--- OK
> (3) Pass @State instance into @Benchmark method, e.g. public void nothing(
> Test test ) <--- ERROR!
Yes, that's a bug in @State DAG machinery, hopefully fixed with:
https://bugs.openjdk.java.net/browse/CODETOOLS-7901743
@State(Scope.Benchmark)
public class Test {
@Setup
public void setUp(BenchmarkParams params) {}
@Benchmark
public void nothing(Test test) {}
}
The compounding factor is that you reference a single @State class both
implicitly (by the virtue of @Benchmark method being the member of
@State class), and explicitly (by injecting via the argument). This made
DAG machinery to believe the Test.setup() method should be fed with
*two* instances of BenchmarkParams. The same thing may happen with two
explicit copies of @State arguments, and it is fixed too.
Also, BenchmarkParams and other infrastructure classes are not implicit
@State-s anymore, which frees that particular example from failing even
without fixing the DAG machinery:
https://bugs.openjdk.java.net/browse/CODETOOLS-7901735
Thanks,
-Aleksey
More information about the jmh-dev
mailing list