package ysoserial.payloads.util;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;

public class Reflections {

	public static Field getField(final Class<?> clazz, final String fieldName) throws Exception {
		Field field = clazz.getDeclaredField(fieldName);
		if (field == null && clazz.getSuperclass() != null) {
			field = getField(clazz.getSuperclass(), fieldName);
		}
		field.setAccessible(true);
		return field;
	}

	public static void setFieldValue(final Object obj, final String fieldName, final Object value) throws Exception {
		final Field field = getField(obj.getClass(), fieldName);
		field.set(obj, value);
	}

	public static Object getFieldValue(final Object obj, final String fieldName) throws Exception {
		final Field field = getField(obj.getClass(), fieldName);		
		return field.get(obj);
	}

	public static Constructor<?> getFirstCtor(final String name) throws Exception {
		final Constructor<?> ctor = Class.forName(name).getDeclaredConstructors()[0];
	    ctor.setAccessible(true);
	    return ctor;
	}

}

@@ -288,19 +288,58 @@
 eld 
-=
+!
 = null
- && 
+)%0A%09%09%09field.setAccessible(true);%0A%09%09else if (
 claz
@@ -364,18 +364,16 @@
 != null)
- %7B
 %0A%09%09%09fiel
@@ -424,41 +424,8 @@
 e);%0A
-%09%09%7D%0A%09%09field.setAccessible(true);%0A
 %09%09re

Call setAccessible only once