< prev index next >

src/java.base/share/classes/jdk/internal/module/ModuleHashes.java

Print this page
rev 58306 : 8240734: ModuleHashes attribute not reproducible between builds
Reviewed-by: duke
Contributed-by: hedongbo@huawei.com

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -32,10 +32,11 @@
 import java.nio.file.Path;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.TreeMap;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
 
 /**

@@ -132,11 +133,11 @@
      * path to the entry (module artifact).
      *
      * @return ModuleHashes that encapsulates the hashes
      */
     public static ModuleHashes generate(Map<String, Path> map, String algorithm) {
-        Map<String, byte[]> nameToHash = new HashMap<>();
+        Map<String, byte[]> nameToHash = new TreeMap<>();
         for (Map.Entry<String, Path> entry: map.entrySet()) {
             String name = entry.getKey();
             Path path = entry.getValue();
             nameToHash.put(name, computeHash(path, algorithm));
         }
< prev index next >