: Date: Mon, 12 Jul 1999 18:12:34 -0700
: From: Christoph Toshok <[EMAIL PROTECTED]>
:
: Jochen Hoenicke wrote:
:
: > I have just committed the jdk 1.2 Reference classes java.lang.ref.
: > They don't have any special functionality. This should be AFAIK
: > implemented by the garbage collection.
:
: unfortunately, the JDK1.2 Reference classes do a lot more -- they
: actually have some code in there.
Yes, there is something more; when I run JDK1.2 with my classes the
jvm complains that it can't access a private fields. But since these
fields are not documented anywhere, I don't see a clean room way to
implement the missing functionality.
But the real part (deciding if a reference should be automatically
cleared and enqueued) has to be done by the garbage collection.
: > This should enable us to implement WeakHashtable (even if it doesn't
: > work yet, it will at least compile) and to use References for caches
: > (the java.util.ResourceBundle come into my mind).
:
: SoftReferences are better for this. WeakReferences are cleared whenever
: they are found to be the only path to an object. SoftReferences are
: cleared when memory gets tight.
Yes, I know. WeakHashMap are not meant for caches, since they use
weak references to the _key_, not the value. I have already mentioned
that in the javadoc comment of WeakHashMap.
Jochen