使字段可访问。
//package com.nowjava; /* from N o w J a v a . c o m*/ import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.security.AccessController; import java.security.PrivilegedAction; public class Main { /** * Make a field accessible. * * @param field the field */ public static void setAccessible(final Field field) { if (Modifier.isPublic(field.getModifiers())) { return; } AccessController.doPrivileged(new PrivilegedAction<Object>() { @Override public Object run()