Skip to content

Commit

Permalink
8240734: ModuleHashes attribute not reproducible between builds
Browse files Browse the repository at this point in the history
Backport-of: f4b5488
  • Loading branch information
RealCLanger committed Mar 19, 2022
1 parent 23af0b1 commit e6f8c1e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
@@ -1,5 +1,5 @@
/*
* 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
Expand Down Expand Up @@ -34,6 +34,7 @@
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;
Expand Down Expand Up @@ -134,7 +135,7 @@ public static byte[] computeHash(Path file, String algorithm) {
* @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();
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 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
Expand Down Expand Up @@ -34,6 +34,7 @@
import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -98,7 +99,7 @@ public Map<String, ModuleHashes> computeHashes(Set<String> roots) {
// the modules to record the hashes - it is the first matching
// module and has not been hashed during the traversal.
Set<String> mods = new HashSet<>();
Map<String, ModuleHashes> hashes = new HashMap<>();
Map<String, ModuleHashes> hashes = new TreeMap<>();
builder.build()
.orderedNodes()
.filter(mn -> roots.contains(mn) && !mods.contains(mn))
Expand Down

1 comment on commit e6f8c1e

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.