On Sun, 7 Aug 2022 07:55:26 GMT, Peter Levart <plev...@openjdk.org> wrote:

>> Can I please get a review of this change which proposes to fix 
>> https://bugs.openjdk.org/browse/JDK-8290041? 
>> 
>> As noted by the reporter, the current implementation is buggy since the 
>> calculation can result in a different value of the hashcode depending on the 
>> order of iteration of the `Modifier`s. The commit in this PR changes that 
>> computation to produce consistent result irrespective of the order in which 
>> the `Modifier`s (enum) is iterated upon.
>> 
>> A new test has been added which reproduces the issue and verifies the fix.
>
> src/java.base/share/classes/java/lang/module/ModuleDescriptor.java line 2630:
> 
>> 2628:         int h = 0;
>> 2629:         for (Enum<?> e : enums) {
>> 2630:             h = h + Objects.hashCode(e.name()) * 43;
> 
> why * 43 ? Isn't String.hashCode good enough?

A sum of e.name().hashCode() should be okay here.

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

PR: https://git.openjdk.org/jdk/pull/9790

Reply via email to