スキップしてメイン コンテンツに移動

投稿

ラベル(Externalization)が付いた投稿を表示しています

Java Customize Serialization - Using Externalizable

I will show you how to customize Java serialization (Externalization), performance comparison default serialization vs my externalization implmentation in this post. In the most cases, you don't have to care about the serialization performance of default implementation. But the default implementation uses reflection so it might be a problem if you develop performance critical application. Externalizable Implement your own serialization is very simple. Just implements Externailizable interface into the class. Here is the example code - simple pojo class and TreeMap which implements Externalizable. package com.dukesoftware.demos.externalizable; import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; import java.util.ArrayList; import java.util.List; public class ExternalizableClass implements Externalizable{ private String field1; private Double field2; private List<String> field3; public S