Here you can find the source of getInstance()
public static Gson getInstance()
//package com.java2s; //License from project: Open Source License import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.InstanceCreator; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; public class Main { private static final Gson SERIALIZER = new GsonBuilder().setPrettyPrinting() .registerTypeAdapter(ReadWriteLock.class, (InstanceCreator<ReadWriteLock>) type -> new ReentrantReadWriteLock(true)) //Dont really care about 1:1 serialization of this .create();// w w w.j a v a 2 s . co m public static Gson getInstance() { return SERIALIZER; } }