11/*
2+ * Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation.
23 * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
34 *
45 * This program and the accompanying materials are made available under the
3839import jakarta .el .MethodExpression ;
3940import jakarta .el .MethodInfo ;
4041import jakarta .el .MethodNotFoundException ;
42+ import jakarta .el .MethodReference ;
4143import jakarta .el .PropertyNotFoundException ;
4244import jakarta .el .VariableMapper ;
4345
7779public final class MethodExpressionImpl extends MethodExpression implements Externalizable {
7880
7981 private Class <?> expectedType ;
80- private String expr ;
81- private FunctionMapper fnMapper ;
82- private VariableMapper varMapper ;
82+ private String expression ;
83+ private FunctionMapper functionMapper ;
84+ private VariableMapper variableMapper ;
8385 private Class <?>[] paramTypes ;
8486
8587 private transient Node node ;
@@ -98,10 +100,10 @@ public MethodExpressionImpl() {
98100 */
99101 public MethodExpressionImpl (String expr , Node node , FunctionMapper fnMapper , VariableMapper varMapper , Class <?> expectedType , Class <?>[] paramTypes ) {
100102 super ();
101- this .expr = expr ;
103+ this .expression = expr ;
102104 this .node = node ;
103- this .fnMapper = fnMapper ;
104- this .varMapper = varMapper ;
105+ this .functionMapper = fnMapper ;
106+ this .variableMapper = varMapper ;
105107 this .expectedType = expectedType ;
106108 this .paramTypes = paramTypes ;
107109 }
@@ -156,7 +158,7 @@ public boolean equals(Object obj) {
156158 */
157159 @ Override
158160 public String getExpressionString () {
159- return expr ;
161+ return expression ;
160162 }
161163
162164 /**
@@ -176,7 +178,16 @@ public String getExpressionString() {
176178 */
177179 @ Override
178180 public MethodInfo getMethodInfo (ELContext context ) throws PropertyNotFoundException , MethodNotFoundException , ELException {
179- return getNode ().getMethodInfo (new EvaluationContext (context , fnMapper , varMapper ), paramTypes );
181+ return getNode ().getMethodInfo (new EvaluationContext (context , functionMapper , variableMapper ), paramTypes );
182+ }
183+
184+ @ Override
185+ public MethodReference getMethodReference (ELContext context ) {
186+ EvaluationContext ctx = new EvaluationContext (context , functionMapper , variableMapper );
187+ ctx .notifyBeforeEvaluation (getExpressionString ());
188+ MethodReference methodReference = getNode ().getMethodReference (ctx );
189+ ctx .notifyAfterEvaluation (getExpressionString ());
190+ return methodReference ;
180191 }
181192
182193 /**
@@ -185,7 +196,7 @@ public MethodInfo getMethodInfo(ELContext context) throws PropertyNotFoundExcept
185196 */
186197 private Node getNode () throws ELException {
187198 if (node == null ) {
188- node = ExpressionBuilder .createNode (expr );
199+ node = ExpressionBuilder .createNode (expression );
189200 }
190201
191202 return node ;
@@ -231,12 +242,12 @@ public int hashCode() {
231242 */
232243 @ Override
233244 public Object invoke (ELContext context , Object [] params ) throws PropertyNotFoundException , MethodNotFoundException , ELException {
234- EvaluationContext ctx = new EvaluationContext (context , fnMapper , varMapper );
235- ctx .notifyBeforeEvaluation (expr );
245+ EvaluationContext ctx = new EvaluationContext (context , functionMapper , variableMapper );
246+ ctx .notifyBeforeEvaluation (expression );
236247
237248 Object obj = getNode ().invoke (ctx , paramTypes , params );
238249
239- ctx .notifyAfterEvaluation (expr );
250+ ctx .notifyAfterEvaluation (expression );
240251 return obj ;
241252 }
242253
@@ -247,30 +258,25 @@ public Object invoke(ELContext context, Object[] params) throws PropertyNotFound
247258 */
248259 @ Override
249260 public void readExternal (ObjectInput in ) throws IOException , ClassNotFoundException {
250- expr = in .readUTF ();
261+ expression = in .readUTF ();
251262 String type = in .readUTF ();
252263
253264 if (!"" .equals (type )) {
254265 expectedType = forName (type );
255266 }
256267
257268 paramTypes = toTypeArray (((String []) in .readObject ()));
258- fnMapper = (FunctionMapper ) in .readObject ();
259- varMapper = (VariableMapper ) in .readObject ();
269+ functionMapper = (FunctionMapper ) in .readObject ();
270+ variableMapper = (VariableMapper ) in .readObject ();
260271 }
261272
262- /*
263- * (non-Javadoc)
264- *
265- * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
266- */
267273 @ Override
268274 public void writeExternal (ObjectOutput out ) throws IOException {
269- out .writeUTF (expr );
275+ out .writeUTF (expression );
270276 out .writeUTF (expectedType != null ? expectedType .getName () : "" );
271277 out .writeObject (toTypeNameArray (paramTypes ));
272- out .writeObject (fnMapper );
273- out .writeObject (varMapper );
278+ out .writeObject (functionMapper );
279+ out .writeObject (variableMapper );
274280 }
275281
276282 @ Override
0 commit comments