From 99eee041ba0b1eaa26b88851432a0278381e60f3 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Fri, 14 Sep 2018 09:16:51 +0200 Subject: [PATCH] 8210731: PropertiesParser does not produce reproducible output Reviewed-by: mchung, jjg, erikj --- .../langtools/tools/propertiesparser/PropertiesParser.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/make/langtools/tools/propertiesparser/PropertiesParser.java b/make/langtools/tools/propertiesparser/PropertiesParser.java index 2cb4689a0df..f03c8bafc34 100644 --- a/make/langtools/tools/propertiesparser/PropertiesParser.java +++ b/make/langtools/tools/propertiesparser/PropertiesParser.java @@ -30,7 +30,7 @@ import propertiesparser.gen.ClassGenerator; 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 @@ public class PropertiesParser { } private Map parseOptions(String args[]) { - Map optionsMap = new HashMap<>(args.length); + /* Use TreeMap to guarantee stable forEach iteration */ + Map 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;