Name: krC82822 Date: 11/02/2000
2 Nov 2000, eval1127@eng -- reproduced with 1.3.0 (Solaris).
See also # 4239645, 4278871.
-----------
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
When a SoftReference is cleared, the clear method on the subclass is not called.
The JDK documentation explicitly states that we can derive a Reference. So I
don't see what I'm doing wrong. It should be a bug.
To reproduce the problem, launch the following example with the command:
java -mx1m RefBug you will see:
D:\Users\Jolif\Essais>java -mx1m RefBug
Soft reference created
in soft [Ljava.lang.String;@3fbdb0
in soft [Ljava.lang.String;@3fbdb0
in soft null << the clear method has not been called !
import java.lang.ref.*;
public class RefBug
{
private static class MySoftReference extends SoftReference
{
public MySoftReference(Object referent)
{
super(referent);
System.out.println("Soft reference created");
}
public void clear()
{
super.clear();
System.out.println("I just clear()'d my ref");
}
}
// CJO 10/00
public static void main(String arg[])
{
SoftReference ref = new MySoftReference(new String[10000]);
System.out.println("in soft "+ref.get());
String[] array = new String[10000];
System.out.println("in soft "+ref.get());
System.gc();
try {
Thread.sleep(10000);
} catch (Exception e) {}
System.gc();
System.out.println("in soft "+ref.get());
}
}
(Review ID: 111128)
======================================================================
- duplicates
-
JDK-6354623 java.util.Service poorly named
-
- Resolved
-