public static <T, R> R callGetter(Method getterMethod, T obj, Class<R> expectedType)
			throws IOException {
		try {
			Object getterValue = getterMethod.invoke(obj);
			if (getterValue == null || expectedType.isInstance(getterValue)) {
				return expectedType.cast(getterValue);
			}
			return null;
		}
		catch (IllegalAccessException | InvocationTargetException e) {
			throw new IOException(e);
		}
	}
Creates an instance of the specified target class, using an optional context parameter
to the constructor.

@param <T> type of the class to be created
@param <CTX> type of the context to be passed to the constructor
@param targetClass class to be created
@param optionalContext anything, or null
@return new instance of type T
@throws IllegalArgumentException if error creating instance
Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/golang/structmapping/ReflectionHelper.java