Evaluator (final Evaluator primary, final Evaluator fallback) { return new Evaluator() { private boolean myIsFallback; @Override public Object evaluate(EvaluationContextImpl context) throws EvaluateException { try { return primary.evaluate(context); } catch (EvaluateException e) { try { Object res = fallback.evaluate(context); myIsFallback = true; return res; } catch (EvaluateException e1) { throw e; } } } @Override public Modifier getModifier() { return myIsFallback ? fallback.getModifier() : primary.getModifier(); } }; }