@Override protected void clearError() { for (PrintStream stream : delegates) { try { GroovyRuntimeUtil.invokeMethod(stream, "clearError"); } catch (MissingMethodException e) { // method doesn't exist in JDK 1.5 if (!"clearError".equals(e.getMethod())) { throw e; } } } }
public static void verifyMethodCondition(@Nullable ErrorCollector errorCollector, @Nullable ValueRecorder recorder, @Nullable String text, int line, int column, @Nullable Object message, Object target, String method, Object[] args, boolean safe, boolean explicit, int lastVariableNum) { MatcherCondition matcherCondition = MatcherCondition.parse(target, method, args, safe); if (matcherCondition != null) { matcherCondition.verify(errorCollector, getValues(recorder), text, line, column, messageToString(message)); return; } if (recorder != null) { recorder.startRecordingValue(lastVariableNum); } Object result = safe ? GroovyRuntimeUtil.invokeMethodNullSafe(target, method, args) : GroovyRuntimeUtil.invokeMethod(target, method, args); if (!explicit && result == null && isVoidMethod(target, method, args)) return; if (!GroovyRuntimeUtil.isTruthy(result)) { List<Object> values = getValues(recorder); if (values != null) CollectionUtil.setLastElement(values, result); final ConditionNotSatisfiedError conditionNotSatisfiedError = new ConditionNotSatisfiedError( new Condition(values, text, TextPosition.create(line, column), messageToString(message), null, null)); errorCollector.collectOrThrow(conditionNotSatisfiedError); } }
@Override public Object invokeMethod(String name, Object args) { try { return GroovyRuntimeUtil.invokeMethod($delegate, name, GroovyRuntimeUtil.asArgumentArray(args)); } catch (MissingMethodException e) { return super.invokeMethod(name, args); } } }
String currPart = exprParts[i]; if (currPart.endsWith("()")) { result = GroovyRuntimeUtil.invokeMethod(result, currPart.substring(0, currPart.length() - 2)); } else { result = GroovyRuntimeUtil.getProperty(result, currPart);
@Override public void intercept(IMethodInvocation invocation) throws Throwable { List<Throwable> exceptions = new ArrayList<>(); try { invocation.proceed(); } catch (Throwable t) { exceptions.add(t); } for (FieldInfo field : fields) { AutoCleanup annotation = field.getAnnotation(AutoCleanup.class); try { Object value = field.readValue(invocation.getInstance()); if (value == null) continue; GroovyRuntimeUtil.invokeMethod(value, annotation.value()); } catch (Throwable t) { if (!annotation.quiet()) exceptions.add(t); } } ExtensionUtil.throwAll(exceptions); } }
@Override public Object invokeMethod(String name, Object args) { Object thisObject = $gestalt.getBlueprint().getThisObject(); if (thisObject != null) { try { return GroovyRuntimeUtil.invokeMethod(thisObject, name, GroovyRuntimeUtil.asArgumentArray(args)); } catch (MissingMethodException ignored) {} } return $gestalt.invokeMethod(name, GroovyRuntimeUtil.asArgumentArray(args)); } }
return GroovyRuntimeUtil.invokeMethod(target, methodName, GroovyRuntimeUtil.asArgumentArray(normalizedArgs[1]));
return GroovyRuntimeUtil.invokeMethod(target, (String) normalizedArgs[0], GroovyRuntimeUtil.asArgumentArray(normalizedArgs[1])); return GroovyRuntimeUtil.invokeMethod(target, methodName); return GroovyRuntimeUtil.invokeMethod(target, methodName, normalizedArgs[1]);