8209880: tzdb.dat is not reproducibly built
authornaoto
Tue, 18 Sep 2018 12:42:40 -0700
changeset 51789 0535b5a54b83
parent 51788 c0f9161f591e
child 51790 62a8579bb6f1
8209880: tzdb.dat is not reproducibly built Reviewed-by: erikj, rriggs
make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesCompiler.java
make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java
--- a/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesCompiler.java	Tue Sep 18 23:20:17 2018 +0530
+++ b/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesCompiler.java	Tue Sep 18 12:42:40 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, 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
@@ -65,8 +65,6 @@
 import java.text.ParsePosition;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.NoSuchElementException;
@@ -76,6 +74,7 @@
 import java.util.regex.Matcher;
 import java.util.regex.MatchResult;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
 
 /**
  * A compiler that reads a set of TZDB time-zone files and builds a single
@@ -256,8 +255,10 @@
             for (String regionId : regionArray) {
                 out.writeUTF(regionId);
             }
-            // rules  -- hashset -> remove the dup
-            List<ZoneRules> rulesList = new ArrayList<>(new HashSet<>(builtZones.values()));
+            // rules  -- remove the dup
+            List<ZoneRules> rulesList = builtZones.values().stream()
+                .distinct()
+                .collect(Collectors.toList());
             out.writeShort(rulesList.size());
             ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
             for (ZoneRules rules : rulesList) {
--- a/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java	Tue Sep 18 23:20:17 2018 +0530
+++ b/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java	Tue Sep 18 12:42:40 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2018, 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
@@ -33,8 +33,6 @@
 import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -43,7 +41,7 @@
 import java.util.Set;
 import java.util.TreeMap;
 import java.util.TreeSet;
-import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentSkipListMap;
 import java.time.*;
 import java.time.Year;
 import java.time.chrono.IsoChronology;
@@ -131,18 +129,18 @@
     /**
      * Zone region to rules mapping
      */
-    private final Map<String, Object> zones = new ConcurrentHashMap<>();
+    private final Map<String, Object> zones = new ConcurrentSkipListMap<>();
 
     /**
      * compatibility list
      */
-    private static HashSet<String> excludedZones;
+    private static Set<String> excludedZones;
     static {
         // (1) exclude EST, HST and MST. They are supported
         //     via the short-id mapping
         // (2) remove UTC and GMT
         // (3) remove ROC, which is not supported in j.u.tz
-        excludedZones = new HashSet<>(10);
+        excludedZones = new TreeSet<>();
         excludedZones.add("EST");
         excludedZones.add("HST");
         excludedZones.add("MST");
@@ -151,8 +149,8 @@
         excludedZones.add("ROC");
     }
 
-    private Map<String, String> links = new HashMap<>(150);
-    private Map<String, List<RuleLine>> rules = new HashMap<>(500);
+    private Map<String, String> links = new TreeMap<>();
+    private Map<String, List<RuleLine>> rules = new TreeMap<>();
 
     private void load(List<Path> files) throws IOException {