This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit bc85743c1e15bb536c593ac43b634357731b3ea9 Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri Aug 9 15:23:43 2024 +0100 Code clean-up - formatting. No functional change. --- java/org/apache/el/ExpressionFactoryImpl.java | 20 +- java/org/apache/el/MethodExpressionImpl.java | 212 ++++++++------------ java/org/apache/el/MethodExpressionLiteral.java | 9 +- java/org/apache/el/ValueExpressionImpl.java | 105 ++++------ java/org/apache/el/ValueExpressionLiteral.java | 19 +- java/org/apache/el/lang/ELArithmetic.java | 20 +- java/org/apache/el/lang/ELSupport.java | 217 +++++++++------------ java/org/apache/el/lang/EvaluationContext.java | 15 +- java/org/apache/el/lang/ExpressionBuilder.java | 65 +++--- java/org/apache/el/lang/FunctionMapperImpl.java | 13 +- .../el/lang/LambdaExpressionNestedState.java | 13 +- java/org/apache/el/lang/VariableMapperImpl.java | 10 +- java/org/apache/el/parser/ArithmeticNode.java | 3 +- java/org/apache/el/parser/AstAnd.java | 3 +- java/org/apache/el/parser/AstBracketSuffix.java | 3 +- java/org/apache/el/parser/AstChoice.java | 6 +- .../apache/el/parser/AstCompositeExpression.java | 6 +- .../apache/el/parser/AstDeferredExpression.java | 12 +- java/org/apache/el/parser/AstDiv.java | 3 +- java/org/apache/el/parser/AstDotSuffix.java | 6 +- .../org/apache/el/parser/AstDynamicExpression.java | 12 +- java/org/apache/el/parser/AstEmpty.java | 6 +- java/org/apache/el/parser/AstEqual.java | 3 +- java/org/apache/el/parser/AstFalse.java | 3 +- java/org/apache/el/parser/AstFloatingPoint.java | 6 +- java/org/apache/el/parser/AstFunction.java | 3 +- java/org/apache/el/parser/AstGreaterThan.java | 3 +- java/org/apache/el/parser/AstGreaterThanEqual.java | 3 +- java/org/apache/el/parser/AstIdentifier.java | 44 ++--- java/org/apache/el/parser/AstInteger.java | 6 +- java/org/apache/el/parser/AstLambdaExpression.java | 31 ++- java/org/apache/el/parser/AstLessThan.java | 3 +- java/org/apache/el/parser/AstLessThanEqual.java | 3 +- .../org/apache/el/parser/AstLiteralExpression.java | 2 +- java/org/apache/el/parser/AstMapEntry.java | 9 +- java/org/apache/el/parser/AstMinus.java | 3 +- java/org/apache/el/parser/AstMod.java | 3 +- java/org/apache/el/parser/AstMult.java | 3 +- java/org/apache/el/parser/AstNegative.java | 6 +- java/org/apache/el/parser/AstNot.java | 6 +- java/org/apache/el/parser/AstNotEqual.java | 3 +- java/org/apache/el/parser/AstNull.java | 6 +- java/org/apache/el/parser/AstOr.java | 3 +- java/org/apache/el/parser/AstPlus.java | 3 +- java/org/apache/el/parser/AstString.java | 6 +- java/org/apache/el/parser/AstTrue.java | 3 +- java/org/apache/el/parser/AstValue.java | 102 ++++------ java/org/apache/el/parser/BooleanNode.java | 3 +- java/org/apache/el/stream/Stream.java | 26 +-- .../org/apache/el/stream/StreamELResolverImpl.java | 9 +- java/org/apache/el/util/ConcurrentCache.java | 2 +- java/org/apache/el/util/ExceptionUtils.java | 11 +- java/org/apache/el/util/ReflectionUtil.java | 146 +++++++------- java/org/apache/el/util/Validation.java | 31 ++- 54 files changed, 500 insertions(+), 772 deletions(-) diff --git a/java/org/apache/el/ExpressionFactoryImpl.java b/java/org/apache/el/ExpressionFactoryImpl.java index 82f5cf123b..4a13adb591 100644 --- a/java/org/apache/el/ExpressionFactoryImpl.java +++ b/java/org/apache/el/ExpressionFactoryImpl.java @@ -34,7 +34,7 @@ import org.apache.el.util.MessageFactory; * * @author Jacob Hookom [ja...@hookom.net] */ -@aQute.bnd.annotation.spi.ServiceProvider(value=ExpressionFactory.class) +@aQute.bnd.annotation.spi.ServiceProvider(value = ExpressionFactory.class) public class ExpressionFactoryImpl extends ExpressionFactory { static { @@ -47,31 +47,25 @@ public class ExpressionFactoryImpl extends ExpressionFactory { } @Override - public MethodExpression createMethodExpression(ELContext context, - String expression, Class<?> expectedReturnType, + public MethodExpression createMethodExpression(ELContext context, String expression, Class<?> expectedReturnType, Class<?>[] expectedParamTypes) { ExpressionBuilder builder = new ExpressionBuilder(expression, context); - return builder.createMethodExpression(expectedReturnType, - expectedParamTypes); + return builder.createMethodExpression(expectedReturnType, expectedParamTypes); } @Override - public ValueExpression createValueExpression(ELContext context, - String expression, Class<?> expectedType) { + public ValueExpression createValueExpression(ELContext context, String expression, Class<?> expectedType) { if (expectedType == null) { - throw new NullPointerException(MessageFactory - .get("error.value.expectedType")); + throw new NullPointerException(MessageFactory.get("error.value.expectedType")); } ExpressionBuilder builder = new ExpressionBuilder(expression, context); return builder.createValueExpression(expectedType); } @Override - public ValueExpression createValueExpression(Object instance, - Class<?> expectedType) { + public ValueExpression createValueExpression(Object instance, Class<?> expectedType) { if (expectedType == null) { - throw new NullPointerException(MessageFactory - .get("error.value.expectedType")); + throw new NullPointerException(MessageFactory.get("error.value.expectedType")); } return new ValueExpressionLiteral(instance, expectedType); } diff --git a/java/org/apache/el/MethodExpressionImpl.java b/java/org/apache/el/MethodExpressionImpl.java index 5981465348..c9174d5796 100644 --- a/java/org/apache/el/MethodExpressionImpl.java +++ b/java/org/apache/el/MethodExpressionImpl.java @@ -39,32 +39,25 @@ import org.apache.el.util.ReflectionUtil; /** * An <code>Expression</code> that refers to a method on an object. - * * <p> - * The {@link jakarta.el.ExpressionFactory#createMethodExpression} method - * can be used to parse an expression string and return a concrete instance - * of <code>MethodExpression</code> that encapsulates the parsed expression. - * The {@link FunctionMapper} is used at parse time, not evaluation time, - * so one is not needed to evaluate an expression using this class. - * However, the {@link ELContext} is needed at evaluation time.</p> - * - * <p>The {@link #getMethodInfo} and {@link #invoke} methods will evaluate the - * expression each time they are called. The {@link jakarta.el.ELResolver} in the - * <code>ELContext</code> is used to resolve the top-level variables and to - * determine the behavior of the <code>.</code> and <code>[]</code> - * operators. For any of the two methods, the - * {@link jakarta.el.ELResolver#getValue} method is used to resolve all properties - * up to but excluding the last one. This provides the <code>base</code> object - * on which the method appears. If the <code>base</code> object is null, a - * <code>NullPointerException</code> must be thrown. At the last resolution, - * the final <code>property</code> is then coerced to a <code>String</code>, - * which provides the name of the method to be found. A method matching the - * name and expected parameters provided at parse time is found and it is - * either queried or invoked (depending on the method called on this - * <code>MethodExpression</code>).</p> - * - * <p>See the notes about comparison, serialization and immutability in - * the {@link jakarta.el.Expression} javadocs. + * The {@link jakarta.el.ExpressionFactory#createMethodExpression} method can be used to parse an expression string and + * return a concrete instance of <code>MethodExpression</code> that encapsulates the parsed expression. The + * {@link FunctionMapper} is used at parse time, not evaluation time, so one is not needed to evaluate an expression + * using this class. However, the {@link ELContext} is needed at evaluation time. + * </p> + * <p> + * The {@link #getMethodInfo} and {@link #invoke} methods will evaluate the expression each time they are called. The + * {@link jakarta.el.ELResolver} in the <code>ELContext</code> is used to resolve the top-level variables and to + * determine the behavior of the <code>.</code> and <code>[]</code> operators. For any of the two methods, the + * {@link jakarta.el.ELResolver#getValue} method is used to resolve all properties up to but excluding the last one. + * This provides the <code>base</code> object on which the method appears. If the <code>base</code> object is null, a + * <code>NullPointerException</code> must be thrown. At the last resolution, the final <code>property</code> is then + * coerced to a <code>String</code>, which provides the name of the method to be found. A method matching the name and + * expected parameters provided at parse time is found and it is either queried or invoked (depending on the method + * called on this <code>MethodExpression</code>). + * </p> + * <p> + * See the notes about comparison, serialization and immutability in the {@link jakarta.el.Expression} javadocs. * * @see jakarta.el.ELResolver * @see jakarta.el.Expression @@ -73,8 +66,7 @@ import org.apache.el.util.ReflectionUtil; * * @author Jacob Hookom [ja...@hookom.net] */ -public final class MethodExpressionImpl extends MethodExpression implements - Externalizable { +public final class MethodExpressionImpl extends MethodExpression implements Externalizable { private Class<?> expectedType; @@ -92,8 +84,7 @@ public final class MethodExpressionImpl extends MethodExpression implements super(); } - public MethodExpressionImpl(String expr, Node node, - FunctionMapper fnMapper, VariableMapper varMapper, + public MethodExpressionImpl(String expr, Node node, FunctionMapper fnMapper, VariableMapper varMapper, Class<?> expectedType, Class<?>[] paramTypes) { super(); this.expr = expr; @@ -105,53 +96,40 @@ public final class MethodExpressionImpl extends MethodExpression implements } /** - * Determines whether the specified object is equal to this - * <code>Expression</code>. - * + * Determines whether the specified object is equal to this <code>Expression</code>. * <p> - * The result is <code>true</code> if and only if the argument is not - * <code>null</code>, is an <code>Expression</code> object that is the - * of the same type (<code>ValueExpression</code> or - * <code>MethodExpression</code>), and has an identical parsed - * representation. + * The result is <code>true</code> if and only if the argument is not <code>null</code>, is an + * <code>Expression</code> object that is the of the same type (<code>ValueExpression</code> or + * <code>MethodExpression</code>), and has an identical parsed representation. * </p> - * * <p> - * Note that two expressions can be equal if their expression Strings are - * different. For example, <code>${fn1:foo()}</code> and - * <code>${fn2:foo()}</code> are equal if their corresponding - * <code>FunctionMapper</code>s mapped <code>fn1:foo</code> and - * <code>fn2:foo</code> to the same method. + * Note that two expressions can be equal if their expression Strings are different. For example, + * <code>${fn1:foo()}</code> and <code>${fn2:foo()}</code> are equal if their corresponding + * <code>FunctionMapper</code>s mapped <code>fn1:foo</code> and <code>fn2:foo</code> to the same method. * </p> * - * @param obj - * the <code>Object</code> to test for equality. - * @return <code>true</code> if <code>obj</code> equals this - * <code>Expression</code>; <code>false</code> otherwise. + * @param obj the <code>Object</code> to test for equality. + * + * @return <code>true</code> if <code>obj</code> equals this <code>Expression</code>; <code>false</code> otherwise. + * * @see java.util.Hashtable * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { - return (obj instanceof MethodExpressionImpl && obj.hashCode() == this - .hashCode()); + return (obj instanceof MethodExpressionImpl && obj.hashCode() == this.hashCode()); } /** - * Returns the original String used to create this <code>Expression</code>, - * unmodified. - * + * Returns the original String used to create this <code>Expression</code>, unmodified. * <p> - * This is used for debugging purposes but also for the purposes of - * comparison (e.g. to ensure the expression in a configuration file has not - * changed). + * This is used for debugging purposes but also for the purposes of comparison (e.g. to ensure the expression in a + * configuration file has not changed). * </p> - * * <p> - * This method does not provide sufficient information to re-create an - * expression. Two different expressions can have exactly the same - * expression string but different function mappings. Serialization should - * be used to save and restore the state of an <code>Expression</code>. + * This method does not provide sufficient information to re-create an expression. Two different expressions can + * have exactly the same expression string but different function mappings. Serialization should be used to save and + * restore the state of an <code>Expression</code>. * </p> * * @return The original expression String. @@ -164,34 +142,30 @@ public final class MethodExpressionImpl extends MethodExpression implements } /** - * Evaluates the expression relative to the provided context, and returns - * information about the actual referenced method. + * Evaluates the expression relative to the provided context, and returns information about the actual referenced + * method. + * + * @param context The context of this evaluation + * + * @return an instance of <code>MethodInfo</code> containing information about the method the expression evaluated + * to. + * + * @throws NullPointerException if context is <code>null</code> or the base object is <code>null</code> on the + * last resolution. + * @throws PropertyNotFoundException if one of the property resolutions failed because a specified variable or + * property does not exist or is not readable. + * @throws MethodNotFoundException if no suitable method can be found. + * @throws ELException if an exception was thrown while performing property or variable resolution. + * The thrown exception must be included as the cause property of this + * exception, if available. * - * @param context - * The context of this evaluation - * @return an instance of <code>MethodInfo</code> containing information - * about the method the expression evaluated to. - * @throws NullPointerException - * if context is <code>null</code> or the base object is - * <code>null</code> on the last resolution. - * @throws PropertyNotFoundException - * if one of the property resolutions failed because a specified - * variable or property does not exist or is not readable. - * @throws MethodNotFoundException - * if no suitable method can be found. - * @throws ELException - * if an exception was thrown while performing property or - * variable resolution. The thrown exception must be included as - * the cause property of this exception, if available. * @see jakarta.el.MethodExpression#getMethodInfo(jakarta.el.ELContext) */ @Override public MethodInfo getMethodInfo(ELContext context) - throws PropertyNotFoundException, MethodNotFoundException, - ELException { + throws PropertyNotFoundException, MethodNotFoundException, ELException { Node n = this.getNode(); - EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, - this.varMapper); + EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, this.varMapper); ctx.notifyBeforeEvaluation(getExpressionString()); MethodInfo result = n.getMethodInfo(ctx, this.paramTypes); ctx.notifyAfterEvaluation(getExpressionString()); @@ -207,17 +181,15 @@ public final class MethodExpressionImpl extends MethodExpression implements /** * Returns the hash code for this <code>Expression</code>. - * * <p> - * See the note in the {@link #equals} method on how two expressions can be - * equal if their expression Strings are different. Recall that if two - * objects are equal according to the <code>equals(Object)</code> method, - * then calling the <code>hashCode</code> method on each of the two - * objects must produce the same integer result. Implementations must take - * special note and implement <code>hashCode</code> correctly. + * See the note in the {@link #equals} method on how two expressions can be equal if their expression Strings are + * different. Recall that if two objects are equal according to the <code>equals(Object)</code> method, then calling + * the <code>hashCode</code> method on each of the two objects must produce the same integer result. Implementations + * must take special note and implement <code>hashCode</code> correctly. * </p> * * @return The hash code for this <code>Expression</code>. + * * @see #equals * @see java.util.Hashtable * @see java.lang.Object#hashCode() @@ -228,41 +200,32 @@ public final class MethodExpressionImpl extends MethodExpression implements } /** - * Evaluates the expression relative to the provided context, invokes the - * method that was found using the supplied parameters, and returns the - * result of the method invocation. + * Evaluates the expression relative to the provided context, invokes the method that was found using the supplied + * parameters, and returns the result of the method invocation. + * + * @param context The context of this evaluation. + * @param params The parameters to pass to the method, or <code>null</code> if no parameters. + * + * @return the result of the method invocation (<code>null</code> if the method has a <code>void</code> return + * type). * - * @param context - * The context of this evaluation. - * @param params - * The parameters to pass to the method, or <code>null</code> - * if no parameters. - * @return the result of the method invocation (<code>null</code> if the - * method has a <code>void</code> return type). - * @throws NullPointerException - * if context is <code>null</code> or the base object is - * <code>null</code> on the last resolution. - * @throws PropertyNotFoundException - * if one of the property resolutions failed because a specified - * variable or property does not exist or is not readable. - * @throws MethodNotFoundException - * if no suitable method can be found. - * @throws ELException - * if an exception was thrown while performing property or - * variable resolution. The thrown exception must be included as - * the cause property of this exception, if available. If the - * exception thrown is an <code>InvocationTargetException</code>, - * extract its <code>cause</code> and pass it to the - * <code>ELException</code> constructor. - * @see jakarta.el.MethodExpression#invoke(jakarta.el.ELContext, - * java.lang.Object[]) + * @throws NullPointerException if context is <code>null</code> or the base object is <code>null</code> on the + * last resolution. + * @throws PropertyNotFoundException if one of the property resolutions failed because a specified variable or + * property does not exist or is not readable. + * @throws MethodNotFoundException if no suitable method can be found. + * @throws ELException if an exception was thrown while performing property or variable resolution. + * The thrown exception must be included as the cause property of this + * exception, if available. If the exception thrown is an + * <code>InvocationTargetException</code>, extract its <code>cause</code> and + * pass it to the <code>ELException</code> constructor. + * + * @see jakarta.el.MethodExpression#invoke(jakarta.el.ELContext, java.lang.Object[]) */ @Override public Object invoke(ELContext context, Object[] params) - throws PropertyNotFoundException, MethodNotFoundException, - ELException { - EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, - this.varMapper); + throws PropertyNotFoundException, MethodNotFoundException, ELException { + EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, this.varMapper); ctx.notifyBeforeEvaluation(getExpressionString()); Object result = this.getNode().invoke(ctx, this.paramTypes, params); ctx.notifyAfterEvaluation(getExpressionString()); @@ -270,15 +233,13 @@ public final class MethodExpressionImpl extends MethodExpression implements } @Override - public void readExternal(ObjectInput in) throws IOException, - ClassNotFoundException { + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { this.expr = in.readUTF(); String type = in.readUTF(); if (!type.isEmpty()) { this.expectedType = ReflectionUtil.forName(type); } - this.paramTypes = ReflectionUtil.toTypeArray(((String[]) in - .readObject())); + this.paramTypes = ReflectionUtil.toTypeArray(((String[]) in.readObject())); this.fnMapper = (FunctionMapper) in.readObject(); this.varMapper = (VariableMapper) in.readObject(); } @@ -286,8 +247,7 @@ public final class MethodExpressionImpl extends MethodExpression implements @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeUTF(this.expr); - out.writeUTF((this.expectedType != null) ? this.expectedType.getName() - : ""); + out.writeUTF((this.expectedType != null) ? this.expectedType.getName() : ""); out.writeObject(ReflectionUtil.toTypeNameArray(this.paramTypes)); out.writeObject(this.fnMapper); out.writeObject(this.varMapper); diff --git a/java/org/apache/el/MethodExpressionLiteral.java b/java/org/apache/el/MethodExpressionLiteral.java index 9fd0046b19..eeec431a47 100644 --- a/java/org/apache/el/MethodExpressionLiteral.java +++ b/java/org/apache/el/MethodExpressionLiteral.java @@ -47,8 +47,7 @@ public class MethodExpressionLiteral extends MethodExpression implements Externa // do nothing } - public MethodExpressionLiteral(String expr, Class<?> expectedType, - Class<?>[] paramTypes) { + public MethodExpressionLiteral(String expr, Class<?> expectedType, Class<?>[] paramTypes) { this.expr = expr; this.expectedType = expectedType; this.paramTypes = paramTypes; @@ -120,15 +119,13 @@ public class MethodExpressionLiteral extends MethodExpression implements Externa if (!type.isEmpty()) { this.expectedType = ReflectionUtil.forName(type); } - this.paramTypes = ReflectionUtil.toTypeArray(((String[]) in - .readObject())); + this.paramTypes = ReflectionUtil.toTypeArray(((String[]) in.readObject())); } @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeUTF(this.expr); - out.writeUTF((this.expectedType != null) ? this.expectedType.getName() - : ""); + out.writeUTF((this.expectedType != null) ? this.expectedType.getName() : ""); out.writeObject(ReflectionUtil.toTypeNameArray(this.paramTypes)); } } diff --git a/java/org/apache/el/ValueExpressionImpl.java b/java/org/apache/el/ValueExpressionImpl.java index 563ec6c7c6..097b924dc7 100644 --- a/java/org/apache/el/ValueExpressionImpl.java +++ b/java/org/apache/el/ValueExpressionImpl.java @@ -39,43 +39,32 @@ import org.apache.el.util.ReflectionUtil; /** * An <code>Expression</code> that can get or set a value. - * * <p> - * In previous incarnations of this API, expressions could only be read. - * <code>ValueExpression</code> objects can now be used both to retrieve a - * value and to set a value. Expressions that can have a value set on them are - * referred to as l-value expressions. Those that cannot are referred to as - * r-value expressions. Not all r-value expressions can be used as l-value - * expressions (e.g. <code>"${1+1}"</code> or - * <code>"${firstName} ${lastName}"</code>). See the EL Specification for - * details. Expressions that cannot be used as l-values must always return - * <code>true</code> from <code>isReadOnly()</code>. + * In previous incarnations of this API, expressions could only be read. <code>ValueExpression</code> objects can now be + * used both to retrieve a value and to set a value. Expressions that can have a value set on them are referred to as + * l-value expressions. Those that cannot are referred to as r-value expressions. Not all r-value expressions can be + * used as l-value expressions (e.g. <code>"${1+1}"</code> or <code>"${firstName} ${lastName}"</code>). See the EL + * Specification for details. Expressions that cannot be used as l-values must always return <code>true</code> from + * <code>isReadOnly()</code>. * </p> - * * <p> - * The {@link jakarta.el.ExpressionFactory#createValueExpression} method - * can be used to parse an expression string and return a concrete instance - * of <code>ValueExpression</code> that encapsulates the parsed expression. - * The {@link FunctionMapper} is used at parse time, not evaluation time, - * so one is not needed to evaluate an expression using this class. - * However, the {@link ELContext} is needed at evaluation time.</p> - * - * <p>The {@link #getValue}, {@link #setValue}, {@link #isReadOnly} and - * {@link #getType} methods will evaluate the expression each time they are - * called. The {@link jakarta.el.ELResolver} in the <code>ELContext</code> is used - * to resolve the top-level variables and to determine the behavior of the - * <code>.</code> and <code>[]</code> operators. For any of the four methods, - * the {@link jakarta.el.ELResolver#getValue} method is used to resolve all - * properties up to but excluding the last one. This provides the - * <code>base</code> object. At the last resolution, the - * <code>ValueExpression</code> will call the corresponding - * {@link jakarta.el.ELResolver#getValue}, {@link jakarta.el.ELResolver#setValue}, - * {@link jakarta.el.ELResolver#isReadOnly} or {@link jakarta.el.ELResolver#getType} - * method, depending on which was called on the <code>ValueExpression</code>. + * The {@link jakarta.el.ExpressionFactory#createValueExpression} method can be used to parse an expression string and + * return a concrete instance of <code>ValueExpression</code> that encapsulates the parsed expression. The + * {@link FunctionMapper} is used at parse time, not evaluation time, so one is not needed to evaluate an expression + * using this class. However, the {@link ELContext} is needed at evaluation time. * </p> - * - * <p>See the notes about comparison, serialization and immutability in - * the {@link jakarta.el.Expression} javadocs. + * <p> + * The {@link #getValue}, {@link #setValue}, {@link #isReadOnly} and {@link #getType} methods will evaluate the + * expression each time they are called. The {@link jakarta.el.ELResolver} in the <code>ELContext</code> is used to + * resolve the top-level variables and to determine the behavior of the <code>.</code> and <code>[]</code> operators. + * For any of the four methods, the {@link jakarta.el.ELResolver#getValue} method is used to resolve all properties up + * to but excluding the last one. This provides the <code>base</code> object. At the last resolution, the + * <code>ValueExpression</code> will call the corresponding {@link jakarta.el.ELResolver#getValue}, + * {@link jakarta.el.ELResolver#setValue}, {@link jakarta.el.ELResolver#isReadOnly} or + * {@link jakarta.el.ELResolver#getType} method, depending on which was called on the <code>ValueExpression</code>. + * </p> + * <p> + * See the notes about comparison, serialization and immutability in the {@link jakarta.el.Expression} javadocs. * * @see jakarta.el.ELResolver * @see jakarta.el.Expression @@ -84,8 +73,7 @@ import org.apache.el.util.ReflectionUtil; * * @author Jacob Hookom [ja...@hookom.net] */ -public final class ValueExpressionImpl extends ValueExpression implements - Externalizable { +public final class ValueExpressionImpl extends ValueExpression implements Externalizable { private Class<?> expectedType; @@ -101,8 +89,8 @@ public final class ValueExpressionImpl extends ValueExpression implements super(); } - public ValueExpressionImpl(String expr, Node node, FunctionMapper fnMapper, - VariableMapper varMapper, Class<?> expectedType) { + public ValueExpressionImpl(String expr, Node node, FunctionMapper fnMapper, VariableMapper varMapper, + Class<?> expectedType) { this.expr = expr; this.node = node; this.fnMapper = fnMapper; @@ -128,12 +116,10 @@ public final class ValueExpressionImpl extends ValueExpression implements } /** - * Returns the type the result of the expression will be coerced to after - * evaluation. + * Returns the type the result of the expression will be coerced to after evaluation. * - * @return the <code>expectedType</code> passed to the - * <code>ExpressionFactory.createValueExpression</code> method - * that created this <code>ValueExpression</code>. + * @return the <code>expectedType</code> passed to the <code>ExpressionFactory.createValueExpression</code> method + * that created this <code>ValueExpression</code>. * * @see jakarta.el.Expression#getExpressionString() */ @@ -150,10 +136,8 @@ public final class ValueExpressionImpl extends ValueExpression implements } @Override - public Class<?> getType(ELContext context) throws PropertyNotFoundException, - ELException { - EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, - this.varMapper); + public Class<?> getType(ELContext context) throws PropertyNotFoundException, ELException { + EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, this.varMapper); context.notifyBeforeEvaluation(getExpressionString()); Class<?> result = this.getNode().getType(ctx); context.notifyAfterEvaluation(getExpressionString()); @@ -162,10 +146,8 @@ public final class ValueExpressionImpl extends ValueExpression implements @SuppressWarnings("unchecked") @Override - public <T> T getValue(ELContext context) throws PropertyNotFoundException, - ELException { - EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, - this.varMapper); + public <T> T getValue(ELContext context) throws PropertyNotFoundException, ELException { + EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, this.varMapper); context.notifyBeforeEvaluation(getExpressionString()); Object value = this.getNode().getValue(ctx); if (this.expectedType != null) { @@ -190,10 +172,8 @@ public final class ValueExpressionImpl extends ValueExpression implements } @Override - public boolean isReadOnly(ELContext context) - throws PropertyNotFoundException, ELException { - EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, - this.varMapper); + public boolean isReadOnly(ELContext context) throws PropertyNotFoundException, ELException { + EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, this.varMapper); context.notifyBeforeEvaluation(getExpressionString()); boolean result = this.getNode().isReadOnly(ctx); context.notifyAfterEvaluation(getExpressionString()); @@ -201,8 +181,7 @@ public final class ValueExpressionImpl extends ValueExpression implements } @Override - public void readExternal(ObjectInput in) throws IOException, - ClassNotFoundException { + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { this.expr = in.readUTF(); String type = in.readUTF(); if (!type.isEmpty()) { @@ -214,10 +193,8 @@ public final class ValueExpressionImpl extends ValueExpression implements @Override public void setValue(ELContext context, Object value) - throws PropertyNotFoundException, PropertyNotWritableException, - ELException { - EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, - this.varMapper); + throws PropertyNotFoundException, PropertyNotWritableException, ELException { + EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, this.varMapper); context.notifyBeforeEvaluation(getExpressionString()); this.getNode().setValue(ctx, value); context.notifyAfterEvaluation(getExpressionString()); @@ -226,21 +203,19 @@ public final class ValueExpressionImpl extends ValueExpression implements @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeUTF(this.expr); - out.writeUTF((this.expectedType != null) ? this.expectedType.getName() - : ""); + out.writeUTF((this.expectedType != null) ? this.expectedType.getName() : ""); out.writeObject(this.fnMapper); out.writeObject(this.varMapper); } @Override public String toString() { - return "ValueExpression["+this.expr+"]"; + return "ValueExpression[" + this.expr + "]"; } @Override public ValueReference getValueReference(ELContext context) { - EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, - this.varMapper); + EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, this.varMapper); context.notifyBeforeEvaluation(getExpressionString()); ValueReference result = this.getNode().getValueReference(ctx); context.notifyAfterEvaluation(getExpressionString()); diff --git a/java/org/apache/el/ValueExpressionLiteral.java b/java/org/apache/el/ValueExpressionLiteral.java index 2ecfe8d4b0..ab6d0c18dc 100644 --- a/java/org/apache/el/ValueExpressionLiteral.java +++ b/java/org/apache/el/ValueExpressionLiteral.java @@ -29,8 +29,7 @@ import org.apache.el.util.MessageFactory; import org.apache.el.util.ReflectionUtil; -public final class ValueExpressionLiteral extends ValueExpression implements - Externalizable { +public final class ValueExpressionLiteral extends ValueExpression implements Externalizable { private static final long serialVersionUID = 1L; @@ -65,8 +64,7 @@ public final class ValueExpressionLiteral extends ValueExpression implements @Override public void setValue(ELContext context, Object value) { context.notifyBeforeEvaluation(getExpressionString()); - throw new PropertyNotWritableException(MessageFactory.get( - "error.value.literal.write", this.value)); + throw new PropertyNotWritableException(MessageFactory.get("error.value.literal.write", this.value)); } @Override @@ -99,13 +97,12 @@ public final class ValueExpressionLiteral extends ValueExpression implements @Override public boolean equals(Object obj) { - return (obj instanceof ValueExpressionLiteral && this - .equals((ValueExpressionLiteral) obj)); + return (obj instanceof ValueExpressionLiteral && this.equals((ValueExpressionLiteral) obj)); } public boolean equals(ValueExpressionLiteral ve) { - return (ve != null && (this.value != null && ve.value != null && (this.value == ve.value || this.value - .equals(ve.value)))); + return (ve != null && + (this.value != null && ve.value != null && (this.value == ve.value || this.value.equals(ve.value)))); } @Override @@ -121,13 +118,11 @@ public final class ValueExpressionLiteral extends ValueExpression implements @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(this.value); - out.writeUTF((this.expectedType != null) ? this.expectedType.getName() - : ""); + out.writeUTF((this.expectedType != null) ? this.expectedType.getName() : ""); } @Override - public void readExternal(ObjectInput in) throws IOException, - ClassNotFoundException { + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { this.value = in.readObject(); String type = in.readUTF(); if (!type.isEmpty()) { diff --git a/java/org/apache/el/lang/ELArithmetic.java b/java/org/apache/el/lang/ELArithmetic.java index de7dacae1b..17182c1fe3 100644 --- a/java/org/apache/el/lang/ELArithmetic.java +++ b/java/org/apache/el/lang/ELArithmetic.java @@ -27,6 +27,7 @@ import org.apache.el.util.MessageFactory; /** * A helper class of Arithmetic defined by the EL Specification + * * @author Jacob Hookom [ja...@hookom.net] */ public abstract class ELArithmetic { @@ -56,8 +57,7 @@ public abstract class ELArithmetic { @Override protected Number divide(Number num0, Number num1) { - return ((BigDecimal) num0).divide((BigDecimal) num1, - RoundingMode.HALF_UP); + return ((BigDecimal) num0).divide((BigDecimal) num1, RoundingMode.HALF_UP); } @Override @@ -190,13 +190,9 @@ public abstract class ELArithmetic { @Override public boolean matches(Object obj0, Object obj1) { - return (obj0 instanceof Double - || obj1 instanceof Double - || obj0 instanceof Float - || obj1 instanceof Float - || (obj0 instanceof String && ELSupport - .isStringFloat((String) obj0)) || (obj1 instanceof String && ELSupport - .isStringFloat((String) obj1))); + return (obj0 instanceof Double || obj1 instanceof Double || obj0 instanceof Float || + obj1 instanceof Float || (obj0 instanceof String && ELSupport.isStringFloat((String) obj0)) || + (obj1 instanceof String && ELSupport.isStringFloat((String) obj1))); } } @@ -359,10 +355,8 @@ public abstract class ELArithmetic { } public static final boolean isNumberType(final Class<?> type) { - return type == Long.TYPE || type == Double.TYPE || - type == Byte.TYPE || type == Short.TYPE || - type == Integer.TYPE || type == Float.TYPE || - Number.class.isAssignableFrom(type); + return type == Long.TYPE || type == Double.TYPE || type == Byte.TYPE || type == Short.TYPE || + type == Integer.TYPE || type == Float.TYPE || Number.class.isAssignableFrom(type); } protected ELArithmetic() { diff --git a/java/org/apache/el/lang/ELSupport.java b/java/org/apache/el/lang/ELSupport.java index 402ed20dbb..1a7275e322 100644 --- a/java/org/apache/el/lang/ELSupport.java +++ b/java/org/apache/el/lang/ELSupport.java @@ -53,13 +53,10 @@ public class ELSupport { static { String coerceToZeroStr; if (System.getSecurityManager() != null) { - coerceToZeroStr = AccessController.doPrivileged( - (PrivilegedAction<String>) () -> System.getProperty( - "org.apache.el.parser.COERCE_TO_ZERO", "false") - ); + coerceToZeroStr = AccessController.doPrivileged((PrivilegedAction<String>) () -> System + .getProperty("org.apache.el.parser.COERCE_TO_ZERO", "false")); } else { - coerceToZeroStr = System.getProperty( - "org.apache.el.parser.COERCE_TO_ZERO", "false"); + coerceToZeroStr = System.getProperty("org.apache.el.parser.COERCE_TO_ZERO", "false"); } COERCE_TO_ZERO = Boolean.parseBoolean(coerceToZeroStr); } @@ -68,18 +65,17 @@ public class ELSupport { /** * Compare two objects, after coercing to the same type if appropriate. * <p> - * If the objects are identical, or they are equal according to - * {@link #equals(ELContext, Object, Object)} then return 0. + * If the objects are identical, or they are equal according to {@link #equals(ELContext, Object, Object)} then + * return 0. * <p> - * If either object is a BigDecimal, then coerce both to BigDecimal first. - * Similarly for Double(Float), BigInteger, and Long(Integer, Char, Short, Byte). + * If either object is a BigDecimal, then coerce both to BigDecimal first. Similarly for Double(Float), BigInteger, + * and Long(Integer, Char, Short, Byte). * <p> - * Otherwise, check that the first object is an instance of Comparable, and compare - * against the second object. If that is null, return 1, otherwise - * return the result of comparing against the second object. + * Otherwise, check that the first object is an instance of Comparable, and compare against the second object. If + * that is null, return 1, otherwise return the result of comparing against the second object. * <p> - * Similarly, if the second object is Comparable, if the first is null, return -1, - * else return the result of comparing against the first object. + * Similarly, if the second object is Comparable, if the first is null, return -1, else return the result of + * comparing against the first object. * <p> * A null object is considered as: * <ul> @@ -88,15 +84,16 @@ public class ELSupport { * <li>Otherwise null is considered to be lower than anything else.</li> * </ul> * - * @param ctx the context in which this comparison is taking place + * @param ctx the context in which this comparison is taking place * @param obj0 first object * @param obj1 second object + * * @return -1, 0, or 1 if this object is less than, equal to, or greater than val. - * @throws ELException if neither object is Comparable + * + * @throws ELException if neither object is Comparable * @throws ClassCastException if the objects are not mutually comparable */ - public static final int compare(final ELContext ctx, final Object obj0, final Object obj1) - throws ELException { + public static final int compare(final ELContext ctx, final Object obj0, final Object obj1) throws ELException { if (obj0 == obj1 || equals(ctx, obj0, obj1)) { return 0; } @@ -149,14 +146,15 @@ public class ELSupport { * <p> * Otherwise default to using Object.equals(). * - * @param ctx the context in which this equality test is taking place + * @param ctx the context in which this equality test is taking place * @param obj0 the first object * @param obj1 the second object + * * @return true if the objects are equal + * * @throws ELException if one of the coercion fails */ - public static final boolean equals(final ELContext ctx, final Object obj0, final Object obj1) - throws ELException { + public static final boolean equals(final ELContext ctx, final Object obj0, final Object obj1) throws ELException { if (obj0 == obj1) { return true; } else if (obj0 == null || obj1 == null) { @@ -173,7 +171,7 @@ public class ELSupport { BigInteger bi0 = (BigInteger) coerceToNumber(ctx, obj0, BigInteger.class); BigInteger bi1 = (BigInteger) coerceToNumber(ctx, obj1, BigInteger.class); return bi0.equals(bi1); - } else if (isLongOp(obj0, obj1)) { + } else if (isLongOp(obj0, obj1)) { Long l0 = (Long) coerceToNumber(ctx, obj0, Long.class); Long l1 = (Long) coerceToNumber(ctx, obj1, Long.class); return l0.equals(l1); @@ -192,8 +190,8 @@ public class ELSupport { } /* - * Going to have to have some casts /raw types somewhere so doing it here keeps them all in one place. There might - * be a neater / better solution but I couldn't find it. + * Going to have to have some casts /raw types somewhere so doing it here keeps them all in one place. There might + * be a neater / better solution but I couldn't find it. */ @SuppressWarnings("unchecked") public static final Enum<?> coerceToEnum(final ELContext ctx, final Object obj, @@ -219,32 +217,31 @@ public class ELSupport { } if (!(obj instanceof String)) { - throw new ELException(MessageFactory.get("error.convert", - obj, obj.getClass(), type)); + throw new ELException(MessageFactory.get("error.convert", obj, obj.getClass(), type)); } Enum<?> result; try { - result = Enum.valueOf(type, (String) obj); + result = Enum.valueOf(type, (String) obj); } catch (IllegalArgumentException iae) { - throw new ELException(MessageFactory.get("error.convert", - obj, obj.getClass(), type)); + throw new ELException(MessageFactory.get("error.convert", obj, obj.getClass(), type)); } return result; } /** - * Convert an object to Boolean. - * Null and empty string are false. - * @param ctx the context in which this conversion is taking place - * @param obj the object to convert - * @param primitive is the target a primitive in which case coercion to null - * is not permitted + * Convert an object to Boolean. Null and empty string are false. + * + * @param ctx the context in which this conversion is taking place + * @param obj the object to convert + * @param primitive is the target a primitive in which case coercion to null is not permitted + * * @return the Boolean value of the object + * * @throws ELException if object is not Boolean or String */ - public static final Boolean coerceToBoolean(final ELContext ctx, final Object obj, - boolean primitive) throws ELException { + public static final Boolean coerceToBoolean(final ELContext ctx, final Object obj, boolean primitive) + throws ELException { if (ctx != null) { boolean originalIsPropertyResolved = ctx.isPropertyResolved(); @@ -274,12 +271,10 @@ public class ELSupport { return Boolean.valueOf((String) obj); } - throw new ELException(MessageFactory.get("error.convert", - obj, obj.getClass(), Boolean.class)); + throw new ELException(MessageFactory.get("error.convert", obj, obj.getClass(), Boolean.class)); } - private static Character coerceToCharacter(final ELContext ctx, final Object obj) - throws ELException { + private static Character coerceToCharacter(final ELContext ctx, final Object obj) throws ELException { if (ctx != null) { boolean originalIsPropertyResolved = ctx.isPropertyResolved(); @@ -307,12 +302,10 @@ public class ELSupport { return (Character) obj; } - throw new ELException(MessageFactory.get("error.convert", - obj, objType, Character.class)); + throw new ELException(MessageFactory.get("error.convert", obj, objType, Character.class)); } - protected static final Number coerceToNumber(final Number number, - final Class<?> type) throws ELException { + protected static final Number coerceToNumber(final Number number, final Class<?> type) throws ELException { if (Long.TYPE == type || Long.class.equals(type)) { return Long.valueOf(number.longValue()); } @@ -353,12 +346,11 @@ public class ELSupport { return number; } - throw new ELException(MessageFactory.get("error.convert", - number, number.getClass(), type)); + throw new ELException(MessageFactory.get("error.convert", number, number.getClass(), type)); } - public static final Number coerceToNumber(final ELContext ctx, final Object obj, - final Class<?> type) throws ELException { + public static final Number coerceToNumber(final ELContext ctx, final Object obj, final Class<?> type) + throws ELException { if (ctx != null) { boolean originalIsPropertyResolved = ctx.isPropertyResolved(); @@ -389,89 +381,79 @@ public class ELSupport { } if (obj instanceof Character) { - return coerceToNumber(Short.valueOf((short) ((Character) obj) - .charValue()), type); + return coerceToNumber(Short.valueOf((short) ((Character) obj).charValue()), type); } - throw new ELException(MessageFactory.get("error.convert", - obj, obj.getClass(), type)); + throw new ELException(MessageFactory.get("error.convert", obj, obj.getClass(), type)); } - protected static final Number coerceToNumber(final String val, - final Class<?> type) throws ELException { + protected static final Number coerceToNumber(final String val, final Class<?> type) throws ELException { if (Long.TYPE == type || Long.class.equals(type)) { try { return Long.valueOf(val); } catch (NumberFormatException nfe) { - throw new ELException(MessageFactory.get("error.convert", - val, String.class, type)); + throw new ELException(MessageFactory.get("error.convert", val, String.class, type)); } } if (Integer.TYPE == type || Integer.class.equals(type)) { try { return Integer.valueOf(val); } catch (NumberFormatException nfe) { - throw new ELException(MessageFactory.get("error.convert", - val, String.class, type)); + throw new ELException(MessageFactory.get("error.convert", val, String.class, type)); } } if (Double.TYPE == type || Double.class.equals(type)) { try { return Double.valueOf(val); } catch (NumberFormatException nfe) { - throw new ELException(MessageFactory.get("error.convert", - val, String.class, type)); + throw new ELException(MessageFactory.get("error.convert", val, String.class, type)); } } if (BigInteger.class.equals(type)) { try { return new BigInteger(val); } catch (NumberFormatException nfe) { - throw new ELException(MessageFactory.get("error.convert", - val, String.class, type)); + throw new ELException(MessageFactory.get("error.convert", val, String.class, type)); } } if (BigDecimal.class.equals(type)) { try { return new BigDecimal(val); } catch (NumberFormatException nfe) { - throw new ELException(MessageFactory.get("error.convert", - val, String.class, type)); + throw new ELException(MessageFactory.get("error.convert", val, String.class, type)); } } if (Byte.TYPE == type || Byte.class.equals(type)) { try { return Byte.valueOf(val); } catch (NumberFormatException nfe) { - throw new ELException(MessageFactory.get("error.convert", - val, String.class, type)); + throw new ELException(MessageFactory.get("error.convert", val, String.class, type)); } } if (Short.TYPE == type || Short.class.equals(type)) { try { return Short.valueOf(val); } catch (NumberFormatException nfe) { - throw new ELException(MessageFactory.get("error.convert", - val, String.class, type)); + throw new ELException(MessageFactory.get("error.convert", val, String.class, type)); } } if (Float.TYPE == type || Float.class.equals(type)) { try { return Float.valueOf(val); } catch (NumberFormatException nfe) { - throw new ELException(MessageFactory.get("error.convert", - val, String.class, type)); + throw new ELException(MessageFactory.get("error.convert", val, String.class, type)); } } - throw new ELException(MessageFactory.get("error.convert", - val, String.class, type)); + throw new ELException(MessageFactory.get("error.convert", val, String.class, type)); } /** * Coerce an object to a string. + * * @param ctx the context in which this conversion is taking place * @param obj the object to convert + * * @return the String value of the object */ public static final String coerceToString(final ELContext ctx, final Object obj) { @@ -507,8 +489,8 @@ public class ELSupport { } } - public static final <T> T coerceToType(final ELContext ctx, final Object obj, - final Class<T> type) throws ELException { + public static final <T> T coerceToType(final ELContext ctx, final Object obj, final Class<T> type) + throws ELException { if (ctx != null) { boolean originalIsPropertyResolved = ctx.isPropertyResolved(); @@ -522,16 +504,14 @@ public class ELSupport { } } - if (type == null || Object.class.equals(type) || - (obj != null && type.isAssignableFrom(obj.getClass()))) { + if (type == null || Object.class.equals(type) || (obj != null && type.isAssignableFrom(obj.getClass()))) { @SuppressWarnings("unchecked") T result = (T) obj; return result; } if (!COERCE_TO_ZERO) { - if (obj == null && !type.isPrimitive() && - !String.class.isAssignableFrom(type)) { + if (obj == null && !type.isPrimitive() && !String.class.isAssignableFrom(type)) { return null; } } @@ -573,8 +553,7 @@ public class ELSupport { if (str.isEmpty()) { return null; } - throw new ELException(MessageFactory.get("error.convert", obj, - obj.getClass(), type)); + throw new ELException(MessageFactory.get("error.convert", obj, obj.getClass(), type)); } else { try { editor.setAsText(str); @@ -585,16 +564,14 @@ public class ELSupport { if (str.isEmpty()) { return null; } - throw new ELException(MessageFactory.get("error.convert", - obj, obj.getClass(), type), e); + throw new ELException(MessageFactory.get("error.convert", obj, obj.getClass(), type), e); } } } // Handle special case because the syntax for the empty set is the same // for an empty map. The parser will always parse {} as an empty set. - if (obj instanceof Set && type == Map.class && - ((Set<?>) obj).isEmpty()) { + if (obj instanceof Set && type == Map.class && ((Set<?>) obj).isEmpty()) { @SuppressWarnings("unchecked") T result = (T) Collections.EMPTY_MAP; return result; @@ -612,12 +589,10 @@ public class ELSupport { return result; } - throw new ELException(MessageFactory.get("error.convert", - obj, obj.getClass(), type)); + throw new ELException(MessageFactory.get("error.convert", obj, obj.getClass(), type)); } - private static Object coerceToArray(final ELContext ctx, final Object obj, - final Class<?> type) { + private static Object coerceToArray(final ELContext ctx, final Object obj, final Class<?> type) { // Note: Nested arrays will result in nested calls to this method. // Note: Calling method has checked the obj is an array. @@ -643,21 +618,21 @@ public class ELSupport { Supplier<T> proxy = () -> { // Create a dynamic proxy for the functional interface @SuppressWarnings("unchecked") - T result = (T) Proxy.newProxyInstance(type.getClassLoader(), new Class[]{type}, - (Object obj, Method method, Object[] args) -> { - // Functional interfaces have a single, abstract method - if (!Modifier.isAbstract(method.getModifiers())) { - throw new ELException(MessageFactory.get("elSupport.coerce.nonAbstract", type, method)); - } - if (ctx == null) { - return lambdaExpression.invoke(args); - } else { - return lambdaExpression.invoke(ctx, args); - } - }); + T result = (T) Proxy.newProxyInstance(type.getClassLoader(), new Class[] { type }, + (Object obj, Method method, Object[] args) -> { + // Functional interfaces have a single, abstract method + if (!Modifier.isAbstract(method.getModifiers())) { + throw new ELException(MessageFactory.get("elSupport.coerce.nonAbstract", type, method)); + } + if (ctx == null) { + return lambdaExpression.invoke(args); + } else { + return lambdaExpression.invoke(ctx, args); + } + }); return result; }; - if (System.getSecurityManager() != null) { + if (System.getSecurityManager() != null) { return AccessController.doPrivileged((PrivilegedAction<T>) proxy::get); } else { return proxy.get(); @@ -665,34 +640,22 @@ public class ELSupport { } - public static final boolean isBigDecimalOp(final Object obj0, - final Object obj1) { + public static final boolean isBigDecimalOp(final Object obj0, final Object obj1) { return (obj0 instanceof BigDecimal || obj1 instanceof BigDecimal); } - public static final boolean isBigIntegerOp(final Object obj0, - final Object obj1) { + public static final boolean isBigIntegerOp(final Object obj0, final Object obj1) { return (obj0 instanceof BigInteger || obj1 instanceof BigInteger); } public static final boolean isDoubleOp(final Object obj0, final Object obj1) { - return (obj0 instanceof Double - || obj1 instanceof Double - || obj0 instanceof Float - || obj1 instanceof Float); + return (obj0 instanceof Double || obj1 instanceof Double || obj0 instanceof Float || obj1 instanceof Float); } public static final boolean isLongOp(final Object obj0, final Object obj1) { - return (obj0 instanceof Long - || obj1 instanceof Long - || obj0 instanceof Integer - || obj1 instanceof Integer - || obj0 instanceof Character - || obj1 instanceof Character - || obj0 instanceof Short - || obj1 instanceof Short - || obj0 instanceof Byte - || obj1 instanceof Byte); + return (obj0 instanceof Long || obj1 instanceof Long || obj0 instanceof Integer || obj1 instanceof Integer || + obj0 instanceof Character || obj1 instanceof Character || obj0 instanceof Short || + obj1 instanceof Short || obj0 instanceof Byte || obj1 instanceof Byte); } public static final boolean isStringFloat(final String str) { @@ -700,12 +663,12 @@ public class ELSupport { if (len > 1) { for (int i = 0; i < len; i++) { switch (str.charAt(i)) { - case 'E': - return true; - case 'e': - return true; - case '.': - return true; + case 'E': + return true; + case 'e': + return true; + case '.': + return true; } } } diff --git a/java/org/apache/el/lang/EvaluationContext.java b/java/org/apache/el/lang/EvaluationContext.java index 1c354b2965..79b26c5c2d 100644 --- a/java/org/apache/el/lang/EvaluationContext.java +++ b/java/org/apache/el/lang/EvaluationContext.java @@ -39,8 +39,7 @@ public final class EvaluationContext extends ELContext { private LambdaExpressionNestedState lambdaExpressionNestedState; - public EvaluationContext(ELContext elContext, FunctionMapper fnMapper, - VariableMapper varMapper) { + public EvaluationContext(ELContext elContext, FunctionMapper fnMapper, VariableMapper varMapper) { this.elContext = elContext; this.fnMapper = fnMapper; this.varMapper = varMapper; @@ -88,7 +87,7 @@ public final class EvaluationContext extends ELContext { @Override public Locale getLocale() { return elContext.getLocale(); - } + } @Override public void setLocale(Locale locale) { @@ -141,7 +140,7 @@ public final class EvaluationContext extends ELContext { } @Override - public void enterLambdaScope(Map<String, Object> arguments) { + public void enterLambdaScope(Map<String,Object> arguments) { elContext.enterLambdaScope(arguments); } @@ -178,10 +177,10 @@ public final class EvaluationContext extends ELContext { public void setLambdaExpressionNestedState(LambdaExpressionNestedState lambdaExpressionNestedState) { - if (this.lambdaExpressionNestedState != null) { - // Should never happen - throw new IllegalStateException(MessageFactory.get("error.lambda.wrongNestedState")); - } + if (this.lambdaExpressionNestedState != null) { + // Should never happen + throw new IllegalStateException(MessageFactory.get("error.lambda.wrongNestedState")); + } this.lambdaExpressionNestedState = lambdaExpressionNestedState; } diff --git a/java/org/apache/el/lang/ExpressionBuilder.java b/java/org/apache/el/lang/ExpressionBuilder.java index 6a13b02886..52c9943f47 100644 --- a/java/org/apache/el/lang/ExpressionBuilder.java +++ b/java/org/apache/el/lang/ExpressionBuilder.java @@ -52,22 +52,20 @@ public final class ExpressionBuilder implements NodeVisitor { private static final SynchronizedStack<ELParser> parserCache = new SynchronizedStack<>(); private static final int CACHE_SIZE; - private static final String CACHE_SIZE_PROP = - "org.apache.el.ExpressionBuilder.CACHE_SIZE"; + private static final String CACHE_SIZE_PROP = "org.apache.el.ExpressionBuilder.CACHE_SIZE"; static { String cacheSizeStr; if (System.getSecurityManager() == null) { cacheSizeStr = System.getProperty(CACHE_SIZE_PROP, "5000"); } else { - cacheSizeStr = AccessController.doPrivileged( - (PrivilegedAction<String>) () -> System.getProperty(CACHE_SIZE_PROP, "5000")); + cacheSizeStr = AccessController + .doPrivileged((PrivilegedAction<String>) () -> System.getProperty(CACHE_SIZE_PROP, "5000")); } CACHE_SIZE = Integer.parseInt(cacheSizeStr); } - private static final ConcurrentCache<String, Node> expressionCache = - new ConcurrentCache<>(CACHE_SIZE); + private static final ConcurrentCache<String,Node> expressionCache = new ConcurrentCache<>(CACHE_SIZE); private FunctionMapper fnMapper; @@ -75,8 +73,7 @@ public final class ExpressionBuilder implements NodeVisitor { private final String expression; - public ExpressionBuilder(String expression, ELContext ctx) - throws ELException { + public ExpressionBuilder(String expression, ELContext ctx) throws ELException { this.expression = expression; FunctionMapper ctxFn = ctx.getFunctionMapper(); @@ -95,8 +92,7 @@ public final class ExpressionBuilder implements NodeVisitor { return n; } - private static Node createNodeInternal(String expr) - throws ELException { + private static Node createNodeInternal(String expr) throws ELException { if (expr == null) { throw new ELException(MessageFactory.get("error.null")); } @@ -128,22 +124,19 @@ public final class ExpressionBuilder implements NodeVisitor { type = child.getClass(); } else { if (!type.equals(child.getClass())) { - throw new ELException(MessageFactory.get( - "error.mixed", expr)); + throw new ELException(MessageFactory.get("error.mixed", expr)); } } } } - if (n instanceof AstDeferredExpression - || n instanceof AstDynamicExpression) { + if (n instanceof AstDeferredExpression || n instanceof AstDynamicExpression) { n = n.jjtGetChild(0); } expressionCache.put(expr, n); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); - throw new ELException( - MessageFactory.get("error.parseFail", expr), t); + throw new ELException(MessageFactory.get("error.parseFail", expr), t); } finally { if (parser != null) { parserCache.push(parser); @@ -174,8 +167,7 @@ public final class ExpressionBuilder implements NodeVisitor { private Node build() throws ELException { Node n = createNodeInternal(this.expression); this.prepare(n); - if (n instanceof AstDeferredExpression - || n instanceof AstDynamicExpression) { + if (n instanceof AstDeferredExpression || n instanceof AstDynamicExpression) { n = n.jjtGetChild(0); } return n; @@ -190,15 +182,13 @@ public final class ExpressionBuilder implements NodeVisitor { Method m = null; if (this.fnMapper != null) { - m = fnMapper.resolveFunction(funcNode.getPrefix(), funcNode - .getLocalName()); + m = fnMapper.resolveFunction(funcNode.getPrefix(), funcNode.getLocalName()); } // References to variables that refer to lambda expressions will be // parsed as functions. This is handled at runtime but at this point // need to treat it as a variable rather than a function. - if (m == null && this.varMapper != null && - funcNode.getPrefix().length() == 0) { + if (m == null && this.varMapper != null && funcNode.getPrefix().length() == 0) { this.varMapper.resolveVariable(funcNode.getLocalName()); return; } @@ -208,8 +198,7 @@ public final class ExpressionBuilder implements NodeVisitor { } if (m == null) { - throw new ELException(MessageFactory.get( - "error.fnMapper.method", funcNode.getOutputName())); + throw new ELException(MessageFactory.get("error.fnMapper.method", funcNode.getOutputName())); } int methodParameterCount = m.getParameterTypes().length; @@ -217,8 +206,7 @@ public final class ExpressionBuilder implements NodeVisitor { int inputParameterCount = node.jjtGetChild(0).jjtGetNumChildren(); if (m.isVarArgs() && inputParameterCount < methodParameterCount - 1 || !m.isVarArgs() && inputParameterCount != methodParameterCount) { - throw new ELException(MessageFactory.get( - "error.fnMapper.paramcount", funcNode.getOutputName(), + throw new ELException(MessageFactory.get("error.fnMapper.paramcount", funcNode.getOutputName(), "" + methodParameterCount, "" + node.jjtGetChild(0).jjtGetNumChildren())); } } else if (node instanceof AstIdentifier && this.varMapper != null) { @@ -229,35 +217,30 @@ public final class ExpressionBuilder implements NodeVisitor { } } - public ValueExpression createValueExpression(Class<?> expectedType) - throws ELException { + public ValueExpression createValueExpression(Class<?> expectedType) throws ELException { Node n = this.build(); - return new ValueExpressionImpl(this.expression, n, this.fnMapper, - this.varMapper, expectedType); + return new ValueExpressionImpl(this.expression, n, this.fnMapper, this.varMapper, expectedType); } - public MethodExpression createMethodExpression(Class<?> expectedReturnType, - Class<?>[] expectedParamTypes) throws ELException { + public MethodExpression createMethodExpression(Class<?> expectedReturnType, Class<?>[] expectedParamTypes) + throws ELException { Node n = this.build(); if (!n.isParametersProvided() && expectedParamTypes == null) { - throw new NullPointerException(MessageFactory - .get("error.method.nullParms")); + throw new NullPointerException(MessageFactory.get("error.method.nullParms")); } if (n instanceof AstValue || n instanceof AstIdentifier) { - return new MethodExpressionImpl(expression, n, this.fnMapper, - this.varMapper, expectedReturnType, expectedParamTypes); - } else if (n instanceof AstLiteralExpression) { - return new MethodExpressionLiteral(expression, expectedReturnType, + return new MethodExpressionImpl(expression, n, this.fnMapper, this.varMapper, expectedReturnType, expectedParamTypes); + } else if (n instanceof AstLiteralExpression) { + return new MethodExpressionLiteral(expression, expectedReturnType, expectedParamTypes); } else { throw new ELException(MessageFactory.get("error.invalidMethodExpression", expression)); } } /* - * Copied from org.apache.tomcat.util.collections.SynchronizedStack since - * we don't want the EL implementation to depend on the JAR where that - * class resides. + * Copied from org.apache.tomcat.util.collections.SynchronizedStack since we don't want the EL implementation to + * depend on the JAR where that class resides. */ private static class SynchronizedStack<T> { diff --git a/java/org/apache/el/lang/FunctionMapperImpl.java b/java/org/apache/el/lang/FunctionMapperImpl.java index 23460c160c..ba35e56b4b 100644 --- a/java/org/apache/el/lang/FunctionMapperImpl.java +++ b/java/org/apache/el/lang/FunctionMapperImpl.java @@ -33,12 +33,11 @@ import org.apache.el.util.ReflectionUtil; /** * @author Jacob Hookom [ja...@hookom.net] */ -public class FunctionMapperImpl extends FunctionMapper implements - Externalizable { +public class FunctionMapperImpl extends FunctionMapper implements Externalizable { private static final long serialVersionUID = 1L; - protected ConcurrentMap<String, Function> functions = new ConcurrentHashMap<>(); + protected ConcurrentMap<String,Function> functions = new ConcurrentHashMap<>(); @Override public Method resolveFunction(String prefix, String localName) { @@ -67,9 +66,8 @@ public class FunctionMapperImpl extends FunctionMapper implements @SuppressWarnings("unchecked") @Override - public void readExternal(ObjectInput in) throws IOException, - ClassNotFoundException { - this.functions = (ConcurrentMap<String, Function>) in.readObject(); + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + this.functions = (ConcurrentMap<String,Function>) in.readObject(); } public static class Function implements Externalizable { @@ -113,8 +111,7 @@ public class FunctionMapperImpl extends FunctionMapper implements } @Override - public void readExternal(ObjectInput in) throws IOException, - ClassNotFoundException { + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { this.prefix = in.readUTF(); if (this.prefix.isEmpty()) { diff --git a/java/org/apache/el/lang/LambdaExpressionNestedState.java b/java/org/apache/el/lang/LambdaExpressionNestedState.java index f4a4d47c70..ebadaa472f 100644 --- a/java/org/apache/el/lang/LambdaExpressionNestedState.java +++ b/java/org/apache/el/lang/LambdaExpressionNestedState.java @@ -17,16 +17,13 @@ package org.apache.el.lang; /** - * Stores the state required for correct evaluation of lambda expressions. - * Lambda expressions may be nested. Correct evaluation requires knowledge not - * just of the current lambda expression, but also of any nested and nesting + * Stores the state required for correct evaluation of lambda expressions. Lambda expressions may be nested. Correct + * evaluation requires knowledge not just of the current lambda expression, but also of any nested and nesting * expressions. * <p> - * The sets of nodes for parsed expressions are cached and, as a result, a set - * of nodes may be being used by multiple concurrent threads. This means any - * state relating to evaluation cannot be stored in the nodes. State is - * therefore stored in the {@link EvaluationContext} which is created, used for - * a single evaluation and then discarded. + * The sets of nodes for parsed expressions are cached and, as a result, a set of nodes may be being used by multiple + * concurrent threads. This means any state relating to evaluation cannot be stored in the nodes. State is therefore + * stored in the {@link EvaluationContext} which is created, used for a single evaluation and then discarded. */ public final class LambdaExpressionNestedState { diff --git a/java/org/apache/el/lang/VariableMapperImpl.java b/java/org/apache/el/lang/VariableMapperImpl.java index 01dbb4a021..f20d1a8955 100644 --- a/java/org/apache/el/lang/VariableMapperImpl.java +++ b/java/org/apache/el/lang/VariableMapperImpl.java @@ -30,7 +30,7 @@ public class VariableMapperImpl extends VariableMapper implements Externalizable private static final long serialVersionUID = 1L; - private Map<String, ValueExpression> vars = new HashMap<>(); + private Map<String,ValueExpression> vars = new HashMap<>(); public VariableMapperImpl() { super(); @@ -42,8 +42,7 @@ public class VariableMapperImpl extends VariableMapper implements Externalizable } @Override - public ValueExpression setVariable(String variable, - ValueExpression expression) { + public ValueExpression setVariable(String variable, ValueExpression expression) { if (expression == null) { return vars.remove(variable); } else { @@ -53,9 +52,8 @@ public class VariableMapperImpl extends VariableMapper implements Externalizable @SuppressWarnings("unchecked") @Override - public void readExternal(ObjectInput in) throws IOException, - ClassNotFoundException { - this.vars = (Map<String, ValueExpression>) in.readObject(); + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + this.vars = (Map<String,ValueExpression>) in.readObject(); } @Override diff --git a/java/org/apache/el/parser/ArithmeticNode.java b/java/org/apache/el/parser/ArithmeticNode.java index 2a665d1d30..69dacaa4ec 100644 --- a/java/org/apache/el/parser/ArithmeticNode.java +++ b/java/org/apache/el/parser/ArithmeticNode.java @@ -30,8 +30,7 @@ public abstract class ArithmeticNode extends SimpleNode { } @Override - public Class<?> getType(EvaluationContext ctx) - throws ELException { + public Class<?> getType(EvaluationContext ctx) throws ELException { return Number.class; } } diff --git a/java/org/apache/el/parser/AstAnd.java b/java/org/apache/el/parser/AstAnd.java index 85d268e99f..8a87feaaaa 100644 --- a/java/org/apache/el/parser/AstAnd.java +++ b/java/org/apache/el/parser/AstAnd.java @@ -32,8 +32,7 @@ public final class AstAnd extends BooleanNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj = children[0].getValue(ctx); Boolean b = ELSupport.coerceToBoolean(ctx, obj, true); if (!b.booleanValue()) { diff --git a/java/org/apache/el/parser/AstBracketSuffix.java b/java/org/apache/el/parser/AstBracketSuffix.java index 16f2e01700..48e47181d8 100644 --- a/java/org/apache/el/parser/AstBracketSuffix.java +++ b/java/org/apache/el/parser/AstBracketSuffix.java @@ -31,8 +31,7 @@ public final class AstBracketSuffix extends SimpleNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { return this.children[0].getValue(ctx); } } diff --git a/java/org/apache/el/parser/AstChoice.java b/java/org/apache/el/parser/AstChoice.java index 173ea22b3b..3981a97704 100644 --- a/java/org/apache/el/parser/AstChoice.java +++ b/java/org/apache/el/parser/AstChoice.java @@ -32,15 +32,13 @@ public final class AstChoice extends SimpleNode { } @Override - public Class<?> getType(EvaluationContext ctx) - throws ELException { + public Class<?> getType(EvaluationContext ctx) throws ELException { Object val = this.getValue(ctx); return (val != null) ? val.getClass() : null; } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Boolean b0 = ELSupport.coerceToBoolean(ctx, obj0, true); return this.children[((b0.booleanValue() ? 1 : 2))].getValue(ctx); diff --git a/java/org/apache/el/parser/AstCompositeExpression.java b/java/org/apache/el/parser/AstCompositeExpression.java index e893cd466e..a682bd0436 100644 --- a/java/org/apache/el/parser/AstCompositeExpression.java +++ b/java/org/apache/el/parser/AstCompositeExpression.java @@ -33,14 +33,12 @@ public final class AstCompositeExpression extends SimpleNode { } @Override - public Class<?> getType(EvaluationContext ctx) - throws ELException { + public Class<?> getType(EvaluationContext ctx) throws ELException { return String.class; } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { StringBuilder sb = new StringBuilder(16); Object obj = null; if (this.children != null) { diff --git a/java/org/apache/el/parser/AstDeferredExpression.java b/java/org/apache/el/parser/AstDeferredExpression.java index 302b6fad53..78c8b44ce0 100644 --- a/java/org/apache/el/parser/AstDeferredExpression.java +++ b/java/org/apache/el/parser/AstDeferredExpression.java @@ -31,26 +31,22 @@ public final class AstDeferredExpression extends SimpleNode { } @Override - public Class<?> getType(EvaluationContext ctx) - throws ELException { + public Class<?> getType(EvaluationContext ctx) throws ELException { return this.children[0].getType(ctx); } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { return this.children[0].getValue(ctx); } @Override - public boolean isReadOnly(EvaluationContext ctx) - throws ELException { + public boolean isReadOnly(EvaluationContext ctx) throws ELException { return this.children[0].isReadOnly(ctx); } @Override - public void setValue(EvaluationContext ctx, Object value) - throws ELException { + public void setValue(EvaluationContext ctx, Object value) throws ELException { this.children[0].setValue(ctx, value); } } diff --git a/java/org/apache/el/parser/AstDiv.java b/java/org/apache/el/parser/AstDiv.java index fd723d9cad..a5104d557b 100644 --- a/java/org/apache/el/parser/AstDiv.java +++ b/java/org/apache/el/parser/AstDiv.java @@ -32,8 +32,7 @@ public final class AstDiv extends ArithmeticNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return ELArithmetic.divide(obj0, obj1); diff --git a/java/org/apache/el/parser/AstDotSuffix.java b/java/org/apache/el/parser/AstDotSuffix.java index 2e02ee8d38..7bd44fe518 100644 --- a/java/org/apache/el/parser/AstDotSuffix.java +++ b/java/org/apache/el/parser/AstDotSuffix.java @@ -33,16 +33,14 @@ public final class AstDotSuffix extends SimpleNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { return this.image; } @Override public void setImage(String image) { if (!Validation.isIdentifier(image)) { - throw new ELException(MessageFactory.get("error.identifier.notjava", - image)); + throw new ELException(MessageFactory.get("error.identifier.notjava", image)); } this.image = image; } diff --git a/java/org/apache/el/parser/AstDynamicExpression.java b/java/org/apache/el/parser/AstDynamicExpression.java index 413880b067..f3b5d20834 100644 --- a/java/org/apache/el/parser/AstDynamicExpression.java +++ b/java/org/apache/el/parser/AstDynamicExpression.java @@ -31,26 +31,22 @@ public final class AstDynamicExpression extends SimpleNode { } @Override - public Class<?> getType(EvaluationContext ctx) - throws ELException { + public Class<?> getType(EvaluationContext ctx) throws ELException { return this.children[0].getType(ctx); } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { return this.children[0].getValue(ctx); } @Override - public boolean isReadOnly(EvaluationContext ctx) - throws ELException { + public boolean isReadOnly(EvaluationContext ctx) throws ELException { return this.children[0].isReadOnly(ctx); } @Override - public void setValue(EvaluationContext ctx, Object value) - throws ELException { + public void setValue(EvaluationContext ctx, Object value) throws ELException { this.children[0].setValue(ctx, value); } } diff --git a/java/org/apache/el/parser/AstEmpty.java b/java/org/apache/el/parser/AstEmpty.java index 323995b6b7..0fc73218ed 100644 --- a/java/org/apache/el/parser/AstEmpty.java +++ b/java/org/apache/el/parser/AstEmpty.java @@ -34,14 +34,12 @@ public final class AstEmpty extends SimpleNode { } @Override - public Class<?> getType(EvaluationContext ctx) - throws ELException { + public Class<?> getType(EvaluationContext ctx) throws ELException { return Boolean.class; } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj = this.children[0].getValue(ctx); if (obj == null) { return Boolean.TRUE; diff --git a/java/org/apache/el/parser/AstEqual.java b/java/org/apache/el/parser/AstEqual.java index 4a9b53ea96..b64688c779 100644 --- a/java/org/apache/el/parser/AstEqual.java +++ b/java/org/apache/el/parser/AstEqual.java @@ -32,8 +32,7 @@ public final class AstEqual extends BooleanNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return Boolean.valueOf(ELSupport.equals(ctx, obj0, obj1)); diff --git a/java/org/apache/el/parser/AstFalse.java b/java/org/apache/el/parser/AstFalse.java index 54ae49dd12..128783773b 100644 --- a/java/org/apache/el/parser/AstFalse.java +++ b/java/org/apache/el/parser/AstFalse.java @@ -31,8 +31,7 @@ public final class AstFalse extends BooleanNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { return Boolean.FALSE; } } diff --git a/java/org/apache/el/parser/AstFloatingPoint.java b/java/org/apache/el/parser/AstFloatingPoint.java index 7715edcf7a..9f29118176 100644 --- a/java/org/apache/el/parser/AstFloatingPoint.java +++ b/java/org/apache/el/parser/AstFloatingPoint.java @@ -54,14 +54,12 @@ public final class AstFloatingPoint extends SimpleNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { return this.getFloatingPoint(); } @Override - public Class<?> getType(EvaluationContext ctx) - throws ELException { + public Class<?> getType(EvaluationContext ctx) throws ELException { return this.getFloatingPoint().getClass(); } } diff --git a/java/org/apache/el/parser/AstFunction.java b/java/org/apache/el/parser/AstFunction.java index bac8db1be9..7335ec65e3 100644 --- a/java/org/apache/el/parser/AstFunction.java +++ b/java/org/apache/el/parser/AstFunction.java @@ -163,7 +163,8 @@ public final class AstFunction extends SimpleNode { if (m.isVarArgs() && i == methodParameterCount - 1) { if (inputParameterCount < methodParameterCount) { params[i] = new Object[] { null }; - } else if (inputParameterCount == methodParameterCount && isArray(parameters.jjtGetChild(i).getValue(ctx))) { + } else if (inputParameterCount == methodParameterCount && + isArray(parameters.jjtGetChild(i).getValue(ctx))) { params[i] = parameters.jjtGetChild(i).getValue(ctx); } else { Object[] varargs = new Object[inputParameterCount - methodParameterCount + 1]; diff --git a/java/org/apache/el/parser/AstGreaterThan.java b/java/org/apache/el/parser/AstGreaterThan.java index 953947c14d..dac3161fb1 100644 --- a/java/org/apache/el/parser/AstGreaterThan.java +++ b/java/org/apache/el/parser/AstGreaterThan.java @@ -32,8 +32,7 @@ public final class AstGreaterThan extends BooleanNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); if (obj0 == null) { return Boolean.FALSE; diff --git a/java/org/apache/el/parser/AstGreaterThanEqual.java b/java/org/apache/el/parser/AstGreaterThanEqual.java index 3095546264..3f57c000a2 100644 --- a/java/org/apache/el/parser/AstGreaterThanEqual.java +++ b/java/org/apache/el/parser/AstGreaterThanEqual.java @@ -32,8 +32,7 @@ public final class AstGreaterThanEqual extends BooleanNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); if (obj0 == obj1) { diff --git a/java/org/apache/el/parser/AstIdentifier.java b/java/org/apache/el/parser/AstIdentifier.java index 4565536faf..a1f9759932 100644 --- a/java/org/apache/el/parser/AstIdentifier.java +++ b/java/org/apache/el/parser/AstIdentifier.java @@ -53,8 +53,7 @@ public final class AstIdentifier extends SimpleNode { ctx.setPropertyResolved(false); Class<?> result = ctx.getELResolver().getType(ctx, null, this.image); if (!ctx.isPropertyResolved()) { - throw new PropertyNotFoundException(MessageFactory.get( - "error.resolver.unhandled.null", this.image)); + throw new PropertyNotFoundException(MessageFactory.get("error.resolver.unhandled.null", this.image)); } return result; } @@ -78,12 +77,11 @@ public final class AstIdentifier extends SimpleNode { // EL Resolvers ctx.setPropertyResolved(false); Object result; - /* Putting the Boolean into the ELContext is part of a performance - * optimisation for ScopedAttributeELResolver. When looking up "foo", - * the resolver can't differentiate between ${ foo } and ${ foo.bar }. - * This is important because the expensive class lookup only needs to - * be performed in the later case. This flag tells the resolver if the - * lookup can be skipped. + /* + * Putting the Boolean into the ELContext is part of a performance optimisation for ScopedAttributeELResolver. + * When looking up "foo", the resolver can't differentiate between ${ foo } and ${ foo.bar }. This is important + * because the expensive class lookup only needs to be performed in the later case. This flag tells the resolver + * if the lookup can be skipped. */ if (parent instanceof AstValue) { ctx.putContext(this.getClass(), Boolean.FALSE); @@ -111,14 +109,12 @@ public final class AstIdentifier extends SimpleNode { if (result != null) { try { return ((Class<?>) result).getField(this.image).get(null); - } catch (IllegalArgumentException | IllegalAccessException - | NoSuchFieldException | SecurityException e) { + } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) { throw new ELException(e); } } - throw new PropertyNotFoundException(MessageFactory.get( - "error.resolver.unhandled.null", this.image)); + throw new PropertyNotFoundException(MessageFactory.get("error.resolver.unhandled.null", this.image)); } @Override @@ -133,15 +129,13 @@ public final class AstIdentifier extends SimpleNode { ctx.setPropertyResolved(false); boolean result = ctx.getELResolver().isReadOnly(ctx, null, this.image); if (!ctx.isPropertyResolved()) { - throw new PropertyNotFoundException(MessageFactory.get( - "error.resolver.unhandled.null", this.image)); + throw new PropertyNotFoundException(MessageFactory.get("error.resolver.unhandled.null", this.image)); } return result; } @Override - public void setValue(EvaluationContext ctx, Object value) - throws ELException { + public void setValue(EvaluationContext ctx, Object value) throws ELException { VariableMapper varMapper = ctx.getVariableMapper(); if (varMapper != null) { ValueExpression expr = varMapper.resolveVariable(this.image); @@ -153,21 +147,18 @@ public final class AstIdentifier extends SimpleNode { ctx.setPropertyResolved(false); ctx.getELResolver().setValue(ctx, null, this.image, value); if (!ctx.isPropertyResolved()) { - throw new PropertyNotFoundException(MessageFactory.get( - "error.resolver.unhandled.null", this.image)); + throw new PropertyNotFoundException(MessageFactory.get("error.resolver.unhandled.null", this.image)); } } @Override - public Object invoke(EvaluationContext ctx, Class<?>[] paramTypes, - Object[] paramValues) throws ELException { + public Object invoke(EvaluationContext ctx, Class<?>[] paramTypes, Object[] paramValues) throws ELException { return this.getMethodExpression(ctx).invoke(ctx.getELContext(), paramValues); } @Override - public MethodInfo getMethodInfo(EvaluationContext ctx, - Class<?>[] paramTypes) throws ELException { + public MethodInfo getMethodInfo(EvaluationContext ctx, Class<?>[] paramTypes) throws ELException { return this.getMethodExpression(ctx).getMethodInfo(ctx.getELContext()); } @@ -179,8 +170,7 @@ public final class AstIdentifier extends SimpleNode { @Override public void setImage(String image) { if (!Validation.isIdentifier(image)) { - throw new ELException(MessageFactory.get("error.identifier.notjava", - image)); + throw new ELException(MessageFactory.get("error.identifier.notjava", image)); } this.image = image; } @@ -204,8 +194,7 @@ public final class AstIdentifier extends SimpleNode { } - private MethodExpression getMethodExpression(EvaluationContext ctx) - throws ELException { + private MethodExpression getMethodExpression(EvaluationContext ctx) throws ELException { Object obj = null; // case A: ValueExpression exists, getValue which must @@ -232,7 +221,8 @@ public final class AstIdentifier extends SimpleNode { } else if (obj == null) { throw new MethodNotFoundException(MessageFactory.get("error.identifier.noMethod", this.image)); } else { - throw new ELException(MessageFactory.get("error.identifier.notMethodExpression", this.image, obj.getClass().getName())); + throw new ELException( + MessageFactory.get("error.identifier.notMethodExpression", this.image, obj.getClass().getName())); } } } diff --git a/java/org/apache/el/parser/AstInteger.java b/java/org/apache/el/parser/AstInteger.java index f30c131993..0e3114fa49 100644 --- a/java/org/apache/el/parser/AstInteger.java +++ b/java/org/apache/el/parser/AstInteger.java @@ -55,14 +55,12 @@ public final class AstInteger extends SimpleNode { } @Override - public Class<?> getType(EvaluationContext ctx) - throws ELException { + public Class<?> getType(EvaluationContext ctx) throws ELException { return this.getInteger().getClass(); } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { return this.getInteger(); } } diff --git a/java/org/apache/el/parser/AstLambdaExpression.java b/java/org/apache/el/parser/AstLambdaExpression.java index 6bf58d6952..b740d02876 100644 --- a/java/org/apache/el/parser/AstLambdaExpression.java +++ b/java/org/apache/el/parser/AstLambdaExpression.java @@ -52,18 +52,16 @@ public class AstLambdaExpression extends SimpleNode { // nested expressions. int methodParameterSetCount = jjtGetNumChildren() - 2; if (methodParameterSetCount > state.getNestingCount()) { - throw new ELException(MessageFactory.get( - "error.lambda.tooManyMethodParameterSets")); + throw new ELException(MessageFactory.get("error.lambda.tooManyMethodParameterSets")); } // First child is always parameters even if there aren't any - AstLambdaParameters formalParametersNode = - (AstLambdaParameters) children[0]; + AstLambdaParameters formalParametersNode = (AstLambdaParameters) children[0]; Node[] formalParamNodes = formalParametersNode.children; // Second child is a value expression - ValueExpressionImpl ve = new ValueExpressionImpl("", children[1], - ctx.getFunctionMapper(), ctx.getVariableMapper(), null); + ValueExpressionImpl ve = + new ValueExpressionImpl("", children[1], ctx.getFunctionMapper(), ctx.getVariableMapper(), null); // Build a LambdaExpression List<String> formalParameters = new ArrayList<>(); @@ -87,27 +85,22 @@ public class AstLambdaExpression extends SimpleNode { } /* - * This is a (possibly nested) lambda expression with one or more sets - * of parameters provided. + * This is a (possibly nested) lambda expression with one or more sets of parameters provided. * - * If there are more nested expressions than sets of parameters this may - * return a LambdaExpression. + * If there are more nested expressions than sets of parameters this may return a LambdaExpression. * - * If there are more sets of parameters than nested expressions an - * ELException will have been thrown by the check at the start of this - * method. + * If there are more sets of parameters than nested expressions an ELException will have been thrown by the + * check at the start of this method. */ // Always have to invoke the outer-most expression int methodParameterIndex = 2; - Object result = le.invoke(((AstMethodParameters) - children[methodParameterIndex]).getParameters(ctx)); + Object result = le.invoke(((AstMethodParameters) children[methodParameterIndex]).getParameters(ctx)); methodParameterIndex++; - while (result instanceof LambdaExpression && - methodParameterIndex < jjtGetNumChildren()) { - result = ((LambdaExpression) result).invoke(((AstMethodParameters) - children[methodParameterIndex]).getParameters(ctx)); + while (result instanceof LambdaExpression && methodParameterIndex < jjtGetNumChildren()) { + result = ((LambdaExpression) result) + .invoke(((AstMethodParameters) children[methodParameterIndex]).getParameters(ctx)); methodParameterIndex++; } diff --git a/java/org/apache/el/parser/AstLessThan.java b/java/org/apache/el/parser/AstLessThan.java index f7882dd702..e661da7cab 100644 --- a/java/org/apache/el/parser/AstLessThan.java +++ b/java/org/apache/el/parser/AstLessThan.java @@ -32,8 +32,7 @@ public final class AstLessThan extends BooleanNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); if (obj0 == null) { return Boolean.FALSE; diff --git a/java/org/apache/el/parser/AstLessThanEqual.java b/java/org/apache/el/parser/AstLessThanEqual.java index 2baadb6e4f..50a138123e 100644 --- a/java/org/apache/el/parser/AstLessThanEqual.java +++ b/java/org/apache/el/parser/AstLessThanEqual.java @@ -32,8 +32,7 @@ public final class AstLessThanEqual extends BooleanNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); if (obj0 == obj1) { diff --git a/java/org/apache/el/parser/AstLiteralExpression.java b/java/org/apache/el/parser/AstLiteralExpression.java index 7fe65c17a1..102d5da761 100644 --- a/java/org/apache/el/parser/AstLiteralExpression.java +++ b/java/org/apache/el/parser/AstLiteralExpression.java @@ -53,7 +53,7 @@ public final class AstLiteralExpression extends SimpleNode { if (c == '\\' && i + 2 < size) { char c1 = image.charAt(i + 1); char c2 = image.charAt(i + 2); - if ((c1 == '#' || c1 == '$') && c2 == '{') { + if ((c1 == '#' || c1 == '$') && c2 == '{') { c = c1; i++; } diff --git a/java/org/apache/el/parser/AstMapEntry.java b/java/org/apache/el/parser/AstMapEntry.java index 5a897dc097..c18874d6ac 100644 --- a/java/org/apache/el/parser/AstMapEntry.java +++ b/java/org/apache/el/parser/AstMapEntry.java @@ -17,10 +17,9 @@ /* Generated By:JJTree: Do not edit this line. AstMapEntry.java Version 4.3 */ package org.apache.el.parser; -public -class AstMapEntry extends SimpleNode { - public AstMapEntry(int id) { - super(id); - } +public class AstMapEntry extends SimpleNode { + public AstMapEntry(int id) { + super(id); + } } /* JavaCC - OriginalChecksum=6a7910e58a583371769800554113a8d3 (do not edit this line) */ diff --git a/java/org/apache/el/parser/AstMinus.java b/java/org/apache/el/parser/AstMinus.java index c31f93624d..10424a5d53 100644 --- a/java/org/apache/el/parser/AstMinus.java +++ b/java/org/apache/el/parser/AstMinus.java @@ -32,8 +32,7 @@ public final class AstMinus extends ArithmeticNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return ELArithmetic.subtract(obj0, obj1); diff --git a/java/org/apache/el/parser/AstMod.java b/java/org/apache/el/parser/AstMod.java index ee2f6267f6..22f3cdae3b 100644 --- a/java/org/apache/el/parser/AstMod.java +++ b/java/org/apache/el/parser/AstMod.java @@ -32,8 +32,7 @@ public final class AstMod extends ArithmeticNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return ELArithmetic.mod(obj0, obj1); diff --git a/java/org/apache/el/parser/AstMult.java b/java/org/apache/el/parser/AstMult.java index 2b5f860738..241c3365a8 100644 --- a/java/org/apache/el/parser/AstMult.java +++ b/java/org/apache/el/parser/AstMult.java @@ -32,8 +32,7 @@ public final class AstMult extends ArithmeticNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return ELArithmetic.multiply(obj0, obj1); diff --git a/java/org/apache/el/parser/AstNegative.java b/java/org/apache/el/parser/AstNegative.java index c2a540c7aa..0e8dfa3b1a 100644 --- a/java/org/apache/el/parser/AstNegative.java +++ b/java/org/apache/el/parser/AstNegative.java @@ -35,14 +35,12 @@ public final class AstNegative extends SimpleNode { } @Override - public Class<?> getType(EvaluationContext ctx) - throws ELException { + public Class<?> getType(EvaluationContext ctx) throws ELException { return Number.class; } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj = this.children[0].getValue(ctx); if (obj == null) { diff --git a/java/org/apache/el/parser/AstNot.java b/java/org/apache/el/parser/AstNot.java index 1a16180b4e..18a57d6df4 100644 --- a/java/org/apache/el/parser/AstNot.java +++ b/java/org/apache/el/parser/AstNot.java @@ -32,14 +32,12 @@ public final class AstNot extends SimpleNode { } @Override - public Class<?> getType(EvaluationContext ctx) - throws ELException { + public Class<?> getType(EvaluationContext ctx) throws ELException { return Boolean.class; } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj = this.children[0].getValue(ctx); Boolean b = ELSupport.coerceToBoolean(ctx, obj, true); return Boolean.valueOf(!b.booleanValue()); diff --git a/java/org/apache/el/parser/AstNotEqual.java b/java/org/apache/el/parser/AstNotEqual.java index 5f19904d24..c2211f33e8 100644 --- a/java/org/apache/el/parser/AstNotEqual.java +++ b/java/org/apache/el/parser/AstNotEqual.java @@ -32,8 +32,7 @@ public final class AstNotEqual extends BooleanNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return Boolean.valueOf(!ELSupport.equals(ctx, obj0, obj1)); diff --git a/java/org/apache/el/parser/AstNull.java b/java/org/apache/el/parser/AstNull.java index b9b28d95b1..4e5f456e7a 100644 --- a/java/org/apache/el/parser/AstNull.java +++ b/java/org/apache/el/parser/AstNull.java @@ -31,14 +31,12 @@ public final class AstNull extends SimpleNode { } @Override - public Class<?> getType(EvaluationContext ctx) - throws ELException { + public Class<?> getType(EvaluationContext ctx) throws ELException { return null; } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { return null; } } diff --git a/java/org/apache/el/parser/AstOr.java b/java/org/apache/el/parser/AstOr.java index a16a04cf40..d5e7d40120 100644 --- a/java/org/apache/el/parser/AstOr.java +++ b/java/org/apache/el/parser/AstOr.java @@ -32,8 +32,7 @@ public final class AstOr extends BooleanNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj = this.children[0].getValue(ctx); Boolean b = ELSupport.coerceToBoolean(ctx, obj, true); if (b.booleanValue()) { diff --git a/java/org/apache/el/parser/AstPlus.java b/java/org/apache/el/parser/AstPlus.java index 06510fdeb2..7c5a60a181 100644 --- a/java/org/apache/el/parser/AstPlus.java +++ b/java/org/apache/el/parser/AstPlus.java @@ -32,8 +32,7 @@ public final class AstPlus extends ArithmeticNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return ELArithmetic.add(obj0, obj1); diff --git a/java/org/apache/el/parser/AstString.java b/java/org/apache/el/parser/AstString.java index f701a17f77..5f7be26487 100644 --- a/java/org/apache/el/parser/AstString.java +++ b/java/org/apache/el/parser/AstString.java @@ -40,14 +40,12 @@ public final class AstString extends SimpleNode { } @Override - public Class<?> getType(EvaluationContext ctx) - throws ELException { + public Class<?> getType(EvaluationContext ctx) throws ELException { return String.class; } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { return this.getString(); } diff --git a/java/org/apache/el/parser/AstTrue.java b/java/org/apache/el/parser/AstTrue.java index 70543d98cd..7a5d7d4a06 100644 --- a/java/org/apache/el/parser/AstTrue.java +++ b/java/org/apache/el/parser/AstTrue.java @@ -31,8 +31,7 @@ public final class AstTrue extends BooleanNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { return Boolean.TRUE; } } diff --git a/java/org/apache/el/parser/AstValue.java b/java/org/apache/el/parser/AstValue.java index 2bd5205fdf..dd26d5ceb4 100644 --- a/java/org/apache/el/parser/AstValue.java +++ b/java/org/apache/el/parser/AstValue.java @@ -59,8 +59,7 @@ public final class AstValue extends SimpleNode { ctx.setPropertyResolved(false); Class<?> result = ctx.getELResolver().getType(ctx, t.base, t.property); if (!ctx.isPropertyResolved()) { - throw new PropertyNotFoundException(MessageFactory.get( - "error.resolver.unhandled", t.base, t.property)); + throw new PropertyNotFoundException(MessageFactory.get("error.resolver.unhandled", t.base, t.property)); } return result; } @@ -71,8 +70,8 @@ public final class AstValue extends SimpleNode { // if our base is null (we know there are more properties to evaluate) if (base == null) { - throw new PropertyNotFoundException(MessageFactory.get( - "error.unreachable.base", this.children[0].getImage())); + throw new PropertyNotFoundException( + MessageFactory.get("error.unreachable.base", this.children[0].getImage())); } // set up our start/end @@ -83,24 +82,19 @@ public final class AstValue extends SimpleNode { // Evaluate any properties or methods before our target ELResolver resolver = ctx.getELResolver(); while (i < propCount) { - if (i + 2 < propCount && - this.children[i + 1] instanceof AstMethodParameters) { + if (i + 2 < propCount && this.children[i + 1] instanceof AstMethodParameters) { // Method call not at end of expression - base = resolver.invoke(ctx, base, - this.children[i].getValue(ctx), null, - ((AstMethodParameters) - this.children[i + 1]).getParameters(ctx)); + base = resolver.invoke(ctx, base, this.children[i].getValue(ctx), null, + ((AstMethodParameters) this.children[i + 1]).getParameters(ctx)); i += 2; - } else if (i + 2 == propCount && - this.children[i + 1] instanceof AstMethodParameters) { + } else if (i + 2 == propCount && this.children[i + 1] instanceof AstMethodParameters) { // Method call at end of expression ctx.setPropertyResolved(false); property = this.children[i].getValue(ctx); i += 2; if (property == null) { - throw new PropertyNotFoundException(MessageFactory.get( - "error.unreachable.property", property)); + throw new PropertyNotFoundException(MessageFactory.get("error.unreachable.property", property)); } } else if (i + 1 < propCount) { // Object with property not at end of expression @@ -116,13 +110,11 @@ public final class AstValue extends SimpleNode { i++; if (property == null) { - throw new PropertyNotFoundException(MessageFactory.get( - "error.unreachable.property", property)); + throw new PropertyNotFoundException(MessageFactory.get("error.unreachable.property", property)); } } if (base == null) { - throw new PropertyNotFoundException(MessageFactory.get( - "error.unreachable.property", property)); + throw new PropertyNotFoundException(MessageFactory.get("error.unreachable.property", property)); } } @@ -141,24 +133,19 @@ public final class AstValue extends SimpleNode { ELResolver resolver = ctx.getELResolver(); while (base != null && i < propCount) { suffix = this.children[i].getValue(ctx); - if (i + 1 < propCount && - (this.children[i+1] instanceof AstMethodParameters)) { - AstMethodParameters mps = - (AstMethodParameters) this.children[i+1]; - if (base instanceof Optional && "orElseGet".equals(suffix) && - mps.jjtGetNumChildren() == 1) { + if (i + 1 < propCount && (this.children[i + 1] instanceof AstMethodParameters)) { + AstMethodParameters mps = (AstMethodParameters) this.children[i + 1]; + if (base instanceof Optional && "orElseGet".equals(suffix) && mps.jjtGetNumChildren() == 1) { Node paramFoOptional = mps.jjtGetChild(0); if (!(paramFoOptional instanceof AstLambdaExpression || paramFoOptional instanceof LambdaExpression)) { - throw new ELException(MessageFactory.get( - "stream.optional.paramNotLambda", suffix)); + throw new ELException(MessageFactory.get("stream.optional.paramNotLambda", suffix)); } } // This is a method Object[] paramValues = mps.getParameters(ctx); - base = resolver.invoke(ctx, base, suffix, - getTypesFromValues(paramValues), paramValues); - i+=2; + base = resolver.invoke(ctx, base, suffix, getTypesFromValues(paramValues), paramValues); + i += 2; } else { // This is a property if (suffix == null) { @@ -171,8 +158,7 @@ public final class AstValue extends SimpleNode { } } if (!ctx.isPropertyResolved()) { - throw new PropertyNotFoundException(MessageFactory.get( - "error.resolver.unhandled", base, suffix)); + throw new PropertyNotFoundException(MessageFactory.get("error.resolver.unhandled", base, suffix)); } return base; } @@ -181,42 +167,35 @@ public final class AstValue extends SimpleNode { public boolean isReadOnly(EvaluationContext ctx) throws ELException { Target t = getTarget(ctx); ctx.setPropertyResolved(false); - boolean result = - ctx.getELResolver().isReadOnly(ctx, t.base, t.property); + boolean result = ctx.getELResolver().isReadOnly(ctx, t.base, t.property); if (!ctx.isPropertyResolved()) { - throw new PropertyNotFoundException(MessageFactory.get( - "error.resolver.unhandled", t.base, t.property)); + throw new PropertyNotFoundException(MessageFactory.get("error.resolver.unhandled", t.base, t.property)); } return result; } @Override - public void setValue(EvaluationContext ctx, Object value) - throws ELException { + public void setValue(EvaluationContext ctx, Object value) throws ELException { Target t = getTarget(ctx); ctx.setPropertyResolved(false); ELResolver resolver = ctx.getELResolver(); // coerce to the expected type Class<?> targetClass = resolver.getType(ctx, t.base, t.property); - resolver.setValue(ctx, t.base, t.property, - ELSupport.coerceToType(ctx, value, targetClass)); + resolver.setValue(ctx, t.base, t.property, ELSupport.coerceToType(ctx, value, targetClass)); if (!ctx.isPropertyResolved()) { - throw new PropertyNotFoundException(MessageFactory.get( - "error.resolver.unhandled", t.base, t.property)); + throw new PropertyNotFoundException(MessageFactory.get("error.resolver.unhandled", t.base, t.property)); } } @Override // Interface el.parser.Node uses raw types (and is auto-generated) - public MethodInfo getMethodInfo(EvaluationContext ctx, - @SuppressWarnings("rawtypes") Class[] paramTypes) + public MethodInfo getMethodInfo(EvaluationContext ctx, @SuppressWarnings("rawtypes") Class[] paramTypes) throws ELException { Target t = getTarget(ctx); Class<?>[] types = null; if (isParametersProvided()) { - Object[] values = ((AstMethodParameters) this.jjtGetChild( - this.jjtGetNumChildren() - 1)).getParameters(ctx); + Object[] values = ((AstMethodParameters) this.jjtGetChild(this.jjtGetNumChildren() - 1)).getParameters(ctx); types = getTypesFromValues(values); } else { types = paramTypes; @@ -227,17 +206,15 @@ public final class AstValue extends SimpleNode { @Override // Interface el.parser.Node uses a raw type (and is auto-generated) - public Object invoke(EvaluationContext ctx, - @SuppressWarnings("rawtypes") Class[] paramTypes, - Object[] paramValues) throws ELException { + public Object invoke(EvaluationContext ctx, @SuppressWarnings("rawtypes") Class[] paramTypes, Object[] paramValues) + throws ELException { Target t = getTarget(ctx); Method m = null; Object[] values = null; Class<?>[] types = null; if (isParametersProvided()) { - values = ((AstMethodParameters) this.jjtGetChild( - this.jjtGetNumChildren() - 1)).getParameters(ctx); + values = ((AstMethodParameters) this.jjtGetChild(this.jjtGetNumChildren() - 1)).getParameters(ctx); types = getTypesFromValues(values); } else { values = paramValues; @@ -273,8 +250,7 @@ public final class AstValue extends SimpleNode { Object[] values = null; Class<?>[] types = null; if (isParametersProvided()) { - values = ((AstMethodParameters) this.jjtGetChild( - this.jjtGetNumChildren() - 1)).getParameters(ctx); + values = ((AstMethodParameters) this.jjtGetChild(this.jjtGetNumChildren() - 1)).getParameters(ctx); types = getTypesFromValues(values); } m = ReflectionUtil.getMethod(ctx, t.base, t.property, types, values); @@ -295,19 +271,18 @@ public final class AstValue extends SimpleNode { int paramCount = types.length; if (m.isVarArgs() && paramCount > 1 && (src == null || paramCount > src.length) || - !m.isVarArgs() && (paramCount > 0 && src == null || - src != null && src.length != paramCount)) { + !m.isVarArgs() && (paramCount > 0 && src == null || src != null && src.length != paramCount)) { String srcCount = null; if (src != null) { srcCount = Integer.toString(src.length); } String msg; if (m.isVarArgs()) { - msg = MessageFactory.get("error.invoke.tooFewParams", - m.getName(), srcCount, Integer.toString(paramCount)); + msg = MessageFactory.get("error.invoke.tooFewParams", m.getName(), srcCount, + Integer.toString(paramCount)); } else { - msg = MessageFactory.get("error.invoke.wrongParams", - m.getName(), srcCount, Integer.toString(paramCount)); + msg = MessageFactory.get("error.invoke.wrongParams", m.getName(), srcCount, + Integer.toString(paramCount)); } throw new IllegalArgumentException(msg); } @@ -327,15 +302,13 @@ public final class AstValue extends SimpleNode { if (m.isVarArgs()) { Class<?> varArgType = m.getParameterTypes()[paramCount - 1].getComponentType(); - Object[] varArgs = - (Object[]) Array.newInstance(varArgType, src.length - (paramCount - 1)); - for (int i = 0; i < src.length - (paramCount - 1); i ++) { + Object[] varArgs = (Object[]) Array.newInstance(varArgType, src.length - (paramCount - 1)); + for (int i = 0; i < src.length - (paramCount - 1); i++) { varArgs[i] = ELSupport.coerceToType(ctx, src[paramCount - 1 + i], varArgType); } dest[paramCount - 1] = varArgs; } else { - dest[paramCount - 1] = ELSupport.coerceToType( - ctx, src[paramCount - 1], types[paramCount - 1]); + dest[paramCount - 1] = ELSupport.coerceToType(ctx, src[paramCount - 1], types[paramCount - 1]); } return dest; @@ -364,8 +337,7 @@ public final class AstValue extends SimpleNode { @Override public ValueReference getValueReference(EvaluationContext ctx) { // Check this is a reference to a base and a property - if (this.children.length > 2 && - this.jjtGetChild(2) instanceof AstMethodParameters) { + if (this.children.length > 2 && this.jjtGetChild(2) instanceof AstMethodParameters) { // This is a method call return null; } diff --git a/java/org/apache/el/parser/BooleanNode.java b/java/org/apache/el/parser/BooleanNode.java index 3cd042ada3..30cb5492a7 100644 --- a/java/org/apache/el/parser/BooleanNode.java +++ b/java/org/apache/el/parser/BooleanNode.java @@ -30,8 +30,7 @@ public abstract class BooleanNode extends SimpleNode { } @Override - public Class<?> getType(EvaluationContext ctx) - throws ELException { + public Class<?> getType(EvaluationContext ctx) throws ELException { return Boolean.class; } } diff --git a/java/org/apache/el/stream/Stream.java b/java/org/apache/el/stream/Stream.java index 4f9241e488..f419f1dca5 100644 --- a/java/org/apache/el/stream/Stream.java +++ b/java/org/apache/el/stream/Stream.java @@ -48,8 +48,7 @@ public class Stream { protected void findNext() { while (iterator.hasNext()) { Object obj = iterator.next(); - if (ELSupport.coerceToBoolean(null, le.invoke(obj), - true).booleanValue()) { + if (ELSupport.coerceToBoolean(null, le.invoke(obj), true).booleanValue()) { next = obj; foundNext = true; break; @@ -83,8 +82,7 @@ public class Stream { @Override protected void findNext() { - while (iterator.hasNext() || - (inner != null && inner.hasNext())) { + while (iterator.hasNext() || (inner != null && inner.hasNext())) { if (inner == null || !inner.hasNext()) { inner = ((Stream) le.invoke(iterator.next())).iterator; } @@ -343,7 +341,7 @@ public class Stream { while (iterator.hasNext()) { iterator.next(); - count ++; + count++; } return Long.valueOf(count); @@ -413,8 +411,7 @@ public class Stream { if ((obj instanceof Comparable)) { result = (Comparable) obj; } else { - throw new ELException( - MessageFactory.get("stream.compare.notComparable")); + throw new ELException(MessageFactory.get("stream.compare.notComparable")); } } @@ -427,8 +424,7 @@ public class Stream { result = (Comparable) obj; } } else { - throw new ELException( - MessageFactory.get("stream.compare.notComparable")); + throw new ELException(MessageFactory.get("stream.compare.notComparable")); } } @@ -450,11 +446,9 @@ public class Stream { while (iterator.hasNext()) { Object obj = iterator.next(); - if (isMax && ELSupport.coerceToNumber(null, le.invoke(obj, result), - Integer.class).intValue() > 0) { + if (isMax && ELSupport.coerceToNumber(null, le.invoke(obj, result), Integer.class).intValue() > 0) { result = obj; - } else if (!isMax && ELSupport.coerceToNumber(null, le.invoke(obj, result), - Integer.class).intValue() < 0) { + } else if (!isMax && ELSupport.coerceToNumber(null, le.invoke(obj, result), Integer.class).intValue() < 0) { result = obj; } } @@ -467,8 +461,7 @@ public class Stream { } - private static class LambdaExpressionComparator - implements Comparator<Object> { + private static class LambdaExpressionComparator implements Comparator<Object> { private final LambdaExpression le; @@ -478,8 +471,7 @@ public class Stream { @Override public int compare(Object o1, Object o2) { - return ELSupport.coerceToNumber( - null, le.invoke(o1, o2), Integer.class).intValue(); + return ELSupport.coerceToNumber(null, le.invoke(o1, o2), Integer.class).intValue(); } } diff --git a/java/org/apache/el/stream/StreamELResolverImpl.java b/java/org/apache/el/stream/StreamELResolverImpl.java index 46bff5ba98..b72daff65c 100644 --- a/java/org/apache/el/stream/StreamELResolverImpl.java +++ b/java/org/apache/el/stream/StreamELResolverImpl.java @@ -38,8 +38,7 @@ public class StreamELResolverImpl extends ELResolver { } @Override - public void setValue(ELContext context, Object base, Object property, - Object value) { + public void setValue(ELContext context, Object base, Object property, Object value) { // NO-OP } @@ -50,8 +49,7 @@ public class StreamELResolverImpl extends ELResolver { @Deprecated(forRemoval = true, since = "Tomcat 10.1.0") @Override - public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, - Object base) { + public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) { return null; } @@ -61,8 +59,7 @@ public class StreamELResolverImpl extends ELResolver { } @Override - public Object invoke(ELContext context, Object base, Object method, - Class<?>[] paramTypes, Object[] params) { + public Object invoke(ELContext context, Object base, Object method, Class<?>[] paramTypes, Object[] params) { if ("stream".equals(method) && params.length == 0) { if (base.getClass().isArray()) { diff --git a/java/org/apache/el/util/ConcurrentCache.java b/java/org/apache/el/util/ConcurrentCache.java index 1be17abaa8..ae37cfb9e6 100644 --- a/java/org/apache/el/util/ConcurrentCache.java +++ b/java/org/apache/el/util/ConcurrentCache.java @@ -20,7 +20,7 @@ import java.util.Map; import java.util.WeakHashMap; import java.util.concurrent.ConcurrentHashMap; -public final class ConcurrentCache<K,V> { +public final class ConcurrentCache<K, V> { private final int size; diff --git a/java/org/apache/el/util/ExceptionUtils.java b/java/org/apache/el/util/ExceptionUtils.java index d8a76ff184..798fd36a40 100644 --- a/java/org/apache/el/util/ExceptionUtils.java +++ b/java/org/apache/el/util/ExceptionUtils.java @@ -25,8 +25,8 @@ package org.apache.el.util; public class ExceptionUtils { /** - * Checks whether the supplied Throwable is one that needs to be - * rethrown and swallows all others. + * Checks whether the supplied Throwable is one that needs to be rethrown and swallows all others. + * * @param t the Throwable to check */ public static void handleThrowable(Throwable t) { @@ -45,10 +45,9 @@ public class ExceptionUtils { /** - * NO-OP method provided to enable simple pre-loading of this class. Since - * the class is used extensively in error handling, it is prudent to - * pre-load it to avoid any failure to load this class masking the true - * problem during error handling. + * NO-OP method provided to enable simple pre-loading of this class. Since the class is used extensively in error + * handling, it is prudent to pre-load it to avoid any failure to load this class masking the true problem during + * error handling. */ public static void preload() { // NO-OP diff --git a/java/org/apache/el/util/ReflectionUtil.java b/java/org/apache/el/util/ReflectionUtil.java index 226fc2af7d..a94a73fd42 100644 --- a/java/org/apache/el/util/ReflectionUtil.java +++ b/java/org/apache/el/util/ReflectionUtil.java @@ -40,12 +40,11 @@ import org.apache.el.lang.EvaluationContext; */ public class ReflectionUtil { - protected static final String[] PRIMITIVE_NAMES = new String[] { "boolean", - "byte", "char", "double", "float", "int", "long", "short", "void" }; + protected static final String[] PRIMITIVE_NAMES = + new String[] { "boolean", "byte", "char", "double", "float", "int", "long", "short", "void" }; - protected static final Class<?>[] PRIMITIVES = new Class[] { boolean.class, - byte.class, char.class, double.class, float.class, int.class, - long.class, short.class, Void.TYPE }; + protected static final Class<?>[] PRIMITIVES = new Class[] { boolean.class, byte.class, char.class, double.class, + float.class, int.class, long.class, short.class, Void.TYPE }; private ReflectionUtil() { super(); @@ -80,10 +79,12 @@ public class ReflectionUtil { /** * Converts an array of Class names to Class types. - * @param s The array of class names - * @return An array of Class instance where the element at index i in the - * result is an instance of the class with the name at index i in - * the input + * + * @param s The array of class names + * + * @return An array of Class instance where the element at index i in the result is an instance of the class with + * the name at index i in the input + * * @throws ClassNotFoundException If a class of a given name cannot be found */ public static Class<?>[] toTypeArray(String[] s) throws ClassNotFoundException { @@ -99,9 +100,11 @@ public class ReflectionUtil { /** * Converts an array of Class types to Class names. + * * @param c The array of class instances - * @return An array of Class names where the element at index i in the - * result is the name of the class instance at index i in the input + * + * @return An array of Class names where the element at index i in the result is the name of the class instance at + * index i in the input */ public static String[] toTypeNameArray(Class<?>[] c) { if (c == null) { @@ -116,32 +119,30 @@ public class ReflectionUtil { /** * Returns a method based on the criteria. - * @param ctx the context in which the expression is being evaluated - * @param base the object that owns the method - * @param property the name of the method - * @param paramTypes the parameter types to use + * + * @param ctx the context in which the expression is being evaluated + * @param base the object that owns the method + * @param property the name of the method + * @param paramTypes the parameter types to use * @param paramValues the parameter values + * * @return the method specified - * @throws MethodNotFoundException If a method cannot be found that matches - * the given criteria + * + * @throws MethodNotFoundException If a method cannot be found that matches the given criteria */ /* - * This class duplicates code in jakarta.el.Util. When making changes keep - * the code in sync. + * This class duplicates code in jakarta.el.Util. When making changes keep the code in sync. */ @SuppressWarnings("null") - public static Method getMethod(EvaluationContext ctx, Object base, Object property, - Class<?>[] paramTypes, Object[] paramValues) - throws MethodNotFoundException { + public static Method getMethod(EvaluationContext ctx, Object base, Object property, Class<?>[] paramTypes, + Object[] paramValues) throws MethodNotFoundException { if (base == null || property == null) { - throw new MethodNotFoundException(MessageFactory.get( - "error.method.notfound", base, property, - paramString(paramTypes))); + throw new MethodNotFoundException( + MessageFactory.get("error.method.notfound", base, property, paramString(paramTypes))); } - String methodName = (property instanceof String) ? (String) property - : property.toString(); + String methodName = (property instanceof String) ? (String) property : property.toString(); int paramCount; if (paramTypes == null) { @@ -168,17 +169,16 @@ public class ReflectionUtil { // Method has wrong number of parameters continue; } - if (m.isVarArgs() && paramCount < mParamCount -1) { + if (m.isVarArgs() && paramCount < mParamCount - 1) { // Method has wrong number of parameters continue; } - if (m.isVarArgs() && paramCount == mParamCount && paramValues != null && - paramValues.length > paramCount && !paramTypes[mParamCount -1].isArray()) { + if (m.isVarArgs() && paramCount == mParamCount && paramValues != null && paramValues.length > paramCount && + !paramTypes[mParamCount - 1].isArray()) { // Method arguments don't match continue; } - if (m.isVarArgs() && paramCount > mParamCount && paramValues != null && - paramValues.length != paramCount) { + if (m.isVarArgs() && paramCount > mParamCount && paramValues != null && paramValues.length != paramCount) { // Might match a different varargs method continue; } @@ -254,15 +254,14 @@ public class ReflectionUtil { if (exactMatch == paramCount && varArgsMatch == 0) { Method result = getMethod(base.getClass(), base, m); if (result == null) { - throw new MethodNotFoundException(MessageFactory.get( - "error.method.notfound", base, property, - paramString(paramTypes))); + throw new MethodNotFoundException( + MessageFactory.get("error.method.notfound", base, property, paramString(paramTypes))); } return result; } - candidates.put(m, new MatchResult( - m.isVarArgs(), exactMatch, assignableMatch, coercibleMatch, varArgsMatch, m.isBridge())); + candidates.put(m, new MatchResult(m.isVarArgs(), exactMatch, assignableMatch, coercibleMatch, varArgsMatch, + m.isBridge())); } // Look for the method that has the highest number of parameters where @@ -270,7 +269,7 @@ public class ReflectionUtil { MatchResult bestMatch = new MatchResult(true, 0, 0, 0, 0, true); Method match = null; boolean multiple = false; - for (Map.Entry<Method, MatchResult> entry : candidates.entrySet()) { + for (Map.Entry<Method,MatchResult> entry : candidates.entrySet()) { int cmp = entry.getValue().compareTo(bestMatch); if (cmp > 0 || match == null) { bestMatch = entry.getValue(); @@ -292,34 +291,29 @@ public class ReflectionUtil { if (match == null) { // If multiple methods have the same matching number of parameters // the match is ambiguous so throw an exception - throw new MethodNotFoundException(MessageFactory.get( - "error.method.ambiguous", base, property, - paramString(paramTypes))); - } + throw new MethodNotFoundException( + MessageFactory.get("error.method.ambiguous", base, property, paramString(paramTypes))); + } } // Handle case where no match at all was found if (match == null) { - throw new MethodNotFoundException(MessageFactory.get( - "error.method.notfound", base, property, - paramString(paramTypes))); + throw new MethodNotFoundException( + MessageFactory.get("error.method.notfound", base, property, paramString(paramTypes))); } Method result = getMethod(base.getClass(), base, match); if (result == null) { - throw new MethodNotFoundException(MessageFactory.get( - "error.method.notfound", base, property, - paramString(paramTypes))); + throw new MethodNotFoundException( + MessageFactory.get("error.method.notfound", base, property, paramString(paramTypes))); } return result; } /* - * This class duplicates code in jakarta.el.Util. When making changes keep - * the code in sync. + * This class duplicates code in jakarta.el.Util. When making changes keep the code in sync. */ - private static Method resolveAmbiguousMethod(Set<Method> candidates, - Class<?>[] paramTypes) { + private static Method resolveAmbiguousMethod(Set<Method> candidates, Class<?>[] paramTypes) { // Identify which parameter isn't an exact match Method m = candidates.iterator().next(); @@ -340,12 +334,11 @@ public class ReflectionUtil { } for (Method c : candidates) { - if (c.getParameterTypes()[nonMatchIndex] == - paramTypes[nonMatchIndex]) { - // Methods have different non-matching parameters - // Result is ambiguous - return null; - } + if (c.getParameterTypes()[nonMatchIndex] == paramTypes[nonMatchIndex]) { + // Methods have different non-matching parameters + // Result is ambiguous + return null; + } } // Can't be null @@ -365,8 +358,7 @@ public class ReflectionUtil { if (Number.class.isAssignableFrom(nonMatchClass)) { for (Method c : candidates) { Class<?> candidateType = c.getParameterTypes()[nonMatchIndex]; - if (Number.class.isAssignableFrom(candidateType) || - candidateType.isPrimitive()) { + if (Number.class.isAssignableFrom(candidateType) || candidateType.isPrimitive()) { if (match == null) { match = c; } else { @@ -383,8 +375,7 @@ public class ReflectionUtil { /* - * This class duplicates code in jakarta.el.Util. When making changes keep - * the code in sync. + * This class duplicates code in jakarta.el.Util. When making changes keep the code in sync. */ private static boolean isAssignableFrom(Class<?> src, Class<?> target) { // src will always be an object @@ -421,12 +412,11 @@ public class ReflectionUtil { /* - * This class duplicates code in jakarta.el.Util. When making changes keep - * the code in sync. + * This class duplicates code in jakarta.el.Util. When making changes keep the code in sync. */ private static boolean isCoercibleFrom(EvaluationContext ctx, Object src, Class<?> target) { // TODO: This isn't pretty but it works. Significant refactoring would - // be required to avoid the exception. + // be required to avoid the exception. try { ELSupport.coerceToType(ctx, src, target); } catch (ELException e) { @@ -437,13 +427,11 @@ public class ReflectionUtil { /* - * This class duplicates code in jakarta.el.Util. When making changes keep - * the code in sync. + * This class duplicates code in jakarta.el.Util. When making changes keep the code in sync. */ private static Method getMethod(Class<?> type, Object base, Method m) { - if (m == null || - (Modifier.isPublic(type.getModifiers()) && - (Modifier.isStatic(m.getModifiers()) && m.canAccess(null) || m.canAccess(base)))) { + if (m == null || (Modifier.isPublic(type.getModifiers()) && + (Modifier.isStatic(m.getModifiers()) && m.canAccess(null) || m.canAccess(base)))) { return m; } Class<?>[] interfaces = type.getInterfaces(); @@ -516,8 +504,7 @@ public class ReflectionUtil { /* - * This class duplicates code in jakarta.el.Util. When making changes keep - * the code in sync. + * This class duplicates code in jakarta.el.Util. When making changes keep the code in sync. */ private static class MatchResult implements Comparable<MatchResult> { @@ -591,14 +578,13 @@ public class ReflectionUtil { @Override public boolean equals(Object o) { - return o == this || (null != o && - this.getClass().equals(o.getClass()) && - ((MatchResult)o).getExactCount() == this.getExactCount() && - ((MatchResult)o).getAssignableCount() == this.getAssignableCount() && - ((MatchResult)o).getCoercible() == this.getCoercible() && - ((MatchResult)o).getVarArgsCount() == this.getVarArgsCount() && - ((MatchResult)o).isVarArgs() == this.isVarArgs() && - ((MatchResult)o).isBridge() == this.isBridge()); + return o == this || (null != o && this.getClass().equals(o.getClass()) && + ((MatchResult) o).getExactCount() == this.getExactCount() && + ((MatchResult) o).getAssignableCount() == this.getAssignableCount() && + ((MatchResult) o).getCoercible() == this.getCoercible() && + ((MatchResult) o).getVarArgsCount() == this.getVarArgsCount() && + ((MatchResult) o).isVarArgs() == this.isVarArgs() && + ((MatchResult) o).isBridge() == this.isBridge()); } @Override diff --git a/java/org/apache/el/util/Validation.java b/java/org/apache/el/util/Validation.java index a27e75f26e..4eab1d8ea6 100644 --- a/java/org/apache/el/util/Validation.java +++ b/java/org/apache/el/util/Validation.java @@ -22,29 +22,24 @@ import java.security.PrivilegedAction; public class Validation { // Java keywords, boolean literals & the null literal in alphabetical order - private static final String invalidIdentifiers[] = { "abstract", "assert", - "boolean", "break", "byte", "case", "catch", "char", "class", "const", - "continue", "default", "do", "double", "else", "enum", "extends", - "false", "final", "finally", "float", "for", "goto", "if", "implements", - "import", "instanceof", "int", "interface", "long", "native", "new", - "null", "package", "private", "protected", "public", "return", "short", - "static", "strictfp", "super", "switch", "synchronized", "this", - "throw", "throws", "transient", "true", "try", "void", "volatile", - "while" }; + private static final String invalidIdentifiers[] = { "abstract", "assert", "boolean", "break", "byte", "case", + "catch", "char", "class", "const", "continue", "default", "do", "double", "else", "enum", "extends", + "false", "final", "finally", "float", "for", "goto", "if", "implements", "import", "instanceof", "int", + "interface", "long", "native", "new", "null", "package", "private", "protected", "public", "return", + "short", "static", "strictfp", "super", "switch", "synchronized", "this", "throw", "throws", "transient", + "true", "try", "void", "volatile", "while" }; - private static final boolean IS_SECURITY_ENABLED = - (System.getSecurityManager() != null); + private static final boolean IS_SECURITY_ENABLED = (System.getSecurityManager() != null); private static final boolean SKIP_IDENTIFIER_CHECK; static { String skipIdentifierCheckStr; if (IS_SECURITY_ENABLED) { - skipIdentifierCheckStr = AccessController.doPrivileged( - (PrivilegedAction<String>) () -> System.getProperty("org.apache.el.parser.SKIP_IDENTIFIER_CHECK", "false")); + skipIdentifierCheckStr = AccessController.doPrivileged((PrivilegedAction<String>) () -> System + .getProperty("org.apache.el.parser.SKIP_IDENTIFIER_CHECK", "false")); } else { - skipIdentifierCheckStr = System.getProperty( - "org.apache.el.parser.SKIP_IDENTIFIER_CHECK", "false"); + skipIdentifierCheckStr = System.getProperty("org.apache.el.parser.SKIP_IDENTIFIER_CHECK", "false"); } SKIP_IDENTIFIER_CHECK = Boolean.parseBoolean(skipIdentifierCheckStr); } @@ -55,14 +50,12 @@ public class Validation { } /** - * Test whether a string is a Java identifier. Note that the behaviour of - * this method depend on the system property + * Test whether a string is a Java identifier. Note that the behaviour of this method depend on the system property * {@code org.apache.el.parser.SKIP_IDENTIFIER_CHECK} * * @param key The string to test * - * @return {@code true} if the provided String should be treated as a Java - * identifier, otherwise false + * @return {@code true} if the provided String should be treated as a Java identifier, otherwise false */ public static boolean isIdentifier(String key) { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org