This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push:
new 8b4e81d375 Follow-up to bad types in JspRuntime fix
8b4e81d375 is described below
commit 8b4e81d37524e741e5fe36e7a1e4946a22a4815a
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Jun 1 21:20:40 2026 +0100
Follow-up to bad types in JspRuntime fix
An array created as Object[] cannot be cast to a different array type so
the array needs to be created using the correct type.
Fix the same issue in AstValue
---
java/org/apache/el/parser/AstValue.java | 106 ++++++++++++++++++++-
.../apache/jasper/runtime/JspRuntimeLibrary.java | 7 +-
2 files changed, 106 insertions(+), 7 deletions(-)
diff --git a/java/org/apache/el/parser/AstValue.java
b/java/org/apache/el/parser/AstValue.java
index bea041a22e..e0e53e7eeb 100644
--- a/java/org/apache/el/parser/AstValue.java
+++ b/java/org/apache/el/parser/AstValue.java
@@ -310,11 +310,109 @@ public final class AstValue extends SimpleNode {
if (m.isVarArgs()) {
Class<?> varArgType = m.getParameterTypes()[paramCount -
1].getComponentType();
- Object[] varArgs = (Object[]) Array.newInstance(varArgType,
src.length - (paramCount - 1));
- for (int i = 0; i < src.length - (paramCount - 1); i++) {
- varArgs[i] = ELSupport.coerceToType(ctx, src[paramCount - 1 +
i], varArgType);
+ if (varArgType.equals(Integer.class)) {
+ Integer[] varArgs = new Integer[src.length - (paramCount - 1)];
+ for (int i = 0; i < src.length - (paramCount - 1); i++) {
+ varArgs[i] = ELSupport.coerceToType(ctx, src[paramCount -
1 + i], Integer.class);
+ }
+ dest[paramCount - 1] = varArgs;
+ } else if (varArgType.equals(Byte.class)) {
+ Byte[] varArgs = new Byte[src.length - (paramCount - 1)];
+ for (int i = 0; i < src.length - (paramCount - 1); i++) {
+ varArgs[i] = ELSupport.coerceToType(ctx, src[paramCount -
1 + i], Byte.class);
+ }
+ dest[paramCount - 1] = varArgs;
+ } else if (varArgType.equals(Boolean.class)) {
+ Boolean[] varArgs = new Boolean[src.length - (paramCount - 1)];
+ for (int i = 0; i < src.length - (paramCount - 1); i++) {
+ varArgs[i] = ELSupport.coerceToType(ctx, src[paramCount -
1 + i], Boolean.class);
+ }
+ dest[paramCount - 1] = varArgs;
+ } else if (varArgType.equals(Short.class)) {
+ Short[] varArgs = new Short[src.length - (paramCount - 1)];
+ for (int i = 0; i < src.length - (paramCount - 1); i++) {
+ varArgs[i] = ELSupport.coerceToType(ctx, src[paramCount -
1 + i], Short.class);
+ }
+ dest[paramCount - 1] = varArgs;
+ } else if (varArgType.equals(Long.class)) {
+ Long[] varArgs = new Long[src.length - (paramCount - 1)];
+ for (int i = 0; i < src.length - (paramCount - 1); i++) {
+ varArgs[i] = ELSupport.coerceToType(ctx, src[paramCount -
1 + i], Long.class);
+ }
+ dest[paramCount - 1] = varArgs;
+ } else if (varArgType.equals(Double.class)) {
+ Double[] varArgs = new Double[src.length - (paramCount - 1)];
+ for (int i = 0; i < src.length - (paramCount - 1); i++) {
+ varArgs[i] = ELSupport.coerceToType(ctx, src[paramCount -
1 + i], Double.class);
+ }
+ dest[paramCount - 1] = varArgs;
+ } else if (varArgType.equals(Float.class)) {
+ Float[] varArgs = new Float[src.length - (paramCount - 1)];
+ for (int i = 0; i < src.length - (paramCount - 1); i++) {
+ varArgs[i] = ELSupport.coerceToType(ctx, src[paramCount -
1 + i], Float.class);
+ }
+ dest[paramCount - 1] = varArgs;
+ } else if (varArgType.equals(Character.class)) {
+ Character[] varArgs = new Character[src.length - (paramCount -
1)];
+ for (int i = 0; i < src.length - (paramCount - 1); i++) {
+ varArgs[i] = ELSupport.coerceToType(ctx, src[paramCount -
1 + i], Character.class);
+ }
+ dest[paramCount - 1] = varArgs;
+ } else if (varArgType.equals(int.class)) {
+ int[] varArgs = new int[src.length - (paramCount - 1)];
+ for (int i = 0; i < src.length - (paramCount - 1); i++) {
+ varArgs[i] = ELSupport.coerceToType(ctx, src[paramCount -
1 + i], int.class).intValue();
+ }
+ dest[paramCount - 1] = varArgs;
+ } else if (varArgType.equals(byte.class)) {
+ byte[] varArgs = new byte[src.length - (paramCount - 1)];
+ for (int i = 0; i < src.length - (paramCount - 1); i++) {
+ varArgs[i] = ELSupport.coerceToType(ctx, src[paramCount -
1 + i], byte.class).byteValue();
+ }
+ dest[paramCount - 1] = varArgs;
+ } else if (varArgType.equals(boolean.class)) {
+ boolean[] varArgs = new boolean[src.length - (paramCount - 1)];
+ for (int i = 0; i < src.length - (paramCount - 1); i++) {
+ varArgs[i] = ELSupport.coerceToType(ctx, src[paramCount -
1 + i], boolean.class).booleanValue();
+ }
+ dest[paramCount - 1] = varArgs;
+ } else if (varArgType.equals(short.class)) {
+ short[] varArgs = new short[src.length - (paramCount - 1)];
+ for (int i = 0; i < src.length - (paramCount - 1); i++) {
+ varArgs[i] = ELSupport.coerceToType(ctx, src[paramCount -
1 + i], short.class).shortValue();
+ }
+ dest[paramCount - 1] = varArgs;
+ } else if (varArgType.equals(long.class)) {
+ long[] varArgs = new long[src.length - (paramCount - 1)];
+ for (int i = 0; i < src.length - (paramCount - 1); i++) {
+ varArgs[i] = ELSupport.coerceToType(ctx, src[paramCount -
1 + i], long.class).longValue();
+ }
+ dest[paramCount - 1] = varArgs;
+ } else if (varArgType.equals(double.class)) {
+ double[] varArgs = new double[src.length - (paramCount - 1)];
+ for (int i = 0; i < src.length - (paramCount - 1); i++) {
+ varArgs[i] = ELSupport.coerceToType(ctx, src[paramCount -
1 + i], double.class).doubleValue();
+ }
+ dest[paramCount - 1] = varArgs;
+ } else if (varArgType.equals(float.class)) {
+ float[] varArgs = new float[src.length - (paramCount - 1)];
+ for (int i = 0; i < src.length - (paramCount - 1); i++) {
+ varArgs[i] = ELSupport.coerceToType(ctx, src[paramCount -
1 + i], float.class).floatValue();
+ }
+ dest[paramCount - 1] = varArgs;
+ } else if (varArgType.equals(char.class)) {
+ char[] varArgs = new char[src.length - (paramCount - 1)];
+ for (int i = 0; i < src.length - (paramCount - 1); i++) {
+ varArgs[i] = ELSupport.coerceToType(ctx, src[paramCount -
1 + i], char.class).charValue();
+ }
+ dest[paramCount - 1] = varArgs;
+ } else {
+ Object[] varArgs = (Object[]) Array.newInstance(varArgType,
src.length - (paramCount - 1));
+ for (int i = 0; i < src.length - (paramCount - 1); i++) {
+ varArgs[i] = ELSupport.coerceToType(ctx, src[paramCount -
1 + i], varArgType);
+ }
+ dest[paramCount - 1] = varArgs;
}
- dest[paramCount - 1] = varArgs;
} else {
dest[paramCount - 1] = ELSupport.coerceToType(ctx, src[paramCount
- 1], types[paramCount - 1]);
}
diff --git a/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
b/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
index 694e58eb89..3d0ac29691 100644
--- a/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
+++ b/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
@@ -19,6 +19,7 @@ package org.apache.jasper.runtime;
import java.beans.PropertyEditor;
import java.beans.PropertyEditorManager;
import java.io.IOException;
+import java.lang.reflect.Array;
import java.lang.reflect.Method;
import java.net.URLEncoder;
import java.nio.charset.Charset;
@@ -567,9 +568,9 @@ public class JspRuntimeLibrary {
try {
if (propertyEditorClass != null) {
- Object[] tmpval = new Object[values.length];
+ Object tmpval = Array.newInstance(t, values.length);
for (int i = 0; i < values.length; i++) {
- tmpval[i] = getValueFromBeanInfoPropertyEditor(t,
propertyName, values[i], propertyEditorClass);
+ Array.set(tmpval, i, getValueFromBeanInfoPropertyEditor(t,
propertyName, values[i], propertyEditorClass));
}
method.invoke(bean, new Object[] { tmpval });
} else if (t.equals(Integer.class)) {
@@ -669,7 +670,7 @@ public class JspRuntimeLibrary {
}
method.invoke(bean, new Object[] { tmpval });
} else {
- Object[] tmpval = new Object[values.length];
+ Object[] tmpval = (Object[]) Array.newInstance(t,
values.length);
for (int i = 0; i < values.length; i++) {
tmpval[i] = getValueFromPropertyEditorManager(t,
propertyName, values[i]);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]