JMH problem with State referencing

Aleksey Shipilev shade at redhat.com
Tue Dec 8 13:58:55 UTC 2020


Hi,

Sorry for late reply, JDK 16 churn got the best of me.

On 11/25/20 11:55 AM, Michal Cervenansky wrote:
> I have come across a use case where I need to reference class with @State
> Scope.Benchmark in class with @State Scope.Thread. This is possible in JMH.
> However, when I tried to use it twice, for example in both setup and
> teardown methods, then the build failed. I believe it is because parameter
> names are generated based on their type, so two parameters of the same type
> lead to generating the same parameter name, and that causes the error.

Thanks! This is the benchmark generator bug:
   https://bugs.openjdk.java.net/browse/CODETOOLS-7902807

I have a fix, and I am currently testing it.

> Please see this example, where I showcase the problem as well as how this
> feature could be still used:
> https://github.com/MichalCervenansky/Demo-JMH-State-Referencing-Problem

Thanks, this MCVE was very helpful.

> May I ask if there are any plans regarding this feature? To either better
> document it and hopefully fix the problem I have encountered or it might
> get removed in future versions?

We are leaning on keeping it in, so this bug should be fixed.

-- 
Thanks,
-Aleksey



More information about the jmh-dev mailing list