Code example for InvocationTargetException

Methods: getCause, getMessage

0
			return method.invoke(obj, newValue);
		} catch (IllegalAccessException e) {
			throw new NoSuchMethodException(methodName + " is not accessible");
		} catch (InvocationTargetException e) {
			// The method is not supposed to throw exceptions 
			InternalError error = new InternalError(e.getMessage());
			error.initCause((e.getCause() != null) ? e.getCause() : e);
			throw error;
		} 
	} 
 
	/** 
	 * Invokes the specified setter method if it exists. 
	 * 
	 * @param obj		  The object on which to invoke the method. 
	 * @param methodName The name of the method. 
	 */ 
	public static void invokeIfExists(Object obj, String methodName) {
		try { 
			invoke(obj, methodName);
		} catch (NoSuchMethodException e) {