in src/main/java/org/apache/commons/jexl3/internal/Operator.java [512:551]
private Object tryEval(final JexlCache.Reference node, final JexlOperator operator, final Object...args) {
if (node != null) {
final Object cached = node.getCache();
if (cached instanceof JexlMethod) {
// we found a method on previous call; try and reuse it (*1)
final JexlMethod me = (JexlMethod) cached;
final Object eval = me.tryInvoke(operator.getMethodName(), arithmetic, args);
if (!me.tryFailed(eval)) {
return eval;
}
} else if (cached instanceof MethodKey) {
// check for a fail-fast, we tried to find an overload before but could not (*2)
final MethodKey cachedKey = (MethodKey) cached;
final MethodKey key = new MethodKey(operator.getMethodName(), args);
if (key.equals(cachedKey)) {
return JexlEngine.TRY_FAILED;
}
}
}
// trying to find an operator overload
JexlMethod vm = getOperator(operator, args);
// no direct overload, any special case ?
if (vm == null) {
vm = getAlternateOverload(operator, args);
}
// *1: found a method, try it and cache it if successful
if (vm != null) {
final Object result = vm.tryInvoke(operator.getMethodName(), arithmetic, args);
if (node != null && !vm.tryFailed(result)) {
node.setCache(vm);
}
return result;
}
if (node != null) {
// *2: could not find an overload for this operator and arguments, keep track of the fail
MethodKey key = new MethodKey(operator.getMethodName(), args);
node.setCache(key);
}
return JexlEngine.TRY_FAILED;
}