diff --git a/spring-expression/src/main/java/org/springframework/expression/EvaluationContext.java b/spring-expression/src/main/java/org/springframework/expression/EvaluationContext.java index 2746352d1a..1d091efa87 100644 --- a/spring-expression/src/main/java/org/springframework/expression/EvaluationContext.java +++ b/spring-expression/src/main/java/org/springframework/expression/EvaluationContext.java @@ -47,15 +47,18 @@ public interface EvaluationContext { /** * Return the default root context object against which unqualified - * properties/methods/etc should be resolved. This can be overridden - * when evaluating an expression. + * properties, methods, etc. should be resolved. + *

This can be overridden when evaluating an expression. */ TypedValue getRootObject(); /** * Return a list of accessors that will be asked in turn to read/write a property. + *

The default implementation returns an empty list. */ - List getPropertyAccessors(); + default List getPropertyAccessors() { + return Collections.emptyList(); + } /** * Return a list of index accessors that will be asked in turn to access or @@ -69,13 +72,19 @@ public interface EvaluationContext { /** * Return a list of resolvers that will be asked in turn to locate a constructor. + *

The default implementation returns an empty list. */ - List getConstructorResolvers(); + default List getConstructorResolvers() { + return Collections.emptyList(); + } /** * Return a list of resolvers that will be asked in turn to locate a method. + *

The default implementation returns an empty list. */ - List getMethodResolvers(); + default List getMethodResolvers() { + return Collections.emptyList(); + } /** * Return a bean resolver that can look up beans by name. diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/support/SimpleEvaluationContext.java b/spring-expression/src/main/java/org/springframework/expression/spel/support/SimpleEvaluationContext.java index f8cd8a1cce..8e0147248f 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/support/SimpleEvaluationContext.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/support/SimpleEvaluationContext.java @@ -26,7 +26,6 @@ import java.util.function.Supplier; import org.springframework.core.convert.ConversionService; import org.springframework.core.convert.TypeDescriptor; import org.springframework.expression.BeanResolver; -import org.springframework.expression.ConstructorResolver; import org.springframework.expression.EvaluationContext; import org.springframework.expression.MethodResolver; import org.springframework.expression.OperatorOverloader; @@ -146,15 +145,6 @@ public final class SimpleEvaluationContext implements EvaluationContext { return this.propertyAccessors; } - /** - * Return an empty list, always, since this context does not support the - * use of type references. - */ - @Override - public List getConstructorResolvers() { - return Collections.emptyList(); - } - /** * Return the specified {@link MethodResolver} delegates, if any. * @see Builder#withMethodResolvers