specializing jvmArgs in a derived class

Aleksey Shipilev aleksey.shipilev at oracle.com
Fri Aug 22 19:53:10 UTC 2014


Hi Tom,

On 08/22/2014 09:16 PM, Deneau, Tom wrote:
> I have a base class with
>     @Benchmark 
>     public void myBenchmark()
> 
> and several derived classes that specialize that benchmark.
> In one of the derived classes, I would like to specify that when that derived class forks, certain jvmArgs get added to the jvm command line.  Is there a way to do this?
> 
> When I tried this in the derived class
> 
>     @Override
>     @Benchmark
>     @Fork(jvmArgs="...") 
>     public void myBenchmark()
> 
> I got this error which I don't really understand:
>     Internal error: multiple methods per @Group, but not all methods have @Group

This is because JMH treats super-class @Benchmark as the benchmark
sibling on par with the sub-class @Benchmark, ignoring the fact the
super-class is overridden by Java rules. This should be fixed to at
least print a sane error message.

In your case, I would rather make the non- at Benchmark method in the
super-class, and override it with @Benchmark in each subclass. Do you
really need the @Benchmark on the super-class method in your scenario?

-Aleksey.




More information about the jmh-dev mailing list