关于java反射的安全问题
public class User { private String name; public User() { }} protected final void injectField(Object source, String fieldName, Object fieldValue) { try { Field field = source.getClass().getDeclaredField(fieldName); field.setAccessible(true); field.set(source, fieldValue); } catch (Exception e) { throw new IllegalStateException(e); } }