Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Won't Fix
-
3.0.0SDK-alpha02
-
None
Description
I rediscovered that some of the deserialization code (e.g. xmi deserialization) has been deserializing empty lists by reusing a shared instance (for a particular CAS) of an empty list.
This seems like Java's sharing of other immutable objects, such as Integer (when you say new Integer(4), it returns you a shared object; likewise, strings like "123" are merged and shared where possible).
The 3.0.0-beta had previously introduced a bunch of methods on CAS and JCas to get shared 0-length arrays and lists.
I'm think it would be good to remove all of these, and instead, just change the creation of these to automatically reuse shared (per CAS) instances of these.
This has a small (tiny?) potential to "break" existing code, if code was written that depended on two different instances of, for example, an FSArray of length 0, were required to be !=.
A recovery mechanism (workaround) for these probably very rare cases would be to enable the creation of non-equal instances, perhaps via the clone() method. Even this is probably not really needed, and deserialization would still be reusing shared values.