标签:反射
public class Test {
private String readOnly;
public String getReadOnly() {
return readOnly;
}
public static void main(String[] args) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
Test t = new Test();
Field f = t.getClass().getDeclaredField("readOnly");
f.setAccessible(true);
f.set(t, "test");
System.out.println(t.getReadOnly());
}
}
标签:反射
原文:http://tianxingzhe.blog.51cto.com/3390077/1696222