RFR: 7903321: Use a set instead of a map to record methods in class 'MethodGroup' [v2]

Aleksey Shipilev shade at openjdk.org
Wed Sep 21 11:08:16 UTC 2022


On Wed, 21 Sep 2022 11:02:58 GMT, Guoxiong Li <gli at openjdk.org> wrote:

>> Hi all,
>> 
>> This patch changes the type of the field `MethodGroup#methods` from a map to a set so that it is more suitable for its meaning.
>> 
>> Thanks for the taking the time to review.
>> 
>> Best Regards,
>> -- Guoxiong
>
> Guoxiong Li has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Simplify the method 'addMethod'.

Changes requested by shade (Committer).

jmh-core/src/main/java/org/openjdk/jmh/generators/core/MethodGroup.java line 78:

> 76:             throw new GenerationException(
> 77:                     "@" + Benchmark.class.getSimpleName() + " method is duplicate with " +
> 78:                             mi.method.getQualifiedName() + ". JMH needs an uniquely named method, regardless of the arguments list. ",

Aha! Now I remember why it was `Map` -- we needed `exist` here. But we can also simplify the diagnostics. Say, for example:


            throw new GenerationException(
                    "Duplicate @" + Benchmark.class.getSimpleName() + " method name: " +
                            mi.method.getQualifiedName() + ". JMH needs an uniquely named method, regardless of the arguments list. ",


This would probably need test adjustments that might expect different error message.

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

PR: https://git.openjdk.org/jmh/pull/79


More information about the jmh-dev mailing list