RFR: StateObjectHandler.validateState(): fix typo and optimize [v2]
Sergey Ponomarev
github.com+415502+stokito at openjdk.java.net
Mon Oct 26 15:09:13 UTC 2020
On Mon, 26 Oct 2020 15:02:03 GMT, wangpeipei90 <github.com+4886855+wangpeipei90 at openjdk.org> wrote:
>> Sergey Ponomarev has refreshed the contents of this pull request, and previous commits have been removed. The incremental views will show differences compared to the previous content of the PR.
>
> jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java line 107:
>
>> 105: boolean hasDefaultConstructor = false;
>> 106: for (MethodInfo constructor : state.getConstructors()) {
>> 107: if (constructor.getParameters().isEmpty()) {
>
> The changes here are not equivalent. If any constructor`isEmpty `and `isPublic`, `hasDefaultConstructor` will always be `True`.
>
> But in the code change, the early exit could cause `hasDefaultConstructor` be `false` if there is a constructor `isEmpty` but not `isPublic` without iterating the default constructor yet.
is it possible to have two default constructors with empty params? Maybe not in Java but in some alternative language?
As far I know this is prohibited.
If we can have only one empty param constructor then we can check only it for having a public modifier and then skip others
-------------
PR: https://git.openjdk.java.net/jmh/pull/7
More information about the jmh-dev
mailing list