This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit a29949e3e862acd0ced0b98031242804d56a0266 Author: Mark Thomas <ma...@apache.org> AuthorDate: Wed Feb 22 19:44:11 2023 +0000 Clean-up. Reformatting. No functional change. --- java/javax/el/ArrayELResolver.java | 22 ++--- java/javax/el/BeanELResolver.java | 65 +++++++------- java/javax/el/BeanNameELResolver.java | 12 +-- java/javax/el/BeanNameResolver.java | 18 ++-- java/javax/el/CompositeELResolver.java | 3 +- java/javax/el/ELContext.java | 41 ++++----- java/javax/el/ELContextListener.java | 1 - java/javax/el/ELException.java | 15 ++-- java/javax/el/ELManager.java | 8 +- java/javax/el/ELProcessor.java | 92 ++++++++------------ java/javax/el/ELResolver.java | 126 +++++++++++----------------- java/javax/el/EvaluationListener.java | 3 +- java/javax/el/ExpressionFactory.java | 112 ++++++++++--------------- java/javax/el/ImportHandler.java | 68 +++++++-------- java/javax/el/JreCompat.java | 15 ++-- java/javax/el/LambdaExpression.java | 17 ++-- java/javax/el/ListELResolver.java | 17 ++-- java/javax/el/MapELResolver.java | 16 ++-- java/javax/el/MethodExpression.java | 40 ++++----- java/javax/el/ResourceBundleELResolver.java | 13 ++- java/javax/el/StandardELContext.java | 33 +++----- java/javax/el/StaticFieldELResolver.java | 47 ++++------- java/javax/el/TypeConverter.java | 9 +- java/javax/el/Util.java | 118 +++++++++++--------------- java/javax/el/ValueExpression.java | 58 +++++-------- 25 files changed, 381 insertions(+), 588 deletions(-) diff --git a/java/javax/el/ArrayELResolver.java b/java/javax/el/ArrayELResolver.java index 9d7b86156c..dac4cd3d01 100644 --- a/java/javax/el/ArrayELResolver.java +++ b/java/javax/el/ArrayELResolver.java @@ -38,8 +38,7 @@ public class ArrayELResolver extends ELResolver { /** * Creates an instance of the standard array resolver. * - * @param readOnly {@code true} if the created instance should be read-only - * otherwise false. + * @param readOnly {@code true} if the created instance should be read-only otherwise false. */ public ArrayELResolver(boolean readOnly) { this.readOnly = readOnly; @@ -80,24 +79,21 @@ public class ArrayELResolver 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) { Objects.requireNonNull(context); if (base != null && base.getClass().isArray()) { context.setPropertyResolved(base, property); if (this.readOnly) { - throw new PropertyNotWritableException(Util.message(context, - "resolverNotWritable", base.getClass().getName())); + throw new PropertyNotWritableException( + Util.message(context, "resolverNotWritable", base.getClass().getName())); } int idx = coerce(property); checkBounds(base, idx); - if (value != null && !Util.isAssignableFrom(value.getClass(), - base.getClass().getComponentType())) { - throw new ClassCastException(Util.message(context, - "objectNotAssignable", value.getClass().getName(), + if (value != null && !Util.isAssignableFrom(value.getClass(), base.getClass().getComponentType())) { + throw new ClassCastException(Util.message(context, "objectNotAssignable", value.getClass().getName(), base.getClass().getComponentType().getName())); } Array.set(base, idx, value); @@ -136,8 +132,7 @@ public class ArrayELResolver extends ELResolver { private static void checkBounds(Object base, int idx) { if (idx < 0 || idx >= Array.getLength(base)) { - throw new PropertyNotFoundException( - new ArrayIndexOutOfBoundsException(idx).getMessage()); + throw new PropertyNotFoundException(new ArrayIndexOutOfBoundsException(idx).getMessage()); } } @@ -154,8 +149,7 @@ public class ArrayELResolver extends ELResolver { if (property instanceof String) { return Integer.parseInt((String) property); } - throw new IllegalArgumentException(property != null ? - property.toString() : "null"); + throw new IllegalArgumentException(property != null ? property.toString() : "null"); } } diff --git a/java/javax/el/BeanELResolver.java b/java/javax/el/BeanELResolver.java index 647bbb1f80..b9798dbc20 100644 --- a/java/javax/el/BeanELResolver.java +++ b/java/javax/el/BeanELResolver.java @@ -45,14 +45,13 @@ public class BeanELResolver extends ELResolver { if (System.getSecurityManager() == null) { CACHE_SIZE = Integer.getInteger(CACHE_SIZE_PROP, 1000).intValue(); } else { - CACHE_SIZE = AccessController.doPrivileged( - new PrivilegedAction<Integer>() { + CACHE_SIZE = AccessController.doPrivileged(new PrivilegedAction<Integer>() { - @Override - public Integer run() { - return Integer.getInteger(CACHE_SIZE_PROP, 1000); - } - }).intValue(); + @Override + public Integer run() { + return Integer.getInteger(CACHE_SIZE_PROP, 1000); + } + }).intValue(); } } @@ -70,8 +69,7 @@ public class BeanELResolver extends ELResolver { /** * Creates an instance of the standard JavaBean resolver. * - * @param readOnly {@code true} if the created instance should be read-only - * otherwise false. + * @param readOnly {@code true} if the created instance should be read-only otherwise false. */ public BeanELResolver(boolean readOnly) { this.readOnly = readOnly; @@ -102,16 +100,15 @@ public class BeanELResolver extends ELResolver { } catch (InvocationTargetException e) { Throwable cause = e.getCause(); Util.handleThrowable(cause); - throw new ELException(Util.message(context, "propertyReadError", - base.getClass().getName(), property.toString()), cause); + throw new ELException( + Util.message(context, "propertyReadError", base.getClass().getName(), property.toString()), cause); } catch (Exception e) { throw new ELException(e); } } @Override - public void setValue(ELContext context, Object base, Object property, - Object value) { + public void setValue(ELContext context, Object base, Object property, Object value) { Objects.requireNonNull(context); if (base == null || property == null) { return; @@ -120,8 +117,8 @@ public class BeanELResolver extends ELResolver { context.setPropertyResolved(base, property); if (this.readOnly) { - throw new PropertyNotWritableException(Util.message(context, - "resolverNotWritable", base.getClass().getName())); + throw new PropertyNotWritableException( + Util.message(context, "resolverNotWritable", base.getClass().getName())); } Method m = this.property(context, base, property).write(context, base); @@ -130,8 +127,8 @@ public class BeanELResolver extends ELResolver { } catch (InvocationTargetException e) { Throwable cause = e.getCause(); Util.handleThrowable(cause); - throw new ELException(Util.message(context, "propertyWriteError", - base.getClass().getName(), property.toString()), cause); + throw new ELException( + Util.message(context, "propertyWriteError", base.getClass().getName(), property.toString()), cause); } catch (Exception e) { throw new ELException(e); } @@ -141,8 +138,7 @@ public class BeanELResolver extends ELResolver { * @since EL 2.2 */ @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) { Objects.requireNonNull(context); if (base == null || method == null) { return null; @@ -155,8 +151,8 @@ public class BeanELResolver extends ELResolver { // Find the matching method Method matchingMethod = Util.findMethod(context, base.getClass(), base, methodName, paramTypes, params); - Object[] parameters = Util.buildParameters( - context, matchingMethod.getParameterTypes(), matchingMethod.isVarArgs(), params); + Object[] parameters = Util.buildParameters(context, matchingMethod.getParameterTypes(), + matchingMethod.isVarArgs(), params); Object result = null; try { @@ -225,7 +221,7 @@ public class BeanELResolver extends ELResolver { try { BeanInfo info = Introspector.getBeanInfo(this.type); PropertyDescriptor[] pds = info.getPropertyDescriptors(); - for (PropertyDescriptor pd: pds) { + for (PropertyDescriptor pd : pds) { this.properties.put(pd.getName(), new BeanProperty(type, pd)); } if (System.getSecurityManager() != null) { @@ -246,8 +242,7 @@ public class BeanELResolver extends ELResolver { PropertyDescriptor[] pds = info.getPropertyDescriptors(); for (PropertyDescriptor pd : pds) { if (!this.properties.containsKey(pd.getName())) { - this.properties.put(pd.getName(), new BeanProperty( - this.type, pd)); + this.properties.put(pd.getName(), new BeanProperty(this.type, pd)); } } populateFromInterfaces(ifs); @@ -262,8 +257,7 @@ public class BeanELResolver extends ELResolver { private BeanProperty get(ELContext ctx, String name) { BeanProperty property = this.properties.get(name); if (property == null) { - throw new PropertyNotFoundException(Util.message(ctx, - "propertyNotFound", type.getName(), name)); + throw new PropertyNotFoundException(Util.message(ctx, "propertyNotFound", type.getName(), name)); } return property; } @@ -303,9 +297,8 @@ public class BeanELResolver extends ELResolver { if (this.write == null) { this.write = Util.getMethod(this.owner, base, descriptor.getWriteMethod()); if (this.write == null) { - throw new PropertyNotWritableException(Util.message(ctx, - "propertyNotWritable", new Object[] { - owner.getName(), descriptor.getName() })); + throw new PropertyNotWritableException(Util.message(ctx, "propertyNotWritable", + new Object[] { owner.getName(), descriptor.getName() })); } } return this.write; @@ -315,17 +308,15 @@ public class BeanELResolver extends ELResolver { if (this.read == null) { this.read = Util.getMethod(this.owner, base, descriptor.getReadMethod()); if (this.read == null) { - throw new PropertyNotFoundException(Util.message(ctx, - "propertyNotReadable", new Object[] { - owner.getName(), descriptor.getName() })); + throw new PropertyNotFoundException(Util.message(ctx, "propertyNotReadable", + new Object[] { owner.getName(), descriptor.getName() })); } } return this.read; } } - private BeanProperty property(ELContext ctx, Object base, - Object property) { + private BeanProperty property(ELContext ctx, Object base, Object property) { Class<?> type = base.getClass(); String prop = property.toString(); @@ -338,11 +329,11 @@ public class BeanELResolver extends ELResolver { return props.get(ctx, prop); } - private static final class ConcurrentCache<K,V> { + private static final class ConcurrentCache<K, V> { private final int size; - private final Map<K,V> eden; - private final Map<K,V> longterm; + private final Map<K, V> eden; + private final Map<K, V> longterm; ConcurrentCache(int size) { this.size = size; diff --git a/java/javax/el/BeanNameELResolver.java b/java/javax/el/BeanNameELResolver.java index 0e7b48dee6..2be04045e9 100644 --- a/java/javax/el/BeanNameELResolver.java +++ b/java/javax/el/BeanNameELResolver.java @@ -55,8 +55,7 @@ public class BeanNameELResolver 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) { Objects.requireNonNull(context); if (base != null || !(property instanceof String)) { return; @@ -77,12 +76,10 @@ public class BeanNameELResolver extends ELResolver { } if (isReadOnly) { - throw new PropertyNotWritableException(Util.message(context, - "beanNameELResolver.beanReadOnly", beanName)); + throw new PropertyNotWritableException(Util.message(context, "beanNameELResolver.beanReadOnly", beanName)); } - if (beanNameResolver.isNameResolved(beanName) || - beanNameResolver.canCreateBean(beanName)) { + if (beanNameResolver.isNameResolved(beanName) || beanNameResolver.canCreateBean(beanName)) { try { beanNameResolver.setBeanValue(beanName, value); context.setPropertyResolved(base, property); @@ -143,8 +140,7 @@ public class BeanNameELResolver extends ELResolver { } @Override - public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, - Object base) { + public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) { return null; } diff --git a/java/javax/el/BeanNameResolver.java b/java/javax/el/BeanNameResolver.java index abe0356046..751b79515d 100644 --- a/java/javax/el/BeanNameResolver.java +++ b/java/javax/el/BeanNameResolver.java @@ -17,8 +17,8 @@ package javax.el; /** - * Base implementation that provides a minimal default implementation that is - * intended to be extended by application developers. + * Base implementation that provides a minimal default implementation that is intended to be extended by application + * developers. * * @since EL 3.0 */ @@ -49,17 +49,15 @@ public abstract class BeanNameResolver { /** - * Sets a value of a bean of the given name. If the named bean does not - * exist and {@link #canCreateBean} returns <code>true</code> then a bean - * is created with the given value. + * Sets a value of a bean of the given name. If the named bean does not exist and {@link #canCreateBean} returns + * <code>true</code> then a bean is created with the given value. * * @param beanName The name of the bean to be set/create * @param value The value of the bean to set/create * * @throws PropertyNotWritableException if the bean is read only */ - public void setBeanValue(String beanName, Object value) - throws PropertyNotWritableException { + public void setBeanValue(String beanName, Object value) throws PropertyNotWritableException { throw new PropertyNotWritableException(); } @@ -69,8 +67,7 @@ public abstract class BeanNameResolver { * * @param beanName The name of the bean of interest * - * @return <code>true</code> if the bean is read only, otherwise - * <code>false</code> + * @return <code>true</code> if the bean is read only, otherwise <code>false</code> */ public boolean isReadOnly(String beanName) { return true; @@ -82,8 +79,7 @@ public abstract class BeanNameResolver { * * @param beanName The name of the bean of interest * - * @return <code>true</code> if the bean may be created, otherwise - * <code>false</code> + * @return <code>true</code> if the bean may be created, otherwise <code>false</code> */ public boolean canCreateBean(String beanName) { return false; diff --git a/java/javax/el/CompositeELResolver.java b/java/javax/el/CompositeELResolver.java index 43e3ea3e62..61a88e6e32 100644 --- a/java/javax/el/CompositeELResolver.java +++ b/java/javax/el/CompositeELResolver.java @@ -71,8 +71,7 @@ public class CompositeELResolver extends ELResolver { * @since EL 2.2 */ @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) { context.setPropertyResolved(false); int sz = this.size; for (int i = 0; i < sz; i++) { diff --git a/java/javax/el/ELContext.java b/java/javax/el/ELContext.java index 1dad8fd68e..ec11cb9f0d 100644 --- a/java/javax/el/ELContext.java +++ b/java/javax/el/ELContext.java @@ -38,7 +38,7 @@ public abstract class ELContext { private List<EvaluationListener> listeners; - private Deque<Map<String,Object>> lambdaArguments = new ArrayDeque<>(); + private Deque<Map<String, Object>> lambdaArguments = new ArrayDeque<>(); public ELContext() { this.resolved = false; @@ -72,11 +72,9 @@ public abstract class ELContext { * @param key The key under which to store the object * @param contextObject The object to add * - * @throws NullPointerException - * If the supplied key or context is <code>null</code> + * @throws NullPointerException If the supplied key or context is <code>null</code> */ - public void putContext(@SuppressWarnings("rawtypes") Class key, - Object contextObject) { + public void putContext(@SuppressWarnings("rawtypes") Class key, Object contextObject) { Objects.requireNonNull(key); Objects.requireNonNull(contextObject); @@ -95,8 +93,7 @@ public abstract class ELContext { * * @return The value of the context object associated with the given key * - * @throws NullPointerException - * If the supplied key is <code>null</code> + * @throws NullPointerException If the supplied key is <code>null</code> */ public Object getContext(@SuppressWarnings("rawtypes") Class key) { Objects.requireNonNull(key); @@ -109,8 +106,7 @@ public abstract class ELContext { public abstract ELResolver getELResolver(); /** - * Obtain the ImportHandler for this ELContext, creating one if necessary. - * This method is not thread-safe. + * Obtain the ImportHandler for this ELContext, creating one if necessary. This method is not thread-safe. * * @return the ImportHandler for this ELContext. * @@ -233,18 +229,17 @@ public abstract class ELContext { } /** - * Determine if the specified name is recognised as the name of a lambda - * argument. + * Determine if the specified name is recognised as the name of a lambda argument. * * @param name The name of the lambda argument * - * @return <code>true</code> if the name is recognised as the name of a - * lambda argument, otherwise <code>false</code> + * @return <code>true</code> if the name is recognised as the name of a lambda argument, otherwise + * <code>false</code> * * @since EL 3.0 */ public boolean isLambdaArgument(String name) { - for (Map<String,Object> arguments : lambdaArguments) { + for (Map<String, Object> arguments : lambdaArguments) { if (arguments.containsKey(name)) { return true; } @@ -262,7 +257,7 @@ public abstract class ELContext { * @since EL 3.0 */ public Object getLambdaArgument(String name) { - for (Map<String,Object> arguments : lambdaArguments) { + for (Map<String, Object> arguments : lambdaArguments) { Object result = arguments.get(name); if (result != null) { return result; @@ -272,20 +267,19 @@ public abstract class ELContext { } /** - * Called when starting to evaluate a lambda expression so that the - * arguments are available to the EL context during evaluation. + * Called when starting to evaluate a lambda expression so that the arguments are available to the EL context during + * evaluation. + * + * @param arguments The arguments in scope for the current lambda expression. * - * @param arguments The arguments in scope for the current lambda - * expression. * @since EL 3.0 */ - public void enterLambdaScope(Map<String,Object> arguments) { + public void enterLambdaScope(Map<String, Object> arguments) { lambdaArguments.push(arguments); } /** - * Called after evaluating a lambda expression to signal that the arguments - * are no longer required. + * Called after evaluating a lambda expression to signal that the arguments are no longer required. * * @since EL 3.0 */ @@ -301,8 +295,7 @@ public abstract class ELContext { * * @return An instance of the requested type. * - * @throws ELException - * If the conversion fails + * @throws ELException If the conversion fails * * @since EL 3.0 */ diff --git a/java/javax/el/ELContextListener.java b/java/javax/el/ELContextListener.java index 737b83adc2..ee566bf750 100644 --- a/java/javax/el/ELContextListener.java +++ b/java/javax/el/ELContextListener.java @@ -18,7 +18,6 @@ package javax.el; /** * @author Jacob Hookom [jacob/hookom.net] - * */ public interface ELContextListener extends java.util.EventListener { diff --git a/java/javax/el/ELException.java b/java/javax/el/ELException.java index d959f0618d..68d0a1f0aa 100644 --- a/java/javax/el/ELException.java +++ b/java/javax/el/ELException.java @@ -17,8 +17,7 @@ package javax.el; /** - * Represents any of the exception conditions that can arise during expression - * evaluation. + * Represents any of the exception conditions that can arise during expression evaluation. * * @since 2.1 */ @@ -36,8 +35,7 @@ public class ELException extends RuntimeException { /** * Creates an ELException with the provided detail message. * - * @param message - * the detail message + * @param message the detail message */ public ELException(String message) { super(message); @@ -46,8 +44,7 @@ public class ELException extends RuntimeException { /** * Creates an ELException with the given cause * - * @param cause - * the originating cause of this exception + * @param cause the originating cause of this exception */ public ELException(Throwable cause) { super(cause); @@ -56,10 +53,8 @@ public class ELException extends RuntimeException { /** * Creates an ELException with the given detail message and root cause. * - * @param message - * the detail message - * @param cause - * the originating cause of this exception + * @param message the detail message + * @param cause the originating cause of this exception */ public ELException(String message, Throwable cause) { super(message, cause); diff --git a/java/javax/el/ELManager.java b/java/javax/el/ELManager.java index c3d60eaed7..6b3cf7bc74 100644 --- a/java/javax/el/ELManager.java +++ b/java/javax/el/ELManager.java @@ -53,16 +53,14 @@ public class ELManager { } public void mapFunction(String prefix, String function, Method method) { - getELContext().getFunctionMapper().mapFunction( - prefix, function, method); + getELContext().getFunctionMapper().mapFunction(prefix, function, method); } public void setVariable(String variable, ValueExpression expression) { getELContext().getVariableMapper().setVariable(variable, expression); } - public void importStatic(String staticMemberName) - throws javax.el.ELException { + public void importStatic(String staticMemberName) throws javax.el.ELException { getELContext().getImportHandler().importStatic(staticMemberName); } @@ -75,7 +73,7 @@ public class ELManager { } public Object defineBean(String name, Object bean) { - Map<String,Object> localBeans = getELContext().getLocalBeans(); + Map<String, Object> localBeans = getELContext().getLocalBeans(); if (bean == null) { return localBeans.remove(name); diff --git a/java/javax/el/ELProcessor.java b/java/javax/el/ELProcessor.java index 8e367c00fd..8133c5026d 100644 --- a/java/javax/el/ELProcessor.java +++ b/java/javax/el/ELProcessor.java @@ -56,15 +56,13 @@ public class ELProcessor { public Object getValue(String expression, Class<?> expectedType) { - ValueExpression ve = factory.createValueExpression( - context, bracket(expression), expectedType); + ValueExpression ve = factory.createValueExpression(context, bracket(expression), expectedType); return ve.getValue(context); } public void setValue(String expression, Object value) { - ValueExpression ve = factory.createValueExpression( - context, bracket(expression), Object.class); + ValueExpression ve = factory.createValueExpression(context, bracket(expression), Object.class); ve.setValue(context, value); } @@ -73,21 +71,17 @@ public class ELProcessor { if (expression == null) { manager.setVariable(variable, null); } else { - ValueExpression ve = factory.createValueExpression( - context, bracket(expression), Object.class); + ValueExpression ve = factory.createValueExpression(context, bracket(expression), Object.class); manager.setVariable(variable, ve); } } - public void defineFunction(String prefix, String function, String className, - String methodName) throws ClassNotFoundException, - NoSuchMethodException { + public void defineFunction(String prefix, String function, String className, String methodName) + throws ClassNotFoundException, NoSuchMethodException { - if (prefix == null || function == null || className == null || - methodName == null) { - throw new NullPointerException(Util.message( - context, "elProcessor.defineFunctionNullParams")); + if (prefix == null || function == null || className == null || methodName == null) { + throw new NullPointerException(Util.message(context, "elProcessor.defineFunctionNullParams")); } // Check the imports @@ -98,12 +92,11 @@ public class ELProcessor { } if (!Modifier.isPublic(clazz.getModifiers())) { - throw new ClassNotFoundException(Util.message(context, - "elProcessor.defineFunctionInvalidClass", className)); + throw new ClassNotFoundException( + Util.message(context, "elProcessor.defineFunctionInvalidClass", className)); } - MethodSignature sig = - new MethodSignature(context, methodName, className); + MethodSignature sig = new MethodSignature(context, methodName, className); if (function.length() == 0) { function = sig.getName(); @@ -139,7 +132,7 @@ public class ELProcessor { if (types.length == typeNames.length) { boolean match = true; for (int i = 0; i < types.length; i++) { - if (i == types.length -1 && method.isVarArgs()) { + if (i == types.length - 1 && method.isVarArgs()) { String typeName = typeNames[i]; if (typeName.endsWith("...")) { typeName = typeName.substring(0, typeName.length() - 3); @@ -163,29 +156,25 @@ public class ELProcessor { } } - throw new NoSuchMethodException(Util.message(context, - "elProcessor.defineFunctionNoMethod", methodName, className)); + throw new NoSuchMethodException( + Util.message(context, "elProcessor.defineFunctionNoMethod", methodName, className)); } /** * Map a method to a function name. * - * @param prefix Function prefix - * @param function Function name - * @param method Method + * @param prefix Function prefix + * @param function Function name + * @param method Method * - * @throws NullPointerException - * If any of the arguments are null - * @throws NoSuchMethodException - * If the method is not static + * @throws NullPointerException If any of the arguments are null + * @throws NoSuchMethodException If the method is not static */ - public void defineFunction(String prefix, String function, Method method) - throws java.lang.NoSuchMethodException { + public void defineFunction(String prefix, String function, Method method) throws java.lang.NoSuchMethodException { if (prefix == null || function == null || method == null) { - throw new NullPointerException(Util.message( - context, "elProcessor.defineFunctionNullParams")); + throw new NullPointerException(Util.message(context, "elProcessor.defineFunctionNullParams")); } int modifiers = method.getModifiers(); @@ -193,9 +182,8 @@ public class ELProcessor { // Check for static, public method and module access for Java 9+ JreCompat jreCompat = JreCompat.getInstance(); if (!Modifier.isStatic(modifiers) || !jreCompat.canAccess(null, method)) { - throw new NoSuchMethodException(Util.message(context, - "elProcessor.defineFunctionInvalidMethod", method.getName(), - method.getDeclaringClass().getName())); + throw new NoSuchMethodException(Util.message(context, "elProcessor.defineFunctionInvalidMethod", + method.getName(), method.getDeclaringClass().getName())); } manager.mapFunction(prefix, function, method); @@ -216,8 +204,7 @@ public class ELProcessor { private final String name; private final String[] parameterTypeNames; - MethodSignature(ELContext context, String methodName, - String className) throws NoSuchMethodException { + MethodSignature(ELContext context, String methodName, String className) throws NoSuchMethodException { int paramIndex = methodName.indexOf('('); @@ -245,8 +232,7 @@ public class ELProcessor { // We know the params start with '(', check they end with ')' if (!paramString.endsWith(")")) { throw new NoSuchMethodException(Util.message(context, - "elProcessor.defineFunctionInvalidParameterList", - paramString, methodName, className)); + "elProcessor.defineFunctionInvalidParameterList", paramString, methodName, className)); } // Trim '(' and ')' paramString = paramString.substring(1, paramString.length() - 1).trim(); @@ -260,11 +246,10 @@ public class ELProcessor { int dimension = 0; int bracketPos = parameterTypeName.indexOf('['); if (bracketPos > -1) { - String parameterTypeNameOnly = - parameterTypeName.substring(0, bracketPos).trim(); + String parameterTypeNameOnly = parameterTypeName.substring(0, bracketPos).trim(); while (bracketPos > -1) { dimension++; - bracketPos = parameterTypeName.indexOf('[', bracketPos+ 1); + bracketPos = parameterTypeName.indexOf('[', bracketPos + 1); } parameterTypeName = parameterTypeNameOnly; } @@ -272,14 +257,12 @@ public class ELProcessor { if (parameterTypeName.endsWith("...")) { varArgs = true; dimension = 1; - parameterTypeName = parameterTypeName.substring( - 0, parameterTypeName.length() -3).trim(); + parameterTypeName = parameterTypeName.substring(0, parameterTypeName.length() - 3).trim(); } boolean isPrimitive = PRIMITIVES.contains(parameterTypeName); if (isPrimitive && dimension > 0) { // When in an array, class name changes for primitive - switch(parameterTypeName) - { + switch (parameterTypeName) { case "boolean": parameterTypeName = "Z"; break; @@ -308,16 +291,12 @@ public class ELProcessor { // Should never happen break; } - } else if (!isPrimitive && - !parameterTypeName.contains(".")) { - Class<?> clazz = importHandler.resolveClass( - parameterTypeName); + } else if (!isPrimitive && !parameterTypeName.contains(".")) { + Class<?> clazz = importHandler.resolveClass(parameterTypeName); if (clazz == null) { - throw new NoSuchMethodException(Util.message( - context, - "elProcessor.defineFunctionInvalidParameterTypeName", - parameterTypeNames[i], methodName, - className)); + throw new NoSuchMethodException( + Util.message(context, "elProcessor.defineFunctionInvalidParameterTypeName", + parameterTypeNames[i], methodName, className)); } parameterTypeName = clazz.getName(); } @@ -351,9 +330,8 @@ public class ELProcessor { } /** - * @return <code>null</code> if just the method name was specified, an - * empty List if an empty parameter list was specified - i.e. () - * - otherwise an ordered list of parameter type names + * @return <code>null</code> if just the method name was specified, an empty List if an empty parameter list was + * specified - i.e. () - otherwise an ordered list of parameter type names */ public String[] getParamTypeNames() { return parameterTypeNames; diff --git a/java/javax/el/ELResolver.java b/java/javax/el/ELResolver.java index a43425eee3..b426d0ace4 100644 --- a/java/javax/el/ELResolver.java +++ b/java/javax/el/ELResolver.java @@ -20,7 +20,6 @@ import java.util.Iterator; /** * @author Jacob Hookom [jacob/hookom.net] - * */ public abstract class ELResolver { @@ -29,28 +28,24 @@ public abstract class ELResolver { public static final String RESOLVABLE_AT_DESIGN_TIME = "resolvableAtDesignTime"; /** - * Obtain the value of the given property on the given object using the - * given context. + * Obtain the value of the given property on the given object using the given context. * - * @param context The EL context for this evaluation - * @param base The base object on which the property is to be found + * @param context The EL context for this evaluation + * @param base The base object on which the property is to be found * @param property The property whose value is to be returned + * * @return the value of the provided property - * @throws NullPointerException - * If the supplied context is <code>null</code> - * @throws PropertyNotFoundException - * If the base/property combination provided to the resolver is - * one that the resolver can handle but no match was found or a - * match was found but was not readable - * @throws ELException - * Wraps any exception throw whilst resolving the property + * + * @throws NullPointerException If the supplied context is <code>null</code> + * @throws PropertyNotFoundException If the base/property combination provided to the resolver is one that the + * resolver can handle but no match was found or a match was found but was not + * readable + * @throws ELException Wraps any exception throw whilst resolving the property */ - public abstract Object getValue(ELContext context, Object base, - Object property); + public abstract Object getValue(ELContext context, Object base, Object property); /** - * Invokes a method on the the given object. This default implementation - * always returns <code>null</code>. + * Invokes a method on the the given object. This default implementation always returns <code>null</code>. * * @param context The EL context for this evaluation * @param base The base object on which the method is to be found @@ -62,83 +57,67 @@ public abstract class ELResolver { * * @since EL 2.2 */ - 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) { return null; } /** - * Obtain the type of the given property on the given object using the given - * context. + * Obtain the type of the given property on the given object using the given context. * - * @param context The EL context for this evaluation - * @param base The base object on which the property is to be found + * @param context The EL context for this evaluation + * @param base The base object on which the property is to be found * @param property The property whose type is to be returned + * * @return the type of the provided property - * @throws NullPointerException - * If the supplied context is <code>null</code> - * @throws PropertyNotFoundException - * If the base/property combination provided to the resolver is - * one that the resolver can handle but no match was found or a - * match was found but was not readable - * @throws ELException - * Wraps any exception throw whilst resolving the property + * + * @throws NullPointerException If the supplied context is <code>null</code> + * @throws PropertyNotFoundException If the base/property combination provided to the resolver is one that the + * resolver can handle but no match was found or a match was found but was not + * readable + * @throws ELException Wraps any exception throw whilst resolving the property */ - public abstract Class<?> getType(ELContext context, Object base, - Object property); + public abstract Class<?> getType(ELContext context, Object base, Object property); /** - * Set the value of the given property on the given object using the given - * context. + * Set the value of the given property on the given object using the given context. * * @param context The EL context for this evaluation * @param base The base object on which the property is to be found * @param property The property whose value is to be set * @param value The value to set the property to - * @throws NullPointerException - * If the supplied context is <code>null</code> - * @throws PropertyNotFoundException - * If the base/property combination provided to the resolver is - * one that the resolver can handle but no match was found - * @throws PropertyNotWritableException - * If the base/property combination provided to the resolver is - * one that the resolver can handle but the property was not - * writable - * @throws ELException - * Wraps any exception throw whilst resolving the property + * + * @throws NullPointerException If the supplied context is <code>null</code> + * @throws PropertyNotFoundException If the base/property combination provided to the resolver is one that the + * resolver can handle but no match was found + * @throws PropertyNotWritableException If the base/property combination provided to the resolver is one that the + * resolver can handle but the property was not writable + * @throws ELException Wraps any exception throw whilst resolving the property */ - public abstract void setValue(ELContext context, Object base, - Object property, Object value); + public abstract void setValue(ELContext context, Object base, Object property, Object value); /** - * Determine if the given property on the given object is read-only using - * the given context. + * Determine if the given property on the given object is read-only using the given context. * - * @param context The EL context for this evaluation - * @param base The base object on which the property is to be found + * @param context The EL context for this evaluation + * @param base The base object on which the property is to be found * @param property The property to be checked for read only status - * @return <code>true</code> if the identified property is read only, - * otherwise <code>false</code> - * @throws NullPointerException - * If the supplied context is <code>null</code> - * @throws PropertyNotFoundException - * If the base/property combination provided to the resolver is - * one that the resolver can handle but no match was found - * @throws ELException - * Wraps any exception throw whilst resolving the property + * + * @return <code>true</code> if the identified property is read only, otherwise <code>false</code> + * + * @throws NullPointerException If the supplied context is <code>null</code> + * @throws PropertyNotFoundException If the base/property combination provided to the resolver is one that the + * resolver can handle but no match was found + * @throws ELException Wraps any exception throw whilst resolving the property */ - public abstract boolean isReadOnly(ELContext context, Object base, - Object property); + public abstract boolean isReadOnly(ELContext context, Object base, Object property); /** - * Obtain the feature descriptors for the resolvable properties of the given - * object. + * Obtain the feature descriptors for the resolvable properties of the given object. * * @param context The context in which the examination takes place - * @param base The object to examine + * @param base The object to examine * - * @return An iterator, possibly empty, of feature descriptors of the given - * object + * @return An iterator, possibly empty, of feature descriptors of the given object */ public abstract Iterator<java.beans.FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base); @@ -146,17 +125,14 @@ public abstract class ELResolver { * Obtain the most common type that is acceptable for the given base object. * * @param context The context in which the examination takes place - * @param base The object to examine + * @param base The object to examine * - * @return {code null} if the most common type cannot be determine, - * otherwise the most common type + * @return {code null} if the most common type cannot be determine, otherwise the most common type */ - public abstract Class<?> getCommonPropertyType(ELContext context, - Object base); + public abstract Class<?> getCommonPropertyType(ELContext context, Object base); /** - * Converts the given object to the given type. This default implementation - * always returns <code>null</code>. + * Converts the given object to the given type. This default implementation always returns <code>null</code>. * * @param context The EL context for this evaluation * @param obj The object to convert diff --git a/java/javax/el/EvaluationListener.java b/java/javax/el/EvaluationListener.java index 785ebdad60..3eb4d2b1e9 100644 --- a/java/javax/el/EvaluationListener.java +++ b/java/javax/el/EvaluationListener.java @@ -24,8 +24,7 @@ public abstract class EvaluationListener { /** * Fired before the evaluation of the expression. * - * @param context The EL context in which the expression will be - * evaluated + * @param context The EL context in which the expression will be evaluated * @param expression The expression that will be evaluated */ public void beforeEvaluation(ELContext context, String expression) { diff --git a/java/javax/el/ExpressionFactory.java b/java/javax/el/ExpressionFactory.java index fe75f582ef..6c70462b95 100644 --- a/java/javax/el/ExpressionFactory.java +++ b/java/javax/el/ExpressionFactory.java @@ -49,37 +49,31 @@ public abstract class ExpressionFactory { private static final String PROPERTY_FILE; private static final CacheValue nullTcclFactory = new CacheValue(); - private static final ConcurrentMap<CacheKey, CacheValue> factoryCache = - new ConcurrentHashMap<>(); + private static final ConcurrentMap<CacheKey, CacheValue> factoryCache = new ConcurrentHashMap<>(); static { if (IS_SECURITY_ENABLED) { - PROPERTY_FILE = AccessController.doPrivileged( - new PrivilegedAction<String>(){ - @Override - public String run() { - return System.getProperty("java.home") + File.separator + - "lib" + File.separator + "el.properties"; - } + PROPERTY_FILE = AccessController.doPrivileged(new PrivilegedAction<String>() { + @Override + public String run() { + return System.getProperty("java.home") + File.separator + "lib" + File.separator + "el.properties"; + } - } - ); + }); } else { - PROPERTY_FILE = System.getProperty("java.home") + File.separator + "lib" + - File.separator + "el.properties"; + PROPERTY_FILE = System.getProperty("java.home") + File.separator + "lib" + File.separator + "el.properties"; } } /** - * Create a new {@link ExpressionFactory}. The class to use is determined by - * the following search order: + * Create a new {@link ExpressionFactory}. The class to use is determined by the following search order: * <ol> * <li>services API (META-INF/services/javax.el.ExpressionFactory)</li> * <li>$JRE_HOME/lib/el.properties - key javax.el.ExpressionFactory</li> * <li>javax.el.ExpressionFactory</li> - * <li>Platform default implementation - - * org.apache.el.ExpressionFactoryImpl</li> + * <li>Platform default implementation - org.apache.el.ExpressionFactoryImpl</li> * </ol> + * * @return the new ExpressionFactory */ public static ExpressionFactory newInstance() { @@ -87,10 +81,11 @@ public abstract class ExpressionFactory { } /** - * Create a new {@link ExpressionFactory} passing in the provided - * {@link Properties}. Search order is the same as {@link #newInstance()}. + * Create a new {@link ExpressionFactory} passing in the provided {@link Properties}. Search order is the same as + * {@link #newInstance()}. * * @param properties the properties to be passed to the new instance (may be null) + * * @return the new ExpressionFactory */ public static ExpressionFactory newInstance(Properties properties) { @@ -164,8 +159,7 @@ public abstract class ExpressionFactory { if (constructor == null) { result = (ExpressionFactory) clazz.getConstructor().newInstance(); } else { - result = - (ExpressionFactory) constructor.newInstance(properties); + result = (ExpressionFactory) constructor.newInstance(properties); } } catch (InvocationTargetException e) { @@ -184,42 +178,32 @@ public abstract class ExpressionFactory { * * @param context The EL context for this evaluation * @param expression The String representation of the value expression - * @param expectedType The expected type of the result of evaluating the - * expression + * @param expectedType The expected type of the result of evaluating the expression * * @return A new value expression formed from the input parameters * - * @throws NullPointerException - * If the expected type is <code>null</code> - * @throws ELException - * If there are syntax errors in the provided expression + * @throws NullPointerException If the expected type is <code>null</code> + * @throws ELException If there are syntax errors in the provided expression */ - public abstract ValueExpression createValueExpression(ELContext context, - String expression, Class<?> expectedType); + public abstract ValueExpression createValueExpression(ELContext context, String expression, Class<?> expectedType); - public abstract ValueExpression createValueExpression(Object instance, - Class<?> expectedType); + public abstract ValueExpression createValueExpression(Object instance, Class<?> expectedType); /** * Create a new method expression instance. * * @param context The EL context for this evaluation - * @param expression The String representation of the method - * expression - * @param expectedReturnType The expected type of the result of invoking the - * method + * @param expression The String representation of the method expression + * @param expectedReturnType The expected type of the result of invoking the method * @param expectedParamTypes The expected types of the input parameters * * @return A new method expression formed from the input parameters. * - * @throws NullPointerException - * If the expected parameters types are <code>null</code> - * @throws ELException - * If there are syntax errors in the provided expression + * @throws NullPointerException If the expected parameters types are <code>null</code> + * @throws ELException If there are syntax errors in the provided expression */ - public abstract MethodExpression createMethodExpression(ELContext context, - String expression, Class<?> expectedReturnType, - Class<?>[] expectedParamTypes); + public abstract MethodExpression createMethodExpression(ELContext context, String expression, + Class<?> expectedReturnType, Class<?>[] expectedParamTypes); /** * Coerce the supplied object to the requested type. @@ -229,8 +213,7 @@ public abstract class ExpressionFactory { * * @return An instance of the requested type. * - * @throws ELException - * If the conversion fails + * @throws ELException If the conversion fails */ public abstract Object coerceToType(Object obj, Class<?> expectedType); @@ -248,14 +231,13 @@ public abstract class ExpressionFactory { * * @since EL 3.0 */ - public Map<String,Method> getInitFunctionMap() { + public Map<String, Method> getInitFunctionMap() { return null; } /** - * Key used to cache ExpressionFactory discovery information per class - * loader. The class loader reference is never {@code null}, because - * {@code null} tccl is handled separately. + * Key used to cache ExpressionFactory discovery information per class loader. The class loader reference is never + * {@code null}, because {@code null} tccl is handled separately. */ private static class CacheKey { private final int hash; @@ -319,8 +301,8 @@ public abstract class ExpressionFactory { /** * Discover the name of class that implements ExpressionFactory. * - * @param tccl - * {@code ClassLoader} + * @param tccl {@code ClassLoader} + * * @return Class name. There is default, so it is never {@code null}. */ private static String discoverClassName(ClassLoader tccl) { @@ -330,14 +312,12 @@ public abstract class ExpressionFactory { className = getClassNameServices(tccl); if (className == null) { if (IS_SECURITY_ENABLED) { - className = AccessController.doPrivileged( - new PrivilegedAction<String>() { - @Override - public String run() { - return getClassNameJreDir(); - } - } - ); + className = AccessController.doPrivileged(new PrivilegedAction<String>() { + @Override + public String run() { + return getClassNameJreDir(); + } + }); } else { // Second el.properties file className = getClassNameJreDir(); @@ -345,14 +325,12 @@ public abstract class ExpressionFactory { } if (className == null) { if (IS_SECURITY_ENABLED) { - className = AccessController.doPrivileged( - new PrivilegedAction<String>() { - @Override - public String run() { - return getClassNameSysProp(); - } - } - ); + className = AccessController.doPrivileged(new PrivilegedAction<String>() { + @Override + public String run() { + return getClassNameSysProp(); + } + }); } else { // Third system property className = getClassNameSysProp(); @@ -385,7 +363,7 @@ public abstract class ExpressionFactory { private static String getClassNameJreDir() { File file = new File(PROPERTY_FILE); if (file.canRead()) { - try (InputStream is = new FileInputStream(file)){ + try (InputStream is = new FileInputStream(file)) { Properties props = new Properties(); props.load(is); String value = props.getProperty(PROPERTY_NAME); diff --git a/java/javax/el/ImportHandler.java b/java/javax/el/ImportHandler.java index ac19a16737..3c73e23430 100644 --- a/java/javax/el/ImportHandler.java +++ b/java/javax/el/ImportHandler.java @@ -31,7 +31,7 @@ import java.util.concurrent.ConcurrentHashMap; */ public class ImportHandler { - private static final Map<String,Set<String>> standardPackages = new HashMap<>(); + private static final Map<String, Set<String>> standardPackages = new HashMap<>(); static { // Servlet 4.0 @@ -119,7 +119,7 @@ public class ImportHandler { // JSP 2.3 Set<String> servletJspClassNames = new HashSet<>(); - //Interfaces + // Interfaces servletJspClassNames.add("HttpJspPage"); servletJspClassNames.add("JspApplicationContext"); servletJspClassNames.add("JspPage"); @@ -155,7 +155,7 @@ public class ImportHandler { javaLangClassNames.add("Thread.Builder.OfPlatform"); javaLangClassNames.add("Thread.Builder.OfVirtual"); javaLangClassNames.add("Thread.UncaughtExceptionHandler"); - //Classes + // Classes javaLangClassNames.add("Boolean"); javaLangClassNames.add("Byte"); javaLangClassNames.add("Character"); @@ -201,13 +201,13 @@ public class ImportHandler { javaLangClassNames.add("ThreadLocal"); javaLangClassNames.add("Throwable"); javaLangClassNames.add("Void"); - //Enums + // Enums javaLangClassNames.add("Character.UnicodeScript"); javaLangClassNames.add("ProcessBuilder.Redirect.Type"); javaLangClassNames.add("StackWalker.Option"); javaLangClassNames.add("System.Logger.Level"); javaLangClassNames.add("Thread.State"); - //Exceptions + // Exceptions javaLangClassNames.add("ArithmeticException"); javaLangClassNames.add("ArrayIndexOutOfBoundsException"); javaLangClassNames.add("ArrayStoreException"); @@ -239,7 +239,7 @@ public class ImportHandler { javaLangClassNames.add("TypeNotPresentException"); javaLangClassNames.add("UnsupportedOperationException"); javaLangClassNames.add("WrongThreadException"); - //Errors + // Errors javaLangClassNames.add("AbstractMethodError"); javaLangClassNames.add("AssertionError"); javaLangClassNames.add("BootstrapMethodError"); @@ -263,7 +263,7 @@ public class ImportHandler { javaLangClassNames.add("UnsupportedClassVersionError"); javaLangClassNames.add("VerifyError"); javaLangClassNames.add("VirtualMachineError"); - //Annotation Types + // Annotation Types javaLangClassNames.add("Deprecated"); javaLangClassNames.add("FunctionalInterface"); javaLangClassNames.add("Override"); @@ -273,10 +273,10 @@ public class ImportHandler { } - private Map<String,Set<String>> packageNames = new ConcurrentHashMap<>(); - private ConcurrentHashMap<String,String> classNames = new ConcurrentHashMap<>(); - private Map<String,Class<?>> clazzes = new ConcurrentHashMap<>(); - private Map<String,Class<?>> statics = new ConcurrentHashMap<>(); + private Map<String, Set<String>> packageNames = new ConcurrentHashMap<>(); + private ConcurrentHashMap<String, String> classNames = new ConcurrentHashMap<>(); + private Map<String, Class<?>> clazzes = new ConcurrentHashMap<>(); + private Map<String, Class<?>> statics = new ConcurrentHashMap<>(); public ImportHandler() { @@ -288,8 +288,7 @@ public class ImportHandler { int lastPeriod = name.lastIndexOf('.'); if (lastPeriod < 0) { - throw new ELException(Util.message( - null, "importHandler.invalidStaticName", name)); + throw new ELException(Util.message(null, "importHandler.invalidStaticName", name)); } String className = name.substring(0, lastPeriod); @@ -298,9 +297,7 @@ public class ImportHandler { Class<?> clazz = findClass(className, true); if (clazz == null) { - throw new ELException(Util.message( - null, "importHandler.invalidClassNameForStatic", - className, name)); + throw new ELException(Util.message(null, "importHandler.invalidClassNameForStatic", className, name)); } boolean found = false; @@ -308,8 +305,7 @@ public class ImportHandler { for (Field field : clazz.getFields()) { if (field.getName().equals(fieldOrMethodName)) { int modifiers = field.getModifiers(); - if (Modifier.isStatic(modifiers) && - Modifier.isPublic(modifiers)) { + if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers)) { found = true; break; } @@ -320,8 +316,7 @@ public class ImportHandler { for (Method method : clazz.getMethods()) { if (method.getName().equals(fieldOrMethodName)) { int modifiers = method.getModifiers(); - if (Modifier.isStatic(modifiers) && - Modifier.isPublic(modifiers)) { + if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers)) { found = true; break; } @@ -330,16 +325,14 @@ public class ImportHandler { } if (!found) { - throw new ELException(Util.message(null, - "importHandler.staticNotFound", fieldOrMethodName, - className, name)); + throw new ELException( + Util.message(null, "importHandler.staticNotFound", fieldOrMethodName, className, name)); } Class<?> conflict = statics.get(fieldOrMethodName); if (conflict != null) { - throw new ELException(Util.message(null, - "importHandler.ambiguousStaticImport", name, - conflict.getName() + '.' + fieldOrMethodName)); + throw new ELException(Util.message(null, "importHandler.ambiguousStaticImport", name, + conflict.getName() + '.' + fieldOrMethodName)); } statics.put(fieldOrMethodName, clazz); @@ -350,8 +343,7 @@ public class ImportHandler { int lastPeriodIndex = name.lastIndexOf('.'); if (lastPeriodIndex < 0) { - throw new ELException(Util.message( - null, "importHandler.invalidClassName", name)); + throw new ELException(Util.message(null, "importHandler.invalidClassName", name)); } String unqualifiedName = name.substring(lastPeriodIndex + 1); @@ -359,8 +351,7 @@ public class ImportHandler { if (currentName != null && !currentName.equals(name)) { // Conflict. Same unqualifiedName, different fully qualified names - throw new ELException(Util.message(null, - "importHandler.ambiguousImport", name, currentName)); + throw new ELException(Util.message(null, "importHandler.ambiguousImport", name, currentName)); } } @@ -407,7 +398,7 @@ public class ImportHandler { // Search the package imports - note there may be multiple matches // (which correctly triggers an error) - for (Map.Entry<String,Set<String>> entry : packageNames.entrySet()) { + for (Map.Entry<String, Set<String>> entry : packageNames.entrySet()) { if (!entry.getValue().isEmpty()) { // Standard package where we know all the class names if (!entry.getValue().contains(name)) { @@ -421,9 +412,8 @@ public class ImportHandler { Class<?> clazz = findClass(className, false); if (clazz != null) { if (result != null) { - throw new ELException(Util.message(null, - "importHandler.ambiguousImport", className, - result.getName())); + throw new ELException( + Util.message(null, "importHandler.ambiguousImport", className, result.getName())); } result = clazz; } @@ -458,11 +448,10 @@ public class ImportHandler { // Java 9+) in an exported package JreCompat jreCompat = JreCompat.getInstance(); int modifiers = clazz.getModifiers(); - if (!Modifier.isPublic(modifiers) || Modifier.isAbstract(modifiers) || - Modifier.isInterface(modifiers) || !jreCompat.isExported(clazz)) { + if (!Modifier.isPublic(modifiers) || Modifier.isAbstract(modifiers) || Modifier.isInterface(modifiers) || + !jreCompat.isExported(clazz)) { if (throwException) { - throw new ELException(Util.message( - null, "importHandler.invalidClass", name)); + throw new ELException(Util.message(null, "importHandler.invalidClass", name)); } else { return null; } @@ -473,8 +462,7 @@ public class ImportHandler { /* - * Marker class used because null values are not permitted in a - * ConcurrentHashMap. + * Marker class used because null values are not permitted in a ConcurrentHashMap. */ private static class NotFound { } diff --git a/java/javax/el/JreCompat.java b/java/javax/el/JreCompat.java index 23604d45aa..bed8e91dc7 100644 --- a/java/javax/el/JreCompat.java +++ b/java/javax/el/JreCompat.java @@ -44,14 +44,12 @@ class JreCompat { /** - * Is the accessibleObject accessible (as a result of appropriate module - * exports) on the provided instance? + * Is the accessibleObject accessible (as a result of appropriate module exports) on the provided instance? * - * @param base The specific instance to be tested. - * @param accessibleObject The method/field/constructor to be tested. + * @param base The specific instance to be tested. + * @param accessibleObject The method/field/constructor to be tested. * - * @return {code true} if the AccessibleObject can be accessed otherwise - * {code false} + * @return {code true} if the AccessibleObject can be accessed otherwise {code false} */ public boolean canAccess(Object base, AccessibleObject accessibleObject) { // Java 8 doesn't support modules so default to true @@ -62,10 +60,9 @@ class JreCompat { /** * Is the given class in an exported package? * - * @param type The class to test + * @param type The class to test * - * @return Always {@code true} for Java 8. {@code true} if the enclosing - * package is exported for Java 9+ + * @return Always {@code true} for Java 8. {@code true} if the enclosing package is exported for Java 9+ */ public boolean isExported(Class<?> type) { return true; diff --git a/java/javax/el/LambdaExpression.java b/java/javax/el/LambdaExpression.java index 36c7929109..cd07fdc9d2 100644 --- a/java/javax/el/LambdaExpression.java +++ b/java/javax/el/LambdaExpression.java @@ -25,11 +25,10 @@ public class LambdaExpression { private final List<String> formalParameters; private final ValueExpression expression; - private final Map<String,Object> nestedArguments = new HashMap<>(); + private final Map<String, Object> nestedArguments = new HashMap<>(); private ELContext context = null; - public LambdaExpression(List<String> formalParameters, - ValueExpression expression) { + public LambdaExpression(List<String> formalParameters, ValueExpression expression) { this.formalParameters = formalParameters; this.expression = expression; @@ -40,8 +39,7 @@ public class LambdaExpression { } @SuppressWarnings("null") // args[i] can't be null due to earlier checks - public Object invoke(ELContext context, Object... args) - throws ELException { + public Object invoke(ELContext context, Object... args) throws ELException { Objects.requireNonNull(context); @@ -56,9 +54,7 @@ public class LambdaExpression { } if (formalParamCount > argCount) { - throw new ELException(Util.message(context, - "lambdaExpression.tooFewArgs", - Integer.valueOf(argCount), + throw new ELException(Util.message(context, "lambdaExpression.tooFewArgs", Integer.valueOf(argCount), Integer.valueOf(formalParamCount))); } @@ -77,8 +73,7 @@ public class LambdaExpression { // Make arguments from this expression available to any nested // expression if (result instanceof LambdaExpression) { - ((LambdaExpression) result).nestedArguments.putAll( - lambdaArguments); + ((LambdaExpression) result).nestedArguments.putAll(lambdaArguments); } return result; } finally { @@ -87,6 +82,6 @@ public class LambdaExpression { } public java.lang.Object invoke(Object... args) { - return invoke (context, args); + return invoke(context, args); } } diff --git a/java/javax/el/ListELResolver.java b/java/javax/el/ListELResolver.java index 3b15e901b9..4874f95ad1 100644 --- a/java/javax/el/ListELResolver.java +++ b/java/javax/el/ListELResolver.java @@ -46,8 +46,7 @@ public class ListELResolver extends ELResolver { List<?> list = (List<?>) base; int idx = coerce(property); if (idx < 0 || idx >= list.size()) { - throw new PropertyNotFoundException( - new ArrayIndexOutOfBoundsException(idx).getMessage()); + throw new PropertyNotFoundException(new ArrayIndexOutOfBoundsException(idx).getMessage()); } return Object.class; } @@ -73,8 +72,7 @@ public class ListELResolver 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) { Objects.requireNonNull(context); if (base instanceof List<?>) { @@ -83,8 +81,8 @@ public class ListELResolver extends ELResolver { List<Object> list = (List<Object>) base; if (this.readOnly) { - throw new PropertyNotWritableException(Util.message(context, - "resolverNotWritable", base.getClass().getName())); + throw new PropertyNotWritableException( + Util.message(context, "resolverNotWritable", base.getClass().getName())); } int idx = coerce(property); @@ -108,9 +106,7 @@ public class ListELResolver extends ELResolver { try { int idx = coerce(property); if (idx < 0 || idx >= list.size()) { - throw new PropertyNotFoundException( - new ArrayIndexOutOfBoundsException(idx) - .getMessage()); + throw new PropertyNotFoundException(new ArrayIndexOutOfBoundsException(idx).getMessage()); } } catch (IllegalArgumentException e) { // ignore @@ -147,7 +143,6 @@ public class ListELResolver extends ELResolver { if (property instanceof String) { return Integer.parseInt((String) property); } - throw new IllegalArgumentException(property != null ? - property.toString() : "null"); + throw new IllegalArgumentException(property != null ? property.toString() : "null"); } } diff --git a/java/javax/el/MapELResolver.java b/java/javax/el/MapELResolver.java index 5306bf3d58..67f8000c48 100644 --- a/java/javax/el/MapELResolver.java +++ b/java/javax/el/MapELResolver.java @@ -27,8 +27,7 @@ import java.util.Objects; public class MapELResolver extends ELResolver { - private static final Class<?> UNMODIFIABLE = - Collections.unmodifiableMap(new HashMap<>()).getClass(); + private static final Class<?> UNMODIFIABLE = Collections.unmodifiableMap(new HashMap<>()).getClass(); private final boolean readOnly; @@ -44,7 +43,7 @@ public class MapELResolver extends ELResolver { public Class<?> getType(ELContext context, Object base, Object property) { Objects.requireNonNull(context); - if (base instanceof Map<?,?>) { + if (base instanceof Map<?, ?>) { context.setPropertyResolved(base, property); return Object.class; } @@ -56,25 +55,24 @@ public class MapELResolver extends ELResolver { public Object getValue(ELContext context, Object base, Object property) { Objects.requireNonNull(context); - if (base instanceof Map<?,?>) { + if (base instanceof Map<?, ?>) { context.setPropertyResolved(base, property); - return ((Map<?,?>) base).get(property); + return ((Map<?, ?>) base).get(property); } return null; } @Override - public void setValue(ELContext context, Object base, Object property, - Object value) { + public void setValue(ELContext context, Object base, Object property, Object value) { Objects.requireNonNull(context); if (base instanceof Map<?, ?>) { context.setPropertyResolved(base, property); if (this.readOnly) { - throw new PropertyNotWritableException(Util.message(context, - "resolverNotWritable", base.getClass().getName())); + throw new PropertyNotWritableException( + Util.message(context, "resolverNotWritable", base.getClass().getName())); } try { diff --git a/java/javax/el/MethodExpression.java b/java/javax/el/MethodExpression.java index a0a7e697d3..a364f0fe63 100644 --- a/java/javax/el/MethodExpression.java +++ b/java/javax/el/MethodExpression.java @@ -25,15 +25,11 @@ public abstract class MethodExpression extends Expression { * * @return Information about the method that this expression resolves to * - * @throws NullPointerException - * If the supplied context is <code>null</code> - * @throws PropertyNotFoundException - * If a property/variable resolution failed because no match - * was found or a match was found but was not readable - * @throws MethodNotFoundException - * If no matching method can be found - * @throws ELException - * Wraps any exception throw whilst resolving the property + * @throws NullPointerException If the supplied context is <code>null</code> + * @throws PropertyNotFoundException If a property/variable resolution failed because no match was found or a match + * was found but was not readable + * @throws MethodNotFoundException If no matching method can be found + * @throws ELException Wraps any exception throw whilst resolving the property */ public abstract MethodInfo getMethodInfo(ELContext context); @@ -43,21 +39,18 @@ public abstract class MethodExpression extends Expression { * * @return The result of invoking this method expression * - * @throws NullPointerException - * If the supplied context is <code>null</code> - * @throws PropertyNotFoundException - * If a property/variable resolution failed because no match - * was found or a match was found but was not readable - * @throws MethodNotFoundException - * If no matching method can be found - * @throws ELException - * Wraps any exception throw whilst resolving the property or - * coercion of the result to the expected return type fails + * @throws NullPointerException If the supplied context is <code>null</code> + * @throws PropertyNotFoundException If a property/variable resolution failed because no match was found or a match + * was found but was not readable + * @throws MethodNotFoundException If no matching method can be found + * @throws ELException Wraps any exception throw whilst resolving the property or coercion of the + * result to the expected return type fails */ public abstract Object invoke(ELContext context, Object[] params); /** * @return This default implementation always returns <code>false</code> + * * @since EL 3.0 */ public boolean isParametersProvided() { @@ -66,15 +59,12 @@ public abstract class MethodExpression extends Expression { } /** - * @since EL 2.2 - * - * Note: The spelling mistake is deliberate. - * isParmetersProvided() - Specification definition - * isParametersProvided() - Corrected spelling + * @since EL 2.2 Note: The spelling mistake is deliberate. isParmetersProvided() - Specification definition + * isParametersProvided() - Corrected spelling * * @return Always <code>false</code> * - * @deprecated Use {@link #isParametersProvided()} + * @deprecated Use {@link #isParametersProvided()} */ @Deprecated public boolean isParmetersProvided() { diff --git a/java/javax/el/ResourceBundleELResolver.java b/java/javax/el/ResourceBundleELResolver.java index a387232cd0..ad2163ad59 100644 --- a/java/javax/el/ResourceBundleELResolver.java +++ b/java/javax/el/ResourceBundleELResolver.java @@ -40,8 +40,7 @@ public class ResourceBundleELResolver extends ELResolver { if (property != null) { try { - return ((ResourceBundle) base).getObject(property - .toString()); + return ((ResourceBundle) base).getObject(property.toString()); } catch (MissingResourceException mre) { return "???" + property.toString() + "???"; } @@ -63,14 +62,13 @@ public class ResourceBundleELResolver 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) { Objects.requireNonNull(context); if (base instanceof ResourceBundle) { context.setPropertyResolved(base, property); - throw new PropertyNotWritableException(Util.message(context, - "resolverNotWritable", base.getClass().getName())); + throw new PropertyNotWritableException( + Util.message(context, "resolverNotWritable", base.getClass().getName())); } } @@ -87,8 +85,7 @@ public class ResourceBundleELResolver extends ELResolver { } @Override - public Iterator<FeatureDescriptor> getFeatureDescriptors( - ELContext context, Object base) { + public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) { if (base instanceof ResourceBundle) { List<FeatureDescriptor> feats = new ArrayList<>(); Enumeration<String> e = ((ResourceBundle) base).getKeys(); diff --git a/java/javax/el/StandardELContext.java b/java/javax/el/StandardELContext.java index 6e62994e74..3185c5cd34 100644 --- a/java/javax/el/StandardELContext.java +++ b/java/javax/el/StandardELContext.java @@ -30,22 +30,20 @@ public class StandardELContext extends ELContext { private final FunctionMapper functionMapper; private final CompositeELResolver standardResolver; private final CompositeELResolver customResolvers; - private final Map<String,Object> localBeans = new HashMap<>(); + private final Map<String, Object> localBeans = new HashMap<>(); public StandardELContext(ExpressionFactory factory) { wrappedContext = null; variableMapper = new StandardVariableMapper(); - functionMapper = - new StandardFunctionMapper(factory.getInitFunctionMap()); + functionMapper = new StandardFunctionMapper(factory.getInitFunctionMap()); standardResolver = new CompositeELResolver(); customResolvers = new CompositeELResolver(); ELResolver streamResolver = factory.getStreamELResolver(); // Add resolvers in order - standardResolver.add(new BeanNameELResolver( - new StandardBeanNameResolver(localBeans))); + standardResolver.add(new BeanNameELResolver(new StandardBeanNameResolver(localBeans))); standardResolver.add(customResolvers); if (streamResolver != null) { standardResolver.add(streamResolver); @@ -66,8 +64,7 @@ public class StandardELContext extends ELContext { customResolvers = new CompositeELResolver(); // Add resolvers in order - standardResolver.add(new BeanNameELResolver( - new StandardBeanNameResolver(localBeans))); + standardResolver.add(new BeanNameELResolver(new StandardBeanNameResolver(localBeans))); standardResolver.add(customResolvers); // Use resolvers from context from this point on standardResolver.add(context.getELResolver()); @@ -75,8 +72,7 @@ public class StandardELContext extends ELContext { // Can't use Class<?> because API needs to match specification @Override - public void putContext(@SuppressWarnings("rawtypes") Class key, - Object contextObject) { + public void putContext(@SuppressWarnings("rawtypes") Class key, Object contextObject) { if (wrappedContext == null) { super.putContext(key, contextObject); } else { @@ -113,7 +109,7 @@ public class StandardELContext extends ELContext { } - Map<String,Object> getLocalBeans() { + Map<String, Object> getLocalBeans() { return localBeans; } @@ -131,8 +127,7 @@ public class StandardELContext extends ELContext { } @Override - public ValueExpression setVariable(String variable, - ValueExpression expression) { + public ValueExpression setVariable(String variable, ValueExpression expression) { if (vars == null) { vars = new HashMap<>(); } @@ -147,9 +142,9 @@ public class StandardELContext extends ELContext { private static class StandardBeanNameResolver extends BeanNameResolver { - private final Map<String,Object> beans; + private final Map<String, Object> beans; - StandardBeanNameResolver(Map<String,Object> beans) { + StandardBeanNameResolver(Map<String, Object> beans) { this.beans = beans; } @@ -164,8 +159,7 @@ public class StandardELContext extends ELContext { } @Override - public void setBeanValue(String beanName, Object value) - throws PropertyNotWritableException { + public void setBeanValue(String beanName, Object value) throws PropertyNotWritableException { beans.put(beanName, value); } @@ -183,9 +177,9 @@ public class StandardELContext extends ELContext { private static class StandardFunctionMapper extends FunctionMapper { - private final Map<String,Method> methods = new HashMap<>(); + private final Map<String, Method> methods = new HashMap<>(); - StandardFunctionMapper(Map<String,Method> initFunctionMap) { + StandardFunctionMapper(Map<String, Method> initFunctionMap) { if (initFunctionMap != null) { methods.putAll(initFunctionMap); } @@ -198,8 +192,7 @@ public class StandardELContext extends ELContext { } @Override - public void mapFunction(String prefix, String localName, - Method method) { + public void mapFunction(String prefix, String localName, Method method) { String key = prefix + ':' + localName; if (method == null) { methods.remove(key); diff --git a/java/javax/el/StaticFieldELResolver.java b/java/javax/el/StaticFieldELResolver.java index 678724acfc..90f7eacd6e 100644 --- a/java/javax/el/StaticFieldELResolver.java +++ b/java/javax/el/StaticFieldELResolver.java @@ -44,17 +44,13 @@ public class StaticFieldELResolver extends ELResolver { Field field = clazz.getField(name); int modifiers = field.getModifiers(); JreCompat jreCompat = JreCompat.getInstance(); - if (Modifier.isStatic(modifiers) && - Modifier.isPublic(modifiers) && - jreCompat.canAccess(null, field)) { + if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers) && jreCompat.canAccess(null, field)) { return field.get(null); } - } catch (IllegalArgumentException | IllegalAccessException | - NoSuchFieldException | SecurityException e) { + } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) { exception = e; } - String msg = Util.message(context, "staticFieldELResolver.notFound", - name, clazz.getName()); + String msg = Util.message(context, "staticFieldELResolver.notFound", name, clazz.getName()); if (exception == null) { throw new PropertyNotFoundException(msg); } else { @@ -66,24 +62,21 @@ public class StaticFieldELResolver 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) { Objects.requireNonNull(context); if (base instanceof ELClass && property instanceof String) { Class<?> clazz = ((ELClass) base).getKlass(); String name = (String) property; - throw new PropertyNotWritableException(Util.message(context, - "staticFieldELResolver.notWritable", name, - clazz.getName())); + throw new PropertyNotWritableException( + Util.message(context, "staticFieldELResolver.notWritable", name, clazz.getName())); } } @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) { Objects.requireNonNull(context); if (base instanceof ELClass && method instanceof String) { @@ -95,8 +88,8 @@ public class StaticFieldELResolver extends ELResolver { if ("<init>".equals(methodName)) { Constructor<?> match = Util.findConstructor(context, clazz, paramTypes, params); - Object[] parameters = Util.buildParameters( - context, match.getParameterTypes(), match.isVarArgs(), params); + Object[] parameters = Util.buildParameters(context, match.getParameterTypes(), match.isVarArgs(), + params); Object result = null; @@ -119,13 +112,12 @@ public class StaticFieldELResolver extends ELResolver { // unnecessary because the canAccess() call in Util.findMethod() // effectively performs the same check if (match == null || !Modifier.isStatic(match.getModifiers())) { - throw new MethodNotFoundException(Util.message(context, - "staticFieldELResolver.methodNotFound", methodName, - clazz.getName())); + throw new MethodNotFoundException( + Util.message(context, "staticFieldELResolver.methodNotFound", methodName, clazz.getName())); } - Object[] parameters = Util.buildParameters( - context, match.getParameterTypes(), match.isVarArgs(), params); + Object[] parameters = Util.buildParameters(context, match.getParameterTypes(), match.isVarArgs(), + params); Object result = null; try { @@ -157,17 +149,13 @@ public class StaticFieldELResolver extends ELResolver { Field field = clazz.getField(name); int modifiers = field.getModifiers(); JreCompat jreCompat = JreCompat.getInstance(); - if (Modifier.isStatic(modifiers) && - Modifier.isPublic(modifiers) && - jreCompat.canAccess(null, field)) { + if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers) && jreCompat.canAccess(null, field)) { return field.getType(); } - } catch (IllegalArgumentException | NoSuchFieldException | - SecurityException e) { + } catch (IllegalArgumentException | NoSuchFieldException | SecurityException e) { exception = e; } - String msg = Util.message(context, "staticFieldELResolver.notFound", - name, clazz.getName()); + String msg = Util.message(context, "staticFieldELResolver.notFound", name, clazz.getName()); if (exception == null) { throw new PropertyNotFoundException(msg); } else { @@ -193,8 +181,7 @@ public class StaticFieldELResolver extends ELResolver { * Always returns <code>null</code>. */ @Override - public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, - Object base) { + public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) { return null; } diff --git a/java/javax/el/TypeConverter.java b/java/javax/el/TypeConverter.java index 6c4d8dc833..c5940816e3 100644 --- a/java/javax/el/TypeConverter.java +++ b/java/javax/el/TypeConverter.java @@ -35,8 +35,7 @@ public abstract class TypeConverter 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 } @@ -46,8 +45,7 @@ public abstract class TypeConverter extends ELResolver { } @Override - public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, - Object base) { + public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) { return null; } @@ -57,6 +55,5 @@ public abstract class TypeConverter extends ELResolver { } @Override - public abstract Object convertToType(ELContext context, Object obj, - Class<?> type); + public abstract Object convertToType(ELContext context, Object obj, Class<?> type); } diff --git a/java/javax/el/Util.java b/java/javax/el/Util.java index cc7fdeea41..39851025f2 100644 --- a/java/javax/el/Util.java +++ b/java/javax/el/Util.java @@ -67,8 +67,8 @@ class Util { /** - * 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 */ static void handleThrowable(Throwable t) { @@ -93,8 +93,7 @@ class Util { return ""; } } - ResourceBundle bundle = ResourceBundle.getBundle( - "javax.el.LocalStrings", locale); + ResourceBundle bundle = ResourceBundle.getBundle("javax.el.LocalStrings", locale); try { String template = bundle.getString(name); if (props != null) { @@ -108,12 +107,11 @@ class Util { private static final CacheValue nullTcclFactory = new CacheValue(); - private static final ConcurrentMap<CacheKey, CacheValue> factoryCache = - new ConcurrentHashMap<>(); + private static final ConcurrentMap<CacheKey, CacheValue> factoryCache = new ConcurrentHashMap<>(); /** - * Provides a per class loader cache of ExpressionFactory instances without - * pinning any in memory as that could trigger a memory leak. + * Provides a per class loader cache of ExpressionFactory instances without pinning any in memory as that could + * trigger a memory leak. */ static ExpressionFactory getExpressionFactory() { @@ -163,9 +161,8 @@ class Util { /** - * Key used to cache default ExpressionFactory information per class - * loader. The class loader reference is never {@code null}, because - * {@code null} tccl is handled separately. + * Key used to cache default ExpressionFactory information per class loader. The class loader reference is never + * {@code null}, because {@code null} tccl is handled separately. */ private static class CacheKey { private final int hash; @@ -219,16 +216,14 @@ class Util { /* - * This method duplicates code in org.apache.el.util.ReflectionUtil. When - * making changes keep the code in sync. + * This method duplicates code in org.apache.el.util.ReflectionUtil. When making changes keep the code in sync. */ - static Method findMethod(ELContext context, Class<?> clazz, Object base, String methodName, - Class<?>[] paramTypes, Object[] paramValues) { + static Method findMethod(ELContext context, Class<?> clazz, Object base, String methodName, Class<?>[] paramTypes, + Object[] paramValues) { if (clazz == null || methodName == null) { throw new MethodNotFoundException( - message(null, "util.method.notfound", clazz, methodName, - paramString(paramTypes))); + message(null, "util.method.notfound", clazz, methodName, paramString(paramTypes))); } if (paramTypes == null) { @@ -245,14 +240,13 @@ class Util { } /* - * This method duplicates code in org.apache.el.util.ReflectionUtil. When - * making changes keep the code in sync. + * This method duplicates code in org.apache.el.util.ReflectionUtil. When making changes keep the code in sync. */ @SuppressWarnings("null") - private static <T> Wrapper<T> findWrapper(ELContext context, Class<?> clazz, List<Wrapper<T>> wrappers, - String name, Class<?>[] paramTypes, Object[] paramValues) { + private static <T> Wrapper<T> findWrapper(ELContext context, Class<?> clazz, List<Wrapper<T>> wrappers, String name, + Class<?>[] paramTypes, Object[] paramValues) { - Map<Wrapper<T>,MatchResult> candidates = new HashMap<>(); + Map<Wrapper<T>, MatchResult> candidates = new HashMap<>(); int paramCount = paramTypes.length; @@ -271,17 +265,16 @@ class Util { // Method has wrong number of parameters continue; } - if (w.isVarArgs() && paramCount < mParamCount -1) { + if (w.isVarArgs() && paramCount < mParamCount - 1) { // Method has wrong number of parameters continue; } - if (w.isVarArgs() && paramCount == mParamCount && paramValues != null && - paramValues.length > paramCount && !paramTypes[mParamCount -1].isArray()) { + if (w.isVarArgs() && paramCount == mParamCount && paramValues != null && paramValues.length > paramCount && + !paramTypes[mParamCount - 1].isArray()) { // Method arguments don't match continue; } - if (w.isVarArgs() && paramCount > mParamCount && paramValues != null && - paramValues.length != paramCount) { + if (w.isVarArgs() && paramCount > mParamCount && paramValues != null && paramValues.length != paramCount) { // Might match a different varargs method continue; } @@ -358,8 +351,8 @@ class Util { return w; } - candidates.put(w, new MatchResult( - w.isVarArgs(), exactMatch, assignableMatch, coercibleMatch, varArgsMatch, w.isBridge())); + candidates.put(w, new MatchResult(w.isVarArgs(), exactMatch, assignableMatch, coercibleMatch, varArgsMatch, + w.isBridge())); } // Look for the method that has the highest number of parameters where @@ -389,17 +382,15 @@ class Util { if (match == null) { // If multiple methods have the same matching number of parameters // the match is ambiguous so throw an exception - throw new MethodNotFoundException(message( - null, "util.method.ambiguous", clazz, name, - paramString(paramTypes))); + throw new MethodNotFoundException( + message(null, "util.method.ambiguous", clazz, name, paramString(paramTypes))); } } // Handle case where no match at all was found if (match == null) { - throw new MethodNotFoundException(message( - null, "util.method.notfound", clazz, name, - paramString(paramTypes))); + throw new MethodNotFoundException( + message(null, "util.method.notfound", clazz, name, paramString(paramTypes))); } return match; @@ -426,11 +417,9 @@ class Util { /* - * This method duplicates code in org.apache.el.util.ReflectionUtil. When - * making changes keep the code in sync. + * This method duplicates code in org.apache.el.util.ReflectionUtil. When making changes keep the code in sync. */ - private static <T> Wrapper<T> resolveAmbiguousWrapper(Set<Wrapper<T>> candidates, - Class<?>[] paramTypes) { + private static <T> Wrapper<T> resolveAmbiguousWrapper(Set<Wrapper<T>> candidates, Class<?>[] paramTypes) { // Identify which parameter isn't an exact match Wrapper<T> w = candidates.iterator().next(); @@ -475,8 +464,7 @@ class Util { if (Number.class.isAssignableFrom(nonMatchClass)) { for (Wrapper<T> 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 { @@ -493,8 +481,7 @@ class Util { /* - * This method duplicates code in org.apache.el.util.ReflectionUtil. When - * making changes keep the code in sync. + * This method duplicates code in org.apache.el.util.ReflectionUtil. When making changes keep the code in sync. */ static boolean isAssignableFrom(Class<?> src, Class<?> target) { // src will always be an object @@ -531,12 +518,11 @@ class Util { /* - * This method duplicates code in org.apache.el.util.ReflectionUtil. When - * making changes keep the code in sync. + * This method duplicates code in org.apache.el.util.ReflectionUtil. When making changes keep the code in sync. */ private static boolean isCoercibleFrom(ELContext context, 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 { context.convertToType(src, target); } catch (ELException e) { @@ -564,14 +550,13 @@ class Util { /* - * This method duplicates code in org.apache.el.util.ReflectionUtil. When - * making changes keep the code in sync. + * This method duplicates code in org.apache.el.util.ReflectionUtil. When making changes keep the code in sync. */ static Method getMethod(Class<?> type, Object base, Method m) { JreCompat jreCompat = JreCompat.getInstance(); - if (m == null || - (Modifier.isPublic(type.getModifiers()) && - (Modifier.isStatic(m.getModifiers()) && jreCompat.canAccess(null, m) || jreCompat.canAccess(base, m)))) { + if (m == null || (Modifier.isPublic(type.getModifiers()) && + (Modifier.isStatic(m.getModifiers()) && jreCompat.canAccess(null, m) || + jreCompat.canAccess(base, m)))) { return m; } Class<?>[] interfaces = type.getInterfaces(); @@ -610,8 +595,7 @@ class Util { if (clazz == null) { throw new MethodNotFoundException( - message(null, "util.method.notfound", null, methodName, - paramString(paramTypes))); + message(null, "util.method.notfound", null, methodName, paramString(paramTypes))); } if (paramTypes == null) { @@ -628,16 +612,15 @@ class Util { JreCompat jreCompat = JreCompat.getInstance(); if (!Modifier.isPublic(clazz.getModifiers()) || !jreCompat.canAccess(null, constructor)) { - throw new MethodNotFoundException(message( - null, "util.method.notfound", clazz, methodName, - paramString(paramTypes))); + throw new MethodNotFoundException( + message(null, "util.method.notfound", clazz, methodName, paramString(paramTypes))); } return constructor; } - static Object[] buildParameters(ELContext context, Class<?>[] parameterTypes, boolean isVarArgs,Object[] params) { + static Object[] buildParameters(ELContext context, Class<?>[] parameterTypes, boolean isVarArgs, Object[] params) { Object[] parameters = null; if (parameterTypes.length > 0) { parameters = new Object[parameterTypes.length]; @@ -704,8 +687,11 @@ class Util { } public abstract T unWrap(); + public abstract Class<?>[] getParameterTypes(); + public abstract boolean isVarArgs(); + public abstract boolean isBridge(); } @@ -767,8 +753,7 @@ class Util { } /* - * This class duplicates code in org.apache.el.util.ReflectionUtil. When - * making changes keep the code in sync. + * This class duplicates code in org.apache.el.util.ReflectionUtil. When making changes keep the code in sync. */ private static class MatchResult implements Comparable<MatchResult> { @@ -842,14 +827,13 @@ class Util { @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).getCoercibleCount() == this.getCoercibleCount() && - ((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).getCoercibleCount() == this.getCoercibleCount() && + ((MatchResult) o).getVarArgsCount() == this.getVarArgsCount() && + ((MatchResult) o).isVarArgs() == this.isVarArgs() && + ((MatchResult) o).isBridge() == this.isBridge()); } @Override diff --git a/java/javax/el/ValueExpression.java b/java/javax/el/ValueExpression.java index ffdf8ccaab..86c9c57d89 100644 --- a/java/javax/el/ValueExpression.java +++ b/java/javax/el/ValueExpression.java @@ -25,50 +25,34 @@ public abstract class ValueExpression extends Expression { * * @return The result of evaluating this value expression * - * @throws NullPointerException - * If the supplied context is <code>null</code> - * @throws PropertyNotFoundException - * If a property/variable resolution failed because no match - * was found or a match was found but was not readable - * @throws ELException - * Wraps any exception throw whilst resolving a property or - * variable + * @throws NullPointerException If the supplied context is <code>null</code> + * @throws PropertyNotFoundException If a property/variable resolution failed because no match was found or a match + * was found but was not readable + * @throws ELException Wraps any exception throw whilst resolving a property or variable */ public abstract Object getValue(ELContext context); /** * @param context The EL context for this evaluation - * @param value The value to set the property to which this value - * expression refers + * @param value The value to set the property to which this value expression refers * - * @throws NullPointerException - * If the supplied context is <code>null</code> - * @throws PropertyNotFoundException - * If a property/variable resolution failed because no match - * was found - * @throws PropertyNotWritableException - * If a property/variable resolution failed because a match was - * found but was not writable - * @throws ELException - * Wraps any exception throw whilst resolving a property or - * variable + * @throws NullPointerException If the supplied context is <code>null</code> + * @throws PropertyNotFoundException If a property/variable resolution failed because no match was found + * @throws PropertyNotWritableException If a property/variable resolution failed because a match was found but was + * not writable + * @throws ELException Wraps any exception throw whilst resolving a property or variable */ public abstract void setValue(ELContext context, Object value); /** * @param context The EL context for this evaluation * - * @return <code>true</code> if this expression is read only otherwise - * <code>false</code> + * @return <code>true</code> if this expression is read only otherwise <code>false</code> * - * @throws NullPointerException - * If the supplied context is <code>null</code> - * @throws PropertyNotFoundException - * If a property/variable resolution failed because no match - * was found or a match was found but was not readable - * @throws ELException - * Wraps any exception throw whilst resolving a property or - * variable + * @throws NullPointerException If the supplied context is <code>null</code> + * @throws PropertyNotFoundException If a property/variable resolution failed because no match was found or a match + * was found but was not readable + * @throws ELException Wraps any exception throw whilst resolving a property or variable */ public abstract boolean isReadOnly(ELContext context); @@ -77,14 +61,10 @@ public abstract class ValueExpression extends Expression { * * @return The type of the result of this value expression * - * @throws NullPointerException - * If the supplied context is <code>null</code> - * @throws PropertyNotFoundException - * If a property/variable resolution failed because no match - * was found or a match was found but was not readable - * @throws ELException - * Wraps any exception throw whilst resolving a property or - * variable + * @throws NullPointerException If the supplied context is <code>null</code> + * @throws PropertyNotFoundException If a property/variable resolution failed because no match was found or a match + * was found but was not readable + * @throws ELException Wraps any exception throw whilst resolving a property or variable */ public abstract Class<?> getType(ELContext context); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org