- All Implemented Interfaces:
- java.io.Externalizable, java.io.Serializable
public class InternedValue
extends java.lang.Object
implements java.io.Externalizable
This class serves two purposes. Firstly, it contains static members
that maintain a bijective map between symbols and values. Secondly,
instances of this class are used in Java serialisation as wrappers
for interned values.
Since the bijective map is static it is shared between app contexts
and hence interned values can leak between apps. This is an
unavoidable consequence of wanting to fit in with standard Java
serialisation in, e.g., J2EE containers, which may happen in
threads with no associated app context. In practice this shouldn't
cause much of a problem. Firstly, many J2EE containers have
separate class loaders for separate web apps etc. Secondly, the
main purpose of interned values is to store globally unique types,
for which there is little harm in sharing between apps.
Access to the bijective map is thread-safe.
The map is *not* weak - symbols and values of map entries will not
be garbage collected. It would be desirable for map entries to be
removed when they are no longer referenced. However, it is
impossible to do so reliably, so the current set up is the only
safe solution.
- See Also:
- Serialized Form