设置私人决赛场
//package com.nowjava; /** from n o w j a v a . c o m**/ import java.lang.reflect.Field; import java.lang.reflect.Modifier; public class Main { public static boolean setPrivateFinalField(Class clazz, String fieldName, Object instance, Object value) { try { Field field = clazz.getDeclaredField(fieldName); field.setAccessible(true); Field modifiersField = Field.class .getDeclaredField("modifiers"); modifiersField.setAccessible(true); modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); field.set(instance, value);/** N o w J a v a . c o m 提供 **/ return true; } catch (NoSuchFieldException e)