View | Details | Raw Unified | Return to bug 44294
Collapse All | Expand All

(-)org/apache/el/lang/ExpressionBuilder.java (-15 / +3 lines)
Lines 158-182 Link Here
158
	 * @see com.sun.el.parser.NodeVisitor#visit(com.sun.el.parser.Node)
158
	 * @see com.sun.el.parser.NodeVisitor#visit(com.sun.el.parser.Node)
159
	 */
159
	 */
160
	public void visit(Node node) throws ELException {
160
	public void visit(Node node) throws ELException {
161
		if (node instanceof AstFunction) {
161
		if (node instanceof AstFunction && this.fnMapper != null) {
162
162
163
			AstFunction funcNode = (AstFunction) node;
163
			AstFunction funcNode = (AstFunction) node;
164
164
165
			if (this.fnMapper == null) {
165
			// simply capture it
166
				throw new ELException(MessageFactory.get("error.fnMapper.null"));
166
			this.fnMapper.resolveFunction(funcNode.getPrefix(), funcNode
167
			}
168
			Method m = fnMapper.resolveFunction(funcNode.getPrefix(), funcNode
169
					.getLocalName());
167
					.getLocalName());
170
			if (m == null) {
171
				throw new ELException(MessageFactory.get(
172
						"error.fnMapper.method", funcNode.getOutputName()));
173
			}
174
			int pcnt = m.getParameterTypes().length;
175
			if (node.jjtGetNumChildren() != pcnt) {
176
				throw new ELException(MessageFactory.get(
177
						"error.fnMapper.paramcount", funcNode.getOutputName(),
178
						"" + pcnt, "" + node.jjtGetNumChildren()));
179
			}
180
		} else if (node instanceof AstIdentifier && this.varMapper != null) {
168
		} else if (node instanceof AstIdentifier && this.varMapper != null) {
181
			String variable = ((AstIdentifier) node).getImage();
169
			String variable = ((AstIdentifier) node).getImage();
182
170
(-)org/apache/el/parser/AstFunction.java (-2 / +18 lines)
Lines 94-106 Link Here
94
        Object[] params = null;
94
        Object[] params = null;
95
        Object result = null;
95
        Object result = null;
96
        int numParams = this.jjtGetNumChildren();
96
        int numParams = this.jjtGetNumChildren();
97
		int pcnt = paramTypes.length;
98
		if (m.isVarArgs() ? pcnt - 1 > numParams : numParams != pcnt ) {
99
			throw new ELException(MessageFactory.get(
100
					"error.fnMapper.paramcount", this.getOutputName(),
101
					"" + pcnt, "" + numParams));
102
		}
97
        if (numParams > 0) {
103
        if (numParams > 0) {
98
            params = new Object[numParams];
104
            params = new Object[paramTypes.length];
99
            try {
105
            try {
100
                for (int i = 0; i < numParams; i++) {
106
                int lastParam  = m.isVarArgs() ? pcnt - 1 : numParams;
107
                for (int i = 0; i < lastParam ; i++) {
101
                    params[i] = this.children[i].getValue(ctx);
108
                    params[i] = this.children[i].getValue(ctx);
102
                    params[i] = coerceToType(params[i], paramTypes[i]);
109
                    params[i] = coerceToType(params[i], paramTypes[i]);
103
                }
110
                }
111
                if (m.isVarArgs()) {
112
                    Class componentType = paramTypes[lastParam].getComponentType();
113
                    Object varArgs = java.lang.reflect.Array.newInstance(componentType, numParams - lastParam);
114
                    for (int i = lastParam ; i < numParams; i++) {
115
                        Object param = this.children[i].getValue(ctx);
116
                        java.lang.reflect.Array.set(varArgs, i - lastParam , coerceToType(param, componentType));
117
                    }
118
                    params[lastParam] = varArgs;
119
                }
104
            } catch (ELException ele) {
120
            } catch (ELException ele) {
105
                throw new ELException(MessageFactory.get("error.function", this
121
                throw new ELException(MessageFactory.get("error.function", this
106
                        .getOutputName()), ele);
122
                        .getOutputName()), ele);

Return to bug 44294