Skip to content

Commit e6f8c1e

Browse files
committed
8240734: ModuleHashes attribute not reproducible between builds
Backport-of: f4b5488
1 parent 23af0b1 commit e6f8c1e

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,7 @@
3434
import java.security.NoSuchAlgorithmException;
3535
import java.util.Collections;
3636
import java.util.HashMap;
37+
import java.util.TreeMap;
3738
import java.util.Map;
3839
import java.util.Objects;
3940
import java.util.Set;
@@ -134,7 +135,7 @@ public static byte[] computeHash(Path file, String algorithm) {
134135
* @return ModuleHashes that encapsulates the hashes
135136
*/
136137
public static ModuleHashes generate(Map<String, Path> map, String algorithm) {
137-
Map<String, byte[]> nameToHash = new HashMap<>();
138+
Map<String, byte[]> nameToHash = new TreeMap<>();
138139
for (Map.Entry<String, Path> entry: map.entrySet()) {
139140
String name = entry.getKey();
140141
Path path = entry.getValue();

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,7 @@
3434
import java.util.Collections;
3535
import java.util.Deque;
3636
import java.util.HashMap;
37+
import java.util.TreeMap;
3738
import java.util.HashSet;
3839
import java.util.Map;
3940
import java.util.Set;
@@ -98,7 +99,7 @@ public Map<String, ModuleHashes> computeHashes(Set<String> roots) {
9899
// the modules to record the hashes - it is the first matching
99100
// module and has not been hashed during the traversal.
100101
Set<String> mods = new HashSet<>();
101-
Map<String, ModuleHashes> hashes = new HashMap<>();
102+
Map<String, ModuleHashes> hashes = new TreeMap<>();
102103
builder.build()
103104
.orderedNodes()
104105
.filter(mn -> roots.contains(mn) && !mods.contains(mn))

0 commit comments

Comments
 (0)