ContainerUtils { public static void invokeMethod(Object targetBean, Method initMethod) { Class<?>[] paramArray = initMethod.getParameterTypes(); Object[] paramObject = BeanUtils.getDefaultValue(paramArray); try { try { initMethod.invoke(targetBean, paramObject); } catch (IllegalAccessException e) { initMethod.setAccessible(true); try { initMethod.invoke(targetBean, paramObject); } catch (IllegalAccessException e1) { logger.error(e1.getMessage(), e); } } } catch (InvocationTargetException e2) { throw ExceptionUtils.toRuntimeException(e2.getTargetException()); } }  static Method findInitMethod(Class<?> targetBeanType, BindInfo<?> bindInfo); static Method findDestroyMethod(Class<?> targetBeanType, BindInfo<?> bindInfo); static Class<T> findImplClass(final Class<?> notSureType); static Annotation findInject(boolean injectDefault, Annotation[] annotations); static boolean isInjectConstructor(Constructor<?> constructor); static Object injSettings(AppContext appContext, InjectSettings injectSettings, Class<?> toType); static void invokeMethod(Object targetBean, Method initMethod); static void invokeField(Field field, Object targetBean, Object newValue); static boolean testAopIgnore(Class<T> targetType, ClassLoader rootLoader);  }
@Test public void testInject7() throws NoSuchMethodException { NonePrivateCallInitBean initBean = new NonePrivateCallInitBean(); Method initMethod = NonePrivateCallInitBean.class.getDeclaredMethod("init"); assert !initBean.isInit(); ContainerUtils.invokeMethod(initBean, initMethod); assert initBean.isInit(); NonePrivateCallDestroyBean destroyBean = new NonePrivateCallDestroyBean(); Method destroyMethod = NonePrivateCallDestroyBean.class.getDeclaredMethod("destroy"); assert !destroyBean.isDestroy(); ContainerUtils.invokeMethod(destroyBean, destroyMethod); assert destroyBean.isDestroy(); }