...
This means that the writeUnshared()
and readUnshared()
methods cannot be used for round-trip serialization of data structures that require a one-to-one mapping between objects preserialization pre-serialization and objects postdeserializationpost-deserialization. One common example of such a data structure is a graph or network of objects that may contain reference cycles. It is also important to note that calls to the writeUnshared()
and readUnshared()
methods prevent sharing only of the object referred to by (or returned by) the methods; sharing (or not) of objects reached from references in the unshared object remains unchanged.
...
Professor
and Students
are types that extend the basic type Person
. A student (that is, an object of type Student
) has a tutor of type Professor
. A professor (that is, an object of type Professor
) has a list (actually, an ArrayList
) of tutees (of type Student
). The method checkTutees()
checks whether all of the tutees of this professor have this professor as their tutor, returning true
if that is the case and false
otherwise.
Suppose that Professor Jane has three tuteesstudents, Able, Baker, and Charlie, all of whom have Professor Jane as their tutor. Issues can arise if the writeUnshared()
and readUnshared()
methods are used with these classes, as demonstrated in the following noncompliant code example.
...