ReflectionException
32333435363738394041
field.setAccessible(true); @SuppressWarnings("unchecked") T returnValue = (T) field.get(target); return returnValue; } catch (NoSuchFieldException e) { throw new ReflectionException(e); } catch (IllegalAccessException e) { throw new ReflectionException(e); } }
50515253545556575859
try { Field field = target.getClass().getDeclaredField(fieldName); field.setAccessible(true); field.set(target, value); } catch (NoSuchFieldException e) { throw new ReflectionException(e); } catch (IllegalAccessException e) { throw new ReflectionException(e); } }
6768697071727374
*/ public static Method getMethod(Object target, String methodName, Class... parameterTypes) { try { return target.getClass().getMethod(methodName, parameterTypes); } catch (NoSuchMethodException e) { throw new ReflectionException(e); } }
83848586878889909192
try { @SuppressWarnings("unchecked") T returnValue = (T) method.invoke(target, parameters); return returnValue; } catch (InvocationTargetException e) { throw new ReflectionException(e); } catch (IllegalAccessException e) { throw new ReflectionException(e); } }