From 450bf77d29c3f2b23bea816be94a346645341cf7 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 29 Jun 2012 21:53:31 +0200 Subject: ridljar: partially revert 4418ad0388b58cab6a129908f78baec5bc73906e It looks like this changes a class interface that is likely part of the URE ABI; removing an interface seems risky to me. Change-Id: I90efbbdbc6ef029dd6a4e6926f6031d56ffbb10a --- ridljar/com/sun/star/lib/util/WeakMap.java | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'ridljar') diff --git a/ridljar/com/sun/star/lib/util/WeakMap.java b/ridljar/com/sun/star/lib/util/WeakMap.java index c9ed21d159de..5de60a19df11 100644 --- a/ridljar/com/sun/star/lib/util/WeakMap.java +++ b/ridljar/com/sun/star/lib/util/WeakMap.java @@ -57,8 +57,12 @@ import java.util.Set; * DisposeNotifier interface. For those that do, the associated * WeakReference wrappers are automatically cleared as soon as the * values are disposed.

+ * + * Note that this class does not actually implement the Map interface properly, + * the type of the return value of the entrySet and values methods is wrong, + * but the "implements Map" is retained for backward compatibility. */ -public final class WeakMap { +public final class WeakMap implements Map { /** * Declare the map as WeakReference instead of Entry because it makes the return @@ -116,7 +120,7 @@ public final class WeakMap { * @return true if this map contains a mapping for the * specified key */ - public boolean containsKey(K key) { + public boolean containsKey(/*K*/ Object key) { return map.containsKey(key); } @@ -130,7 +134,7 @@ public final class WeakMap { * @return true if this map maps one or more keys to the * specified value */ - public boolean containsValue(WeakReference value) { + public boolean containsValue(Object /*WeakReference*/ value) { return map.containsValue(value); } @@ -145,7 +149,7 @@ public final class WeakMap { * @return the value to which this map maps the specified key, or * null if the map contains no mapping for this key */ - public WeakReference get(K key) { + public WeakReference get(/*K*/ Object key) { return map.get(key); } @@ -161,9 +165,9 @@ public final class WeakMap { * @return previous value associated with the specified key, or * null if there was no mapping for the key */ - public WeakReference put(K key, V value) { + public Object /*WeakReference*/ put(/*K*/ Object key, /*V*/ Object value) { cleanUp(); - return map.put(key, new Entry(key, value, queue)); + return map.put((K) key, new Entry((K) key, (V) value, queue)); } /** @@ -175,7 +179,7 @@ public final class WeakMap { * @return previous value associated with the specified key, or * null if there was no mapping for the key */ - public WeakReference remove(K key) { + public Object /*WeakReference*/ remove(/*K*/ Object key) { cleanUp(); return map.remove(key); } @@ -189,7 +193,7 @@ public final class WeakMap { * must be plain objects, which are then wrapped in instances of * WeakReference. */ - public void putAll(Map m) { + public void putAll(Map/**/ m) { cleanUp(); for (Iterator> i = m.entrySet().iterator(); i.hasNext();) { Map.Entry e = i.next(); @@ -237,7 +241,7 @@ public final class WeakMap { * * @return a collection view of the mappings contained in this map */ - public Set>> entrySet() { + public Set/*>>*/ entrySet() { return map.entrySet(); } @@ -261,8 +265,8 @@ public final class WeakMap { * @return the referent of the specified WeakReference, or * null if ref is null */ - public static T getValue(WeakReference ref) { - return ref == null ? null : ref.get(); + public static T getValue(Object /*WeakReference*/ ref) { + return ref == null ? null : ((WeakReference) ref).get(); } /** -- cgit