Добрый день. Изучаем сериализацию. В данном случае, надо поставить запрет сериализации. Так вот, почему если поставить у SubSolution.writeObject модификатор доступа public, то сериализация пройдет ? Что-то не могу понять. Буду благодарен за ссылку на похожий вопрос или статью/литературу.
public class TestFile implements Serializable {
public static void main(String args[]) throws Exception
{
FileOutputStream fileOutput = new FileOutputStream("FilePath");
ObjectOutputStream outputStream = new ObjectOutputStream(fileOutput);
SubSolution subSolution = new SubSolution();
outputStream.writeObject(subSolution);
fileOutput.close();
outputStream.close();
}
public static class SubSolution extends TestFile {
private void writeObject(ObjectOutputStream objectOutput) throws Exception {
throw new NotSerializableException();
}
private void readObject(ObjectInputStream objectInput) throws Exception {
throw new NotSerializableException();
}
}
}