changeset 51737:30e6a0b9d691

8210731: PropertiesParser does not produce reproducible output Reviewed-by: mchung, jjg, erikj
author ihse
date Fri, 14 Sep 2018 09:16:51 +0200
parents 42d99cb7f50f
children 606e039bd655
files make/langtools/tools/propertiesparser/PropertiesParser.java
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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;