From 0c74355c2b58d84d300d62edbb41806b04e834b2 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 2 May 2019 15:35:26 +0100 Subject: [PATCH] JAL-3235 override entrySet() to output Properties sorted by key (Java 9) --- src/jalview/bin/Cache.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index 19aa800..2bafb10 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -43,8 +43,12 @@ import java.util.Collections; import java.util.Date; import java.util.Enumeration; import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; import java.util.Properties; +import java.util.Set; import java.util.StringTokenizer; +import java.util.TreeMap; import java.util.TreeSet; import org.apache.log4j.ConsoleAppender; @@ -266,12 +270,24 @@ public class Cache /** Jalview Properties */ public static Properties applicationProperties = new Properties() { - // override results in properties output in alphabetical order + // override so properties are output in alphabetical order (Java 8) @Override public synchronized Enumeration keys() { return Collections.enumeration(new TreeSet<>(super.keySet())); } + + // override so properties are output in alphabetical order (Java 11) + @Override + public Set> entrySet() + { + Map copy = new TreeMap<>(); + for (Object key : this.keySet()) + { + copy.put(key, this.get(key)); + } + return copy.entrySet(); + } }; /** Default file is ~/.jalview_properties */ -- 1.7.10.2