On Thu, 4 Nov 2021 05:16:42 GMT, Jaikiran Pai <j...@openjdk.org> wrote:

>> Can I please get a review for this change which fixes the issue reported in 
>> https://bugs.openjdk.java.net/browse/JDK-8275509?
>> 
>> The `ModuleDescriptor.hashCode()` method uses the hash code of its various 
>> components to compute the final hash code. While doing so it ends up calling 
>> hashCode() on (collection of) various `enum` types. Since the hashCode() of 
>> enum types is generated from a call to `java.lang.Object.hashCode()`, their 
>> value isn't guaranteed to stay the same across multiple JVM runs.
>> 
>> The commit here proposes to use the ordinal of the enum as the hash code. As 
>> Alan notes in the mailing list discussion, any changes to the ordinal of the 
>> enum (either due to addition of new value, removal of a value or just 
>> reordering existing values, all of which I think will be rare in these 
>> specific enum types) isn't expected to produce the same hash code across 
>> those changed runtimes and that should be okay. 
>> 
>> The rest of the ModuleDescriptor.hashCode() has been reviewed too and apart 
>> from calls to the enum types hashCode(), rest of the calls in that 
>> implementation, either directly or indirectly end up as calls on 
>> `java.lang.String.hashCode()` and as such aren't expected to cause 
>> non-deterministic values.
>> 
>> A new jtreg test has been added to reproduce this issue and verify the fix.
>
> Jaikiran Pai has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   use Enum#name() for hashCode() generation instead of Enum#ordinal()

FWIW, the GitHub Actions job failure for Windows is due to an unrelated reason:


2021-11-04T05:22:48.5273779Z /usr/bin/bash: line 1:  1174 Segmentation fault    
  (core dumped) /usr/bin/make -s -r -R -I /cygdrive/d/a/jdk/jdk/jdk/make/common 
SPEC=/cygdrive/d/a/jdk/jdk/jdk/build/windows-x64/spec.gmk MAKE_LOG_FLAGS="-s" 
-f ModuleWrapper.gmk -I /cygdrive/d/a/jdk/jdk/jdk/make/common/modules 
-I/cygdrive/d/a/jdk/jdk/jdk/make/modules/java.base MODULE=java.base 
MAKEFILE_PREFIX=Copy
2021-11-04T05:22:48.5304517Z make[2]: *** [make/Main.gmk:157: java.base-copy] 
Error 139
2021-11-04T05:22:48.5305851Z make[2]: *** Waiting for unfinished jobs....
2021-11-04T05:22:48.8158343Z Compiling 12 properties into resource bundles for 
jdk.jdeps
2021-11-04T05:22:49.2707959Z 
2021-11-04T05:22:49.2712144Z ERROR: Build failed for target 'default 
(product-bundles test-bundles)' in configuration 'windows-x64' (exit code 2) 
2021-11-04T05:22:49.8818435Z 
2021-11-04T05:22:49.8823500Z No indication of failed target found.
2021-11-04T05:22:49.8845292Z Hint: Try searching the build log for '] Error'.
2021-11-04T05:22:49.9156326Z Hint: See doc/building.html#troubleshooting for 
assistance.
2021-11-04T05:22:49.9156822Z 
2021-11-04T05:22:49.9206739Z make[1]: *** 
[/cygdrive/d/a/jdk/jdk/jdk/make/Init.gmk:315: main] Error 2
2021-11-04T05:22:49.9249924Z make: *** 
[/cygdrive/d/a/jdk/jdk/jdk/make/Init.gmk:186: default] Error 2
2021-11-04T05:22:50.0054100Z ##[error]Process completed with exit code 1.

Going ahead with the merge of this PR.

Thank you Alan and Magnus for the inputs and the reviews.

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

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

Reply via email to