On Wed, 18 Nov 2020 14:49:54 GMT, Weijun Wang <wei...@openjdk.org> wrote:

>> test/micro/org/openjdk/bench/java/security/PKCS12KeyStores.java line 65:
>> 
>>> 63:     }
>>> 64: 
>>> 65:     static {
>> 
>> Move these to 
>> 
>> @Setup
>> public void setup() throws Exception {
>>   ...
>> }
>> 
>> This would save you a `try-catch` section, and harness would properly fail 
>> on setup exception.
>
> Newbie on JMH. Is it worth designing the byte[] fields as static? I assume 
> there will be different objects for different forks but only one for 
> different threads?

It does not worth it to make fields `static`. It is much better to let JMH 
manage the setup, that's what `@Setup` methods are for. If you want to share 
all instance fields across the thread, then use `@State(Scope.Benchmark)`, it 
is now `Scope.Thread`.

-------------

PR: https://git.openjdk.java.net/jdk/pull/1277

Reply via email to