Fix so references are properly cleared on Kaffe JVM
bug 34689, by Guilhem Lavaux git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@169101 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
decc437cc7
commit
d9796b6160
|
@ -218,6 +218,9 @@
|
|||
<contributor>
|
||||
<name>Olaf Krische</name>
|
||||
</contributor>
|
||||
<contributor>
|
||||
<name>Guilhem Lavaux</name>
|
||||
</contributor>
|
||||
<contributor>
|
||||
<name>David Leppik</name>
|
||||
</contributor>
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.apache.commons.collections.map.AbstractTestMap;
|
|||
* @version $Revision$ $Date$
|
||||
*
|
||||
* @author Paul Jack
|
||||
* @author Guilhem Lavaux
|
||||
*/
|
||||
public class TestReferenceMap extends AbstractTestMap {
|
||||
|
||||
|
@ -152,14 +153,15 @@ public class TestReferenceMap extends AbstractTestMap {
|
|||
}
|
||||
*/
|
||||
|
||||
/** Tests whether purge values setting works */
|
||||
public void testPurgeValues() throws Exception {
|
||||
// many thanks to Juozas Baliuka for suggesting this method
|
||||
WeakReference keyReference;
|
||||
WeakReference valueReference;
|
||||
|
||||
public Map buildRefMap() {
|
||||
Object key = new Object();
|
||||
Object value = new Object();
|
||||
|
||||
WeakReference keyReference = new WeakReference(key);
|
||||
WeakReference valueReference = new WeakReference(value);
|
||||
keyReference = new WeakReference(key);
|
||||
valueReference = new WeakReference(value);
|
||||
|
||||
Map testMap = new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.HARD, true);
|
||||
testMap.put(key, value);
|
||||
|
@ -167,10 +169,14 @@ public class TestReferenceMap extends AbstractTestMap {
|
|||
assertEquals("In map", value, testMap.get(key));
|
||||
assertNotNull("Weak reference released early (1)", keyReference.get());
|
||||
assertNotNull("Weak reference released early (2)", valueReference.get());
|
||||
return testMap;
|
||||
}
|
||||
|
||||
// dereference strong references
|
||||
key = null;
|
||||
value = null;
|
||||
/** Tests whether purge values setting works */
|
||||
public void testPurgeValues() throws Exception {
|
||||
// many thanks to Juozas Baliuka for suggesting this method
|
||||
|
||||
Map testMap = buildRefMap();
|
||||
|
||||
int iterations = 0;
|
||||
int bytz = 2;
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.commons.collections.IterableMap;
|
|||
*
|
||||
* @author Paul Jack
|
||||
* @author Stephen Colebourne
|
||||
* @author Guilhem Lavaux
|
||||
*/
|
||||
public class TestReferenceIdentityMap extends AbstractTestIterableMap {
|
||||
|
||||
|
@ -261,25 +262,29 @@ public class TestReferenceIdentityMap extends AbstractTestIterableMap {
|
|||
}
|
||||
*/
|
||||
|
||||
/** Tests whether purge values setting works */
|
||||
public void testPurgeValues() throws Exception {
|
||||
// many thanks to Juozas Baliuka for suggesting this method
|
||||
WeakReference keyReference;
|
||||
WeakReference valueReference;
|
||||
|
||||
public Map buildRefMap() {
|
||||
Object key = new Object();
|
||||
Object value = new Object();
|
||||
|
||||
WeakReference keyReference = new WeakReference(key);
|
||||
WeakReference valueReference = new WeakReference(value);
|
||||
keyReference = new WeakReference(key);
|
||||
valueReference = new WeakReference(value);
|
||||
|
||||
Map testMap = new ReferenceIdentityMap(ReferenceIdentityMap.WEAK, ReferenceIdentityMap.HARD, true);
|
||||
Map testMap = new ReferenceIdentityMap(ReferenceMap.WEAK, ReferenceMap.HARD, true);
|
||||
testMap.put(key, value);
|
||||
|
||||
assertEquals("In map", value, testMap.get(key));
|
||||
assertNotNull("Weak reference released early (1)", keyReference.get());
|
||||
assertNotNull("Weak reference released early (2)", valueReference.get());
|
||||
return testMap;
|
||||
}
|
||||
|
||||
// dereference strong references
|
||||
key = null;
|
||||
value = null;
|
||||
/** Tests whether purge values setting works */
|
||||
public void testPurgeValues() throws Exception {
|
||||
// many thanks to Juozas Baliuka for suggesting this method
|
||||
Map testMap = buildRefMap();
|
||||
|
||||
int iterations = 0;
|
||||
int bytz = 2;
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.apache.commons.collections.BulkTest;
|
|||
* @version $Revision$ $Date$
|
||||
*
|
||||
* @author Paul Jack
|
||||
* @author Guilhem Lavaux
|
||||
*/
|
||||
public class TestReferenceMap extends AbstractTestIterableMap {
|
||||
|
||||
|
@ -196,14 +197,15 @@ public class TestReferenceMap extends AbstractTestIterableMap {
|
|||
}
|
||||
*/
|
||||
|
||||
/** Tests whether purge values setting works */
|
||||
public void testPurgeValues() throws Exception {
|
||||
// many thanks to Juozas Baliuka for suggesting this method
|
||||
WeakReference keyReference;
|
||||
WeakReference valueReference;
|
||||
|
||||
public Map buildRefMap() {
|
||||
Object key = new Object();
|
||||
Object value = new Object();
|
||||
|
||||
WeakReference keyReference = new WeakReference(key);
|
||||
WeakReference valueReference = new WeakReference(value);
|
||||
keyReference = new WeakReference(key);
|
||||
valueReference = new WeakReference(value);
|
||||
|
||||
Map testMap = new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.HARD, true);
|
||||
testMap.put(key, value);
|
||||
|
@ -211,10 +213,13 @@ public class TestReferenceMap extends AbstractTestIterableMap {
|
|||
assertEquals("In map", value, testMap.get(key));
|
||||
assertNotNull("Weak reference released early (1)", keyReference.get());
|
||||
assertNotNull("Weak reference released early (2)", valueReference.get());
|
||||
return testMap;
|
||||
}
|
||||
|
||||
// dereference strong references
|
||||
key = null;
|
||||
value = null;
|
||||
/** Tests whether purge values setting works */
|
||||
public void testPurgeValues() throws Exception {
|
||||
// many thanks to Juozas Baliuka for suggesting this method
|
||||
Map testMap = buildRefMap();
|
||||
|
||||
int iterations = 0;
|
||||
int bytz = 2;
|
||||
|
|
Loading…
Reference in New Issue