public static void main(String[] args) throws Exception{
TbIntVsopExceptionLog log = new TbIntVsopExceptionLog();
//字段处理
Field f = TbIntVsopExceptionLog.class.getDeclaredField("exception_log_id");
f.setAccessible(true);
f.set(log, new Long(12));
System.out.println(log.getException_log_id());//12
System.out.println(log.getException_position());//null
//方法处理
Method setMethod = (Method) TbIntVsopExceptionLog.class
.getMethod("setException_log_id", new Class[] {Long.class});
setMethod.invoke(log, new Object[] {new Long(100)});
Method getMethod = (Method) TbIntVsopExceptionLog.class
.getMethod("getException_log_id", new Class[] {});
Long l = (Long)getMethod.invoke(log, new Object[] {});
System.out.println(log.getException_position());//null
System.out.println(l);//100
}
java 反射
最新推荐文章于 2025-03-26 20:25:07 发布