Ignore:
Timestamp:
06/14/11 09:20:56 (10 years ago)
Author:
Mark Evenson
Message:

Allow JCOERCE to convert any number to java.lang.Byte.

Maps any number passed to to its two's complement 8bit byte
representation, meaning that it will which may not be what one would
wish.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/JavaObject.java

    r13278 r13327  
    6969            intendedClass = Java.maybeBoxClass(intendedClass);
    7070            if(!intendedClass.isInstance(obj)) {
     71                if (intendedClass.equals(java.lang.Byte.class)
     72                    && obj instanceof java.lang.Number) {
     73                    // Maps any number to two's complement 8bit byte representation
     74                    // ??? Is this a reasonable thing?
     75                    this.obj = ((java.lang.Number)obj).byteValue();
     76                    this.intendedClass = intendedClass;
     77                    return;
     78                }
    7179                throw new ClassCastException(obj + " can not be cast to " + intendedClass);
    7280            }
Note: See TracChangeset for help on using the changeset viewer.