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

(-)java/org/apache/el/parser/AstValue.java (-4 / +24 lines)
Lines 37-43 Link Here
37
 * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author$
37
 * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author$
38
 */
38
 */
39
public final class AstValue extends SimpleNode {
39
public final class AstValue extends SimpleNode {
40
    private static final boolean STRICT_JSP_COMPLIANCE;
40
41
42
    static {
43
        STRICT_JSP_COMPLIANCE = "true".equals(System.getProperty(
44
                "org.apache.catalina.STRICT_JSP_COMPLIANCE", "false"));
45
    }
46
41
    protected static class Target {
47
    protected static class Target {
42
        protected Object base;
48
        protected Object base;
43
49
Lines 129-140 Link Here
129
        Target t = getTarget(ctx);
135
        Target t = getTarget(ctx);
130
        ctx.setPropertyResolved(false);
136
        ctx.setPropertyResolved(false);
131
        ELResolver resolver = ctx.getELResolver();
137
        ELResolver resolver = ctx.getELResolver();
132
        resolver.setValue(ctx, t.base, t.property, 
138
133
        		// coerce to the expected type
139
        // coerce to the expected type
134
        		ELSupport.coerceToType(value, 
140
        Class<?> targetClass = resolver.getType(ctx, t.base, t.property);
135
        				resolver.getType(ctx, t.base, t.property)));
141
        if (STRICT_JSP_COMPLIANCE == true
142
                || !isAssignable(value, targetClass)) {
143
            value = ELSupport.coerceToType(value, targetClass);
144
        }
145
146
        resolver.setValue(ctx, t.base, t.property, value);
136
    }
147
    }
137
148
149
    private boolean isAssignable(Object value, Class<?> targetClass) {
150
        if (value != null && targetClass.isPrimitive()) {
151
            return false;
152
        } else if (value != null && !targetClass.isInstance(value)) {
153
            return false;
154
        }
155
        return true;
156
    }
157
138
    public MethodInfo getMethodInfo(EvaluationContext ctx, Class[] paramTypes)
158
    public MethodInfo getMethodInfo(EvaluationContext ctx, Class[] paramTypes)
139
            throws ELException {
159
            throws ELException {
140
        Target t = getTarget(ctx);
160
        Target t = getTarget(ctx);

Return to bug 43285