8210731: PropertiesParser does not produce reproducible output
authorihse
Fri, 14 Sep 2018 09:16:51 +0200
changeset 51737 30e6a0b9d691
parent 51736 42d99cb7f50f
child 51738 606e039bd655
8210731: PropertiesParser does not produce reproducible output Reviewed-by: mchung, jjg, erikj
make/langtools/tools/propertiesparser/PropertiesParser.java
--- a/make/langtools/tools/propertiesparser/PropertiesParser.java	Thu Sep 13 22:45:12 2018 -0700
+++ b/make/langtools/tools/propertiesparser/PropertiesParser.java	Fri Sep 14 09:16:51 2018 +0200
@@ -30,7 +30,7 @@
 
 import java.io.File;
 import java.io.PrintStream;
-import java.util.HashMap;
+import java.util.TreeMap;
 import java.util.Map;
 
 /** Translates a .properties file into a .java file containing an enum-like Java class
@@ -96,12 +96,13 @@
     }
 
     private Map<String, String> parseOptions(String args[]) {
-        Map<String, String> optionsMap = new HashMap<>(args.length);
+        /* Use TreeMap to guarantee stable forEach iteration */
+        Map<String, String> optionsMap = new TreeMap<>();
         for ( int i = 0; i < args.length ; i++ ) {
             if ( "-compile".equals(args[i]) && i+2 < args.length ) {
                 optionsMap.put(args[++i], args[++i]);
             } else {
-                return new HashMap<>();
+                return new TreeMap<>();
             }
         }
         return optionsMap;