8210731: PropertiesParser does not produce reproducible output
Reviewed-by: mchung, jjg, erikj
--- 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;