Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/SortedProperties.java')
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/SortedProperties.java24
1 files changed, 16 insertions, 8 deletions
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/SortedProperties.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/SortedProperties.java
index 88fd878b1..c7f5324da 100644
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/SortedProperties.java
+++ b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/SortedProperties.java
@@ -14,24 +14,31 @@ package org.eclipse.core.internal.preferences;
import java.util.*;
import java.util.Map.Entry;
+/**
+ * A {@link Properties} class whose entries are sorted by key; can <strong>only</strong> be used in limited scenarios
+ * like storing properties to a file.
+ * <p>
+ * <b>Implementation note</b>: The implementations of the {@link #keys()} and {@link #entrySet()} methods
+ * violate the contracts of {@link Properties#keySet()} and {@link Properties#entrySet()}, because the returned sets
+ * are <em>not</em> backed by this map.
+ * Overriding both methods is necessary to support Oracle and IBM VMS, see
+ * <a href="https://bugs.eclipse.org/325000">bug 325000</a>.
+ * </p>
+ */
public class SortedProperties extends Properties {
+ // Warning: This class is referenced by our friend org.eclipse.core.internal.resources.ProjectPreferences
private static final long serialVersionUID = 1L;
- public SortedProperties() {
- super();
- }
-
-
@Override
public synchronized Enumeration<Object> keys() {
TreeSet<Object> set = new TreeSet<>();
- for (Enumeration<?> e = super.keys(); e.hasMoreElements();)
+ for (Enumeration<?> e = super.keys(); e.hasMoreElements();) {
set.add(e.nextElement());
+ }
return Collections.enumeration(set);
}
-
@Override
public Set<Entry<Object, Object>> entrySet() {
TreeSet<Entry<Object, Object>> set = new TreeSet<>(new Comparator<Entry<Object, Object>>() {
@@ -42,8 +49,9 @@ public class SortedProperties extends Properties {
return s1.compareTo(s2);
}
});
- for (Iterator<Entry<Object, Object>> i = super.entrySet().iterator(); i.hasNext();)
+ for (Iterator<Entry<Object, Object>> i = super.entrySet().iterator(); i.hasNext();) {
set.add(i.next());
+ }
return set;
}
} \ No newline at end of file

Back to the top