Top Description Inners Fields Constructors Methods
org.springframework.expression.spel.ast

public Class MethodReference

extends SpelNodeImpl
Class Inheritance
Imports
java.lang.reflect.InvocationTargetException, .Method, .Modifier, .Proxy, java.util.ArrayList, .Collections, .List, .StringJoiner, org.springframework.asm.Label, .MethodVisitor, org.springframework.core.convert.TypeDescriptor, org.springframework.expression.AccessException, .EvaluationContext, .EvaluationException, .ExpressionInvocationTargetException, .MethodExecutor, .MethodResolver, .TypedValue, org.springframework.expression.spel.CodeFlow, .ExpressionState, .SpelEvaluationException, .SpelMessage, org.springframework.expression.spel.support.ReflectiveMethodExecutor, .ReflectiveMethodResolver, org.springframework.lang.Nullable, org.springframework.util.Assert, .ObjectUtils

Expression language AST node that represents a method reference.
Authors
Andy Clement, Juergen Hoeller, Sam Brannen
Since
3.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private class

Field Summary

Modifier and TypeField and Description
private volatile MethodReference.CachedMethodExecutor
private final String
private final boolean
private Character
Inherited from org.springframework.expression.spel.ast.SpelNodeImpl:
childrenexitTypeDescriptor

Constructor Summary

AccessConstructor and Description
public
MethodReference(boolean nullSafe, String methodName, int startPos, int endPos, SpelNodeImpl... arguments)

Method Summary

Modifier and TypeMethod and Description
private MethodExecutor
findAccessorForMethod(List<TypeDescriptor> argumentTypes, Object targetObject, EvaluationContext evaluationContext)

public void
generateCode(MethodVisitor
the ASM MethodVisitor into which code should be generated
mv
,
CodeFlow
a context object with info about what is on the stack
cf
)

Overrides org.springframework.expression.spel.ast.SpelNodeImpl.generateCode.

Generate the bytecode for this node into the supplied visitor.
private Object[]
private List<TypeDescriptor>
getArgumentTypes(Object... arguments)

private MethodExecutor
getCachedExecutor(EvaluationContext evaluationContext, Object value, TypeDescriptor target, List<TypeDescriptor> argumentTypes)

public final String
getName()

Get the name of the referenced method.

public TypedValue
private TypedValue
getValueInternal(EvaluationContext evaluationContext, Object value, TypeDescriptor targetType, Object[] arguments)

protected ValueRef
public boolean
isCompilable()

Overrides org.springframework.expression.spel.ast.SpelNodeImpl.isCompilable.

A method reference is compilable if it has been resolved to a reflectively accessible method and the child nodes (arguments to the method) are also compilable.
public final boolean
isNullSafe()

Does this node represent a null-safe method reference?

private void
private void
throwSimpleExceptionIfPossible(Object value, AccessException ex)

Decode the AccessException, throwing a lightweight evaluation exception or, if the cause was a RuntimeException, throw the RuntimeException directly.

public String
toStringAST()

Implements org.springframework.expression.spel.SpelNode.toStringAST.

Return the string form of this AST node.
private void
Inherited from org.springframework.expression.spel.ast.SpelNodeImpl:
generateCodeForArgumentgenerateCodeForArgumentsgetChildgetChildCountgetEndPositiongetExitDescriptorgetObjectClassgetStartPositiongetTypedValuegetValuegetValueisWritablenextChildIssetValuesetValueInternal

Field Detail

cachedExecutorback to summary
private volatile MethodReference.CachedMethodExecutor cachedExecutor
Annotations
@Nullable
nameback to summary
private final String name
nullSafeback to summary
private final boolean nullSafe
originalPrimitiveExitTypeDescriptorback to summary
private Character originalPrimitiveExitTypeDescriptor
Annotations
@Nullable

Constructor Detail

MethodReferenceback to summary
public MethodReference(boolean nullSafe, String methodName, int startPos, int endPos, SpelNodeImpl... arguments)

Method Detail

findAccessorForMethodback to summary
private MethodExecutor findAccessorForMethod(List<TypeDescriptor> argumentTypes, Object targetObject, EvaluationContext evaluationContext) throws SpelEvaluationException
generateCodeback to summary
public void generateCode(MethodVisitor mv, CodeFlow cf)

Overrides org.springframework.expression.spel.ast.SpelNodeImpl.generateCode.

Doc from org.springframework.expression.spel.ast.SpelNodeImpl.generateCode.

Generate the bytecode for this node into the supplied visitor. Context info about the current expression being compiled is available in the codeflow object, e.g. including information about the type of the object currently on the stack.

Parameters
mv:MethodVisitor

the ASM MethodVisitor into which code should be generated

cf:CodeFlow

a context object with info about what is on the stack

Annotations
@Override
getArgumentsback to summary
private Object[] getArguments(ExpressionState state)
getArgumentTypesback to summary
private List<TypeDescriptor> getArgumentTypes(Object... arguments)
getCachedExecutorback to summary
private MethodExecutor getCachedExecutor(EvaluationContext evaluationContext, Object value, TypeDescriptor target, List<TypeDescriptor> argumentTypes)
Annotations
@Nullable
getNameback to summary
public final String getName()

Get the name of the referenced method.

getValueInternalback to summary
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException

Implements abstract org.springframework.expression.spel.ast.SpelNodeImpl.getValueInternal.

Annotations
@Override
getValueInternalback to summary
private TypedValue getValueInternal(EvaluationContext evaluationContext, Object value, TypeDescriptor targetType, Object[] arguments)
getValueRefback to summary
protected ValueRef getValueRef(ExpressionState state) throws EvaluationException

Overrides org.springframework.expression.spel.ast.SpelNodeImpl.getValueRef.

Annotations
@Override
isCompilableback to summary
public boolean isCompilable()

Overrides org.springframework.expression.spel.ast.SpelNodeImpl.isCompilable.

A method reference is compilable if it has been resolved to a reflectively accessible method and the child nodes (arguments to the method) are also compilable.

Returns:boolean

Doc from org.springframework.expression.spel.ast.SpelNodeImpl.isCompilable.

true if this node can be compiled to bytecode

Annotations
@Override
isNullSafeback to summary
public final boolean isNullSafe()

Does this node represent a null-safe method reference?

Since
6.0.13
throwIfNotNullSafeback to summary
private void throwIfNotNullSafe(List<TypeDescriptor> argumentTypes)
throwSimpleExceptionIfPossibleback to summary
private void throwSimpleExceptionIfPossible(Object value, AccessException ex)

Decode the AccessException, throwing a lightweight evaluation exception or, if the cause was a RuntimeException, throw the RuntimeException directly.

toStringASTback to summary
public String toStringAST()

Implements org.springframework.expression.spel.SpelNode.toStringAST.

Doc from org.springframework.expression.spel.SpelNode.toStringAST.

Return the string form of this AST node.

Returns:String

the string form

Annotations
@Override
updateExitTypeDescriptorback to summary
private void updateExitTypeDescriptor()
org.springframework.expression.spel.ast back to summary

private Class MethodReference.CachedMethodExecutor

extends Object
Class Inheritance
  • java.lang.Object
  • org.springframework.expression.spel.ast.MethodReference.CachedMethodExecutor

Field Summary

Modifier and TypeField and Description
private final List<TypeDescriptor>
private final MethodExecutor
private final Class<?>
private final TypeDescriptor

Constructor Summary

AccessConstructor and Description
public
CachedMethodExecutor(MethodExecutor methodExecutor, Class<?> staticClass, TypeDescriptor target, List<TypeDescriptor> argumentTypes)

Method Summary

Modifier and TypeMethod and Description
public MethodExecutor
get()

public boolean
public boolean
isSuitable(Object value, TypeDescriptor target, List<TypeDescriptor> argumentTypes)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

argumentTypesback to summary
private final List<TypeDescriptor> argumentTypes
methodExecutorback to summary
private final MethodExecutor methodExecutor
staticClassback to summary
private final Class<?> staticClass
Annotations
@Nullable
targetback to summary
private final TypeDescriptor target
Annotations
@Nullable

Constructor Detail

CachedMethodExecutorback to summary
public CachedMethodExecutor(MethodExecutor methodExecutor, Class<?> staticClass, TypeDescriptor target, List<TypeDescriptor> argumentTypes)

Method Detail

getback to summary
public MethodExecutor get()
hasProxyTargetback to summary
public boolean hasProxyTarget()
isSuitableback to summary
public boolean isSuitable(Object value, TypeDescriptor target, List<TypeDescriptor> argumentTypes)
org.springframework.expression.spel.ast back to summary

private Class MethodReference.MethodValueRef

extends Object
implements ValueRef
Class Inheritance
  • java.lang.Object
  • org.springframework.expression.spel.ast.MethodReference.MethodValueRef
All Implemented Interfaces
org.springframework.expression.spel.ast.ValueRef

Field Summary

Modifier and TypeField and Description
private final Object[]
private final EvaluationContext
private final TypeDescriptor
private final Object

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public TypedValue
getValue()

Implements org.springframework.expression.spel.ast.ValueRef.getValue.

Returns the value this ValueRef points to, it should not require expression component re-evaluation.
public boolean
isWritable()

Implements org.springframework.expression.spel.ast.ValueRef.isWritable.

Indicates whether calling setValue(Object) is supported.
public void
setValue(Object
the new value
newValue
)

Implements org.springframework.expression.spel.ast.ValueRef.setValue.

Sets the value this ValueRef points to, it should not require expression component re-evaluation.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

argumentsback to summary
private final Object[] arguments
evaluationContextback to summary
private final EvaluationContext evaluationContext
targetTypeback to summary
private final TypeDescriptor targetType
Annotations
@Nullable
valueback to summary
private final Object value
Annotations
@Nullable

Constructor Detail

MethodValueRefback to summary
public MethodValueRef(ExpressionState state, Object[] arguments)

Method Detail

getValueback to summary
public TypedValue getValue()

Implements org.springframework.expression.spel.ast.ValueRef.getValue.

Doc from org.springframework.expression.spel.ast.ValueRef.getValue.

Returns the value this ValueRef points to, it should not require expression component re-evaluation.

Returns:TypedValue

the value

Annotations
@Override
isWritableback to summary
public boolean isWritable()

Implements org.springframework.expression.spel.ast.ValueRef.isWritable.

Doc from org.springframework.expression.spel.ast.ValueRef.isWritable.

Indicates whether calling setValue(Object) is supported.

Returns:boolean

true if setValue() is supported for this value reference.

Annotations
@Override
setValueback to summary
public void setValue(Object newValue)

Implements org.springframework.expression.spel.ast.ValueRef.setValue.

Doc from org.springframework.expression.spel.ast.ValueRef.setValue.

Sets the value this ValueRef points to, it should not require expression component re-evaluation.

Parameters
newValue:Object

the new value

Annotations
@Override