/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.gemstone.gemfire.test.junit.rules.serializable;

import java.lang.reflect.Field;

/**
 * Provides support for serialization of private fields by reflection.
 */
public class FieldSerializationUtils {

  protected FieldSerializationUtils() {
  }

  public static Object readField(final Class targetClass, final Object targetInstance, final String fieldName) {
    try {
      Field assureDeletionField = targetClass.getDeclaredField(fieldName);
      assureDeletionField.setAccessible(true);
      return assureDeletionField.get(targetInstance);
    } catch (IllegalAccessException | NoSuchFieldException e) {
      throw new Error(e);
    }
  }

  public static void writeField(final Class targetClass, final Object targetInstance, final String fieldName, final Object value) {
    try {
      Field folderField = targetClass.getDeclaredField(fieldName);
      folderField.setAccessible(true);
      folderField.set(targetInstance, value);
    } catch (IllegalAccessException | NoSuchFieldException e) {
      throw new Error(e);
    }
  }
}

@@ -1189,31 +1189,17 @@
   Field 
-assureDeletionF
+f
 ield = t
@@ -1244,31 +1244,17 @@
 ;%0A      
-assureDeletionF
+f
 ield.set
@@ -1288,23 +1288,9 @@
 urn 
-assureDeletionF
+f
 ield
@@ -1567,22 +1567,16 @@
  Field f
-olderF
 ield = t
@@ -1614,38 +1614,32 @@
 ldName);%0A      f
-olderF
 ield.setAccessib
@@ -1659,14 +1659,8 @@
    f
-olderF
 ield

Fix the names of local variables