Here you can find the source of setFieldAccessible(Class> clazz, String... names)
public static void setFieldAccessible(Class<?> clazz, String... names)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Field; public class Main { public static void setFieldAccessible(Class<?> clazz, String... names) { try {// w w w. j a v a 2 s . c om Field field = getField(clazz, names); if (field != null) field.setAccessible(true); } catch (Exception e) { } } public static Field getField(Class<?> clazz, String... names) { try { Field[] fields = clazz.getDeclaredFields(); for (Field field : fields) { for (String fieldName : names) { if (field.getName().equalsIgnoreCase(fieldName)) { field.setAccessible(true); return field; } } } } catch (Exception e) { throw e; } return null; } }