record R (int x, int y, C c) implements Serializable { }
staticclass C implements Serializable {
Object obj; // mutable
}
/** *Deserializationofarecordobject,r,doesnotsupportreferencestor, *fromanyofr'scomponents.Allreferenceswillbenull.
*/
@Test publicvoid testCycle1() throws Exception {
out.println("\n---");
C c = new C();
R r = new R(1, 2, c);
c.obj = r; // cycle, targeting record r
/** *Anobject,c,reconstructedbeforetherecord,r,canbereferencedfrom *arecordcomponent.It'sacycle,fromwithintherecord,buttherecord, *r,isnotthetarget.
*/
@Test publicvoid testCycle2() throws Exception {
out.println("\n---");
C c = new C();
R r = new R(3, 4, c);
c.obj = r; // cycle, serializing c first should preserve the cycle
record R3 (long l, R r) implements Serializable { }
/** *Deserializationofarecordobject,r,(withacycle),shouldstill *deserializefromwithinarecord,r3.
*/
@Test publicvoid testCycle4() throws Exception {
out.println("\n---");
C c = new C();
R r = new R(7, 8, c);
c.obj = r; // cycle, targeting record r
R3 r3 = new R3(9, r); // record within a record
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.