public GsonBuilder newBuilder() {
    return new GsonBuilder(this);
  }
@Test
  public void testDefaultGsonNewBuilderModification() {
    Gson gson = new Gson();
    GsonBuilder gsonBuilder = gson.newBuilder();

    // Modifications of `gsonBuilder` should not affect `gson` object
    gsonBuilder.registerTypeAdapter(
        CustomClass1.class,
        new TypeAdapter<CustomClass1>() {
          @Override
          public CustomClass1 read(JsonReader in) throws IOException {
            throw new UnsupportedOperationException();
          }

          @Override
          public void write(JsonWriter out, CustomClass1 value) throws IOException {
            out.value("custom-adapter");
          }
        });
    gsonBuilder.registerTypeHierarchyAdapter(
        CustomClass2.class,
        new JsonSerializer<CustomClass2>() {
          @Override
          public JsonElement serialize(
              CustomClass2 src, Type typeOfSrc, JsonSerializationContext context) {
            return new JsonPrimitive("custom-hierarchy-adapter");
          }
        });
    gsonBuilder.registerTypeAdapter(
        CustomClass3.class,
        new InstanceCreator<CustomClass3>() {
          @Override
          public CustomClass3 createInstance(Type type) {
            return new CustomClass3("custom-instance");
          }
        });

    assertDefaultGson(gson);
    // New GsonBuilder created from `gson` should not have been affected by changes either
    assertDefaultGson(gson.newBuilder().create());

    // But new Gson instance from `gsonBuilder` should use custom adapters
    assertCustomGson(gsonBuilder.create());
  }