RFR: StateObjectHandler.validateState(): fix typo and optimize [v2]
wangpeipei90
github.com+4886855+wangpeipei90 at openjdk.java.net
Mon Oct 26 15:04:17 UTC 2020
On Sat, 24 Oct 2020 16:21:46 GMT, Sergey Ponomarev <github.com+415502+stokito at openjdk.org> wrote:
>> Last commit contains extract of two methods from duplicated code that IntelliJ found. Not sure if this change has any value for you so I can revert it
>
> 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.
-------------
PR: https://git.openjdk.java.net/jmh/pull/7
More information about the jmh-dev
mailing list