Object (@NotNull Object receiver, @NotNull String methodName) { Object result = null; try { Method getMethod = receiver.getClass().getMethod(methodName); result = getMethod.invoke(receiver); } catch (NoSuchMethodException e) { Logging.getLogger(CppModelBuilder.class) .warn("Can not find `" + methodName + "` for receiver [" + receiver + "], gradle version " + GradleVersion.current() , e); } catch (IllegalAccessException | InvocationTargetException e) { Logging.getLogger(CppModelBuilder.class) .warn("Can not call `" + methodName + "` for receiver [" + receiver + "], gradle version " + GradleVersion.current(), e); } return result; }