From: gmungoc Date: Thu, 2 May 2019 14:35:26 +0000 (+0100) Subject: JAL-3235 override entrySet() to output Properties sorted by key (Java 9) X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=0c74355c2b58d84d300d62edbb41806b04e834b2;p=jalview.git JAL-3235 override entrySet() to output Properties sorted by key (Java 9) --- 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 */