--- java/org/apache/el/lang/ELSupport.java (revision 1771946) +++ java/org/apache/el/lang/ELSupport.java (working copy) @@ -24,6 +24,7 @@ import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.Set; @@ -577,6 +578,11 @@ if (type.isArray() && obj.getClass().isArray()) { return coerceToArray(ctx, obj, type); } + + // Handle lists + if (type.isArray() && List.class.isInstance(obj)) { + return coerceToArray(ctx, ((List)obj).toArray(), type); + } throw new ELException(MessageFactory.get("error.convert", obj, obj.getClass(), type)); --- java/org/apache/el/parser/AstFunction.java (revision 1771946) +++ java/org/apache/el/parser/AstFunction.java (working copy) @@ -170,6 +170,9 @@ if (m.isVarArgs() && i == methodParameterCount - 1) { if (inputParameterCount < methodParameterCount) { params[i] = null; + } else if (inputParameterCount == methodParameterCount && paramTypes[i].isArray()) { + params[i] = parameters.jjtGetChild(i).getValue(ctx); + params[i] = coerceToType(ctx, params[i], paramTypes[i]); } else { Object[] varargs = new Object[inputParameterCount - methodParameterCount + 1]; --- test/org/apache/el/parser/TestAstFunction.java (revision 1771946) +++ test/org/apache/el/parser/TestAstFunction.java (working copy) @@ -38,4 +38,31 @@ Object result = processor.getValue("valueOf(1000)", Integer.class); Assert.assertEquals(Integer.valueOf(1000), result); } + + @Test + public void testParamsToVararg() throws Exception { + ELProcessor processor = new ELProcessor(); + processor.getELManager().mapFunction("fn", "echo", TesterUtilA.class.getMethod("echo", String[].class)); + Object result = processor.getValue("fn:echo('a', 'b', 'c')", String.class); + Assert.assertEquals("a, b, c", result); + } + + @Test + public void testArrayToVararg() throws Exception { + ELProcessor processor = new ELProcessor(); + processor.getELManager().getELContext().getImportHandler() + .importStatic("org.apache.el.parser.TesterUtilA.toArray"); + processor.getELManager().mapFunction("fn", "echo", TesterUtilA.class.getMethod("echo", String[].class)); + Object result = processor.getValue("fn:echo(toArray('a', 'b'))", String.class); + Assert.assertEquals("a, b", result); + } + + @Test + public void testListToVararg() throws Exception { + ELProcessor processor = new ELProcessor(); + processor.getELManager().mapFunction("fn", "echo", TesterUtilA.class.getMethod("echo", String[].class)); + Object result = processor.getValue("fn:echo(['a', 'b'])", String.class); + Assert.assertEquals("a, b", result); + } + } --- test/org/apache/el/parser/TesterUtilA.java (nonexistent) +++ test/org/apache/el/parser/TesterUtilA.java (working copy) @@ -0,0 +1,24 @@ +package org.apache.el.parser; + +public class TesterUtilA { + + public static String echo(String...strings) { + if (strings == null) { + return null; + } + + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < strings.length; i++) { + if (i > 0) { + sb.append(", "); + } + sb.append(strings[i]); + } + return sb.toString(); + } + + public static String[] toArray(String arg1, String arg2) { + return new String[] {arg1, arg2}; + } + +}