Przykład


public static final class SomeType {}

public class SerializableField implements Serializable {
public SerializableField( String str ) {
super();
this .str = str;
nonser = new SomeType();
}

private String str;
private SomeType nonser;

private static final long serialVersionUID = 123;
}


Rozwiązanie
Zadeklaruj typ pola jako możliwy do przekształcenia do postaci szeregowej.

public static final class SomeType implements Serializable {}

public class SerializableField() implements Serializable {

public SerializableField( String str ) {
super();
this .str = str;
nonser = new SomeType();
}

private String str;
private SomeType nonser;

private static final long serialVersionUID = 123;
}

Rozwiązanie
Zadeklaruj pole jako przejściowe.

public static final class SomeType {}

public class SerializableField implements Serializable {

public SerializableField( String str ) {
super();
this .str = str;
nonser = new SomeType();
}

private String str;
private transient SomeType nonser;

private static final long serialVersionUID = 123;


}