ASF Bugzilla – Attachment 21570 Details for
Bug 44294
Support for EL functions with varargs
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
alternative.patch
alternative.patch (text/plain), 3.20 KB, created by
Tuomas Kiviaho
on 2008-02-20 03:11:58 UTC
(
hide
)
Description:
alternative.patch
Filename:
MIME Type:
Creator:
Tuomas Kiviaho
Created:
2008-02-20 03:11:58 UTC
Size:
3.20 KB
patch
obsolete
>Index: org/apache/el/lang/ExpressionBuilder.java >=================================================================== >--- org/apache/el/lang/ExpressionBuilder.java (revision 607569) >+++ org/apache/el/lang/ExpressionBuilder.java (working copy) >@@ -158,25 +158,13 @@ > * @see com.sun.el.parser.NodeVisitor#visit(com.sun.el.parser.Node) > */ > public void visit(Node node) throws ELException { >- if (node instanceof AstFunction) { >+ if (node instanceof AstFunction && this.fnMapper != null) { > > AstFunction funcNode = (AstFunction) node; > >- if (this.fnMapper == null) { >- throw new ELException(MessageFactory.get("error.fnMapper.null")); >- } >- Method m = fnMapper.resolveFunction(funcNode.getPrefix(), funcNode >+ // simply capture it >+ this.fnMapper.resolveFunction(funcNode.getPrefix(), funcNode > .getLocalName()); >- if (m == null) { >- throw new ELException(MessageFactory.get( >- "error.fnMapper.method", funcNode.getOutputName())); >- } >- int pcnt = m.getParameterTypes().length; >- if (node.jjtGetNumChildren() != pcnt) { >- throw new ELException(MessageFactory.get( >- "error.fnMapper.paramcount", funcNode.getOutputName(), >- "" + pcnt, "" + node.jjtGetNumChildren())); >- } > } else if (node instanceof AstIdentifier && this.varMapper != null) { > String variable = ((AstIdentifier) node).getImage(); > >Index: org/apache/el/parser/AstFunction.java >=================================================================== >--- org/apache/el/parser/AstFunction.java (revision 607569) >+++ org/apache/el/parser/AstFunction.java (working copy) >@@ -94,13 +94,29 @@ > Object[] params = null; > Object result = null; > int numParams = this.jjtGetNumChildren(); >+ int pcnt = paramTypes.length; >+ if (m.isVarArgs() ? pcnt - 1 > numParams : numParams != pcnt ) { >+ throw new ELException(MessageFactory.get( >+ "error.fnMapper.paramcount", this.getOutputName(), >+ "" + pcnt, "" + numParams)); >+ } > if (numParams > 0) { >- params = new Object[numParams]; >+ params = new Object[paramTypes.length]; > try { >- for (int i = 0; i < numParams; i++) { >+ int lastParam = m.isVarArgs() ? pcnt - 1 : numParams; >+ for (int i = 0; i < lastParam ; i++) { > params[i] = this.children[i].getValue(ctx); > params[i] = coerceToType(params[i], paramTypes[i]); > } >+ if (m.isVarArgs()) { >+ Class componentType = paramTypes[lastParam].getComponentType(); >+ Object varArgs = java.lang.reflect.Array.newInstance(componentType, numParams - lastParam); >+ for (int i = lastParam ; i < numParams; i++) { >+ Object param = this.children[i].getValue(ctx); >+ java.lang.reflect.Array.set(varArgs, i - lastParam , coerceToType(param, componentType)); >+ } >+ params[lastParam] = varArgs; >+ } > } catch (ELException ele) { > throw new ELException(MessageFactory.get("error.function", this > .getOutputName()), ele);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 44294
:
21426
|
21567
|
21569
| 21570 |
21593