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

(-)java/org/apache/el/lang/ELSupport.java (-4 / +1 lines)
Lines 343-349 Link Here
343
    public final static Object coerceToType(final Object obj, final Class type)
343
    public final static Object coerceToType(final Object obj, final Class type)
344
            throws IllegalArgumentException {
344
            throws IllegalArgumentException {
345
        if (type == null || Object.class.equals(type) ||
345
        if (type == null || Object.class.equals(type) ||
346
                (obj != null && type.equals(obj.getClass()))) {
346
                (obj != null && type.isAssignableFrom(obj.getClass()))) {
347
            return obj;
347
            return obj;
348
        }
348
        }
349
        if (String.class.equals(type)) {
349
        if (String.class.equals(type)) {
Lines 358-366 Link Here
358
        if (Boolean.class.equals(type) || Boolean.TYPE == type) {
358
        if (Boolean.class.equals(type) || Boolean.TYPE == type) {
359
            return coerceToBoolean(obj);
359
            return coerceToBoolean(obj);
360
        }
360
        }
361
        if (obj != null && type.isAssignableFrom(obj.getClass())) {
362
            return obj;
363
        }
364
        if (type.isEnum()) {
361
        if (type.isEnum()) {
365
            return coerceToEnum(obj, type);
362
            return coerceToEnum(obj, type);
366
        }
363
        }
(-)test/org/apache/el/lang/TestELSupport.java (+6 lines)
Lines 56-61 Link Here
56
        testIsSame(Float.valueOf(0.123456F));
56
        testIsSame(Float.valueOf(0.123456F));
57
    }
57
    }
58
58
59
    public void testCoerceIntegerToNumber() {
60
        Integer input = 4390241;
61
        Object output = ELSupport.coerceToType(input, Number.class);
62
        assertEquals(input, output);
63
    }
64
59
    private static void testIsSame(Object value) {
65
    private static void testIsSame(Object value) {
60
        assertEquals(value, ELSupport.coerceToNumber(value, value.getClass()));
66
        assertEquals(value, ELSupport.coerceToNumber(value, value.getClass()));
61
    }
67
    }

Return to bug 43656