please include function getOpt_cached. // Some people use this. static Field setOpt_findField(Class c, S field) { HashMap map; synchronized(getOpt_cache) { map = getOpt_cache.get(c); if (map == null) map = getOpt_makeCache(c); } ret map.get(field); } static void setOpt(Object o, String field, Object value) ctex { if (o == null) ret; ifclass _SetField if (o << _SetField) ret with o/_SetField._setField(field, value); endif Class c = o.getClass(); HashMap map; synchronized(getOpt_cache) { map = getOpt_cache.get(c); if (map == null) map = getOpt_makeCache(c); } if (map == getOpt_special) { if (o instanceof Class) { setOpt((Class) o, field, value); ret; } // It's probably a subclass of Map. Use raw method setOpt_raw(o, field, value); ret; } Field f = map.get(field); if (f != null) smartSet(f, o, value); // possible improvement: skip setAccessible } static void setOpt(Class c, String field, Object value) { if (c == null) ret; try { Field f = setOpt_findStaticField(c, field); if (f != null) smartSet(f, null, value); } catch (Exception e) { throw new RuntimeException(e); } } static Field setOpt_findStaticField(Class c, String field) { Class _c = c; do { for (Field f : _c.getDeclaredFields()) if (f.getName().equals(field) && (f.getModifiers() & java.lang.reflect.Modifier.STATIC) != 0) { f.setAccessible(true); return f; } _c = _c.getSuperclass(); } while (_c != null); ret null; }