Oliver Wong wrote on 13.11.2006 22:25:
The javadocs explain exactly what guarantees are and are not made
with regards to SoftReference. As usual for things intimately tied with
the garbage collector, a lot of its behaviour is implementation defined.
Well the Javadocs says (and that's the reason for my assumptions):
"All soft references to softly-reachable objects are guaranteed to have
been cleared before the virtual machine throws an OutOfMemoryError.
Otherwise no constraints are placed upon the time at which a soft
reference will be cleared or the order in which a set of such references
to different objects will be cleared."
Especially the part about "Otherwise no constraints are placed upon the
time", which sounds to me like "The will *only* be collected to prevent an
OOME", which clearly isn't the case.
No, "no constraints" means the JVM is allowed to do whatever it wants.
the getter always returns null.