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

(-)org/apache/el/lang/ELArithmetic.java (-5 / +2 lines)
Lines 164-171 Link Here
164
                    || obj1 instanceof Double
164
                    || obj1 instanceof Double
165
                    || obj0 instanceof Float
165
                    || obj0 instanceof Float
166
                    || obj1 instanceof Float
166
                    || obj1 instanceof Float
167
                    || (obj0 != null && (Double.TYPE == obj0.getClass() || Float.TYPE == obj0.getClass()))
168
                    || (obj1 != null && (Double.TYPE == obj1.getClass() || Float.TYPE == obj1.getClass()))
169
                    || (obj0 instanceof String && ELSupport
167
                    || (obj0 instanceof String && ELSupport
170
                            .isStringFloat((String) obj0)) || (obj1 instanceof String && ELSupport
168
                            .isStringFloat((String) obj0)) || (obj1 instanceof String && ELSupport
171
                    .isStringFloat((String) obj1)));
169
                    .isStringFloat((String) obj1)));
Lines 359-371 Link Here
359
            return coerce(ZERO);
357
            return coerce(ZERO);
360
        }
358
        }
361
359
362
        Class objType = obj.getClass();
360
        if (obj instanceof Character) {
363
        if (Character.class.equals(objType) || Character.TYPE == objType) {
364
            return coerce(new Short((short) ((Character) obj).charValue()));
361
            return coerce(new Short((short) ((Character) obj).charValue()));
365
        }
362
        }
366
363
367
        throw new IllegalArgumentException(MessageFactory.get("error.convert",
364
        throw new IllegalArgumentException(MessageFactory.get("error.convert",
368
                obj, objType, "Number"));
365
                obj, obj.getClass(), "Number"));
369
    }
366
    }
370
367
371
    protected abstract Number coerce(final String str);
368
    protected abstract Number coerce(final String str);
(-)org/apache/el/lang/ELSupport.java (-20 / +6 lines)
Lines 164-170 Link Here
164
        if (obj == null || "".equals(obj)) {
164
        if (obj == null || "".equals(obj)) {
165
            return Boolean.FALSE;
165
            return Boolean.FALSE;
166
        }
166
        }
167
        if (obj instanceof Boolean || obj.getClass() == Boolean.TYPE) {
167
        if (obj instanceof Boolean) {
168
            return (Boolean) obj;
168
            return (Boolean) obj;
169
        }
169
        }
170
        if (obj instanceof String) {
170
        if (obj instanceof String) {
Lines 187-193 Link Here
187
            return new Character((char) ((Number) obj).shortValue());
187
            return new Character((char) ((Number) obj).shortValue());
188
        }
188
        }
189
        Class objType = obj.getClass();
189
        Class objType = obj.getClass();
190
        if (obj instanceof Character || objType == Character.TYPE) {
190
        if (obj instanceof Character) {
191
            return (Character) obj;
191
            return (Character) obj;
192
        }
192
        }
193
193
Lines 259-272 Link Here
259
            return coerceToNumber((Number) obj, type);
259
            return coerceToNumber((Number) obj, type);
260
        }
260
        }
261
261
262
        Class objType = obj.getClass();
262
        if (obj instanceof Character) {
263
        if (Character.class.equals(objType) || Character.TYPE == objType) {
264
            return coerceToNumber(new Short((short) ((Character) obj)
263
            return coerceToNumber(new Short((short) ((Character) obj)
265
                    .charValue()), type);
264
                    .charValue()), type);
266
        }
265
        }
267
266
268
        throw new IllegalArgumentException(MessageFactory.get("error.convert",
267
        throw new IllegalArgumentException(MessageFactory.get("error.convert",
269
                obj, objType, type));
268
                obj, obj.getClass(), type));
270
    }
269
    }
271
270
272
    protected final static Number coerceToNumber(final String val,
271
    protected final static Number coerceToNumber(final String val,
Lines 402-411 Link Here
402
        return (obj0 instanceof Double
401
        return (obj0 instanceof Double
403
                || obj1 instanceof Double
402
                || obj1 instanceof Double
404
                || obj0 instanceof Float
403
                || obj0 instanceof Float
405
                || obj1 instanceof Float
404
                || obj1 instanceof Float);
406
                || (obj0 != null && (Double.TYPE == obj0.getClass() || Float.TYPE == obj0
407
                        .getClass())) || (obj1 != null && (Double.TYPE == obj1
408
                .getClass() || Float.TYPE == obj1.getClass())));
409
    }
405
    }
410
406
411
    public final static boolean isDoubleStringOp(final Object obj0,
407
    public final static boolean isDoubleStringOp(final Object obj0,
Lines 424-440 Link Here
424
                || obj0 instanceof Short
420
                || obj0 instanceof Short
425
                || obj1 instanceof Short
421
                || obj1 instanceof Short
426
                || obj0 instanceof Byte
422
                || obj0 instanceof Byte
427
                || obj1 instanceof Byte
423
                || obj1 instanceof Byte);
428
                || (obj0 != null && (Long.TYPE == obj0.getClass()
429
                        || Integer.TYPE == obj0.getClass()
430
                        || Character.TYPE == obj0.getClass()
431
                        || Short.TYPE == obj0.getClass() || Byte.TYPE == obj0
432
                        .getClass())) || (obj0 != null && (Long.TYPE == obj0
433
                .getClass()
434
                || Integer.TYPE == obj0.getClass()
435
                || Character.TYPE == obj0.getClass()
436
                || Short.TYPE == obj0.getClass() || Byte.TYPE == obj0
437
                .getClass())));
438
    }
424
    }
439
425
440
    public final static boolean isStringFloat(final String str) {
426
    public final static boolean isStringFloat(final String str) {
(-)org/apache/el/parser/AstNegative.java (-7 / +6 lines)
Lines 59-81 Link Here
59
            }
59
            }
60
            return new Long(-Long.parseLong((String) obj));
60
            return new Long(-Long.parseLong((String) obj));
61
        }
61
        }
62
        Class type = obj.getClass();
62
        if (obj instanceof Long) {
63
        if (obj instanceof Long || Long.TYPE == type) {
64
            return new Long(-((Long) obj).longValue());
63
            return new Long(-((Long) obj).longValue());
65
        }
64
        }
66
        if (obj instanceof Double || Double.TYPE == type) {
65
        if (obj instanceof Double) {
67
            return new Double(-((Double) obj).doubleValue());
66
            return new Double(-((Double) obj).doubleValue());
68
        }
67
        }
69
        if (obj instanceof Integer || Integer.TYPE == type) {
68
        if (obj instanceof Integer) {
70
            return new Integer(-((Integer) obj).intValue());
69
            return new Integer(-((Integer) obj).intValue());
71
        }
70
        }
72
        if (obj instanceof Float || Float.TYPE == type) {
71
        if (obj instanceof Float) {
73
            return new Float(-((Float) obj).floatValue());
72
            return new Float(-((Float) obj).floatValue());
74
        }
73
        }
75
        if (obj instanceof Short || Short.TYPE == type) {
74
        if (obj instanceof Short) {
76
            return new Short((short) -((Short) obj).shortValue());
75
            return new Short((short) -((Short) obj).shortValue());
77
        }
76
        }
78
        if (obj instanceof Byte || Byte.TYPE == type) {
77
        if (obj instanceof Byte) {
79
            return new Byte((byte) -((Byte) obj).byteValue());
78
            return new Byte((byte) -((Byte) obj).byteValue());
80
        }
79
        }
81
        Long num = (Long) coerceToNumber(obj, Long.class);
80
        Long num = (Long) coerceToNumber(obj, Long.class);

Return to bug 44766