[armedbear-cvs] r13327 - trunk/abcl/src/org/armedbear/lisp

mevenson at common-lisp.net mevenson at common-lisp.net
Tue Jun 14 09:20:58 UTC 2011


Author: mevenson
Date: Tue Jun 14 02:20:56 2011
New Revision: 13327

Log:
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.

Modified:
   trunk/abcl/src/org/armedbear/lisp/JavaObject.java

Modified: trunk/abcl/src/org/armedbear/lisp/JavaObject.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/JavaObject.java	Fri Jun 10 08:53:12 2011	(r13326)
+++ trunk/abcl/src/org/armedbear/lisp/JavaObject.java	Tue Jun 14 02:20:56 2011	(r13327)
@@ -68,6 +68,14 @@
         if(intendedClass != null) {
             intendedClass = Java.maybeBoxClass(intendedClass);
             if(!intendedClass.isInstance(obj)) {
+                if (intendedClass.equals(java.lang.Byte.class)
+                    && obj instanceof java.lang.Number) {
+                    // Maps any number to two's complement 8bit byte representation
+                    // ??? Is this a reasonable thing?
+                    this.obj = ((java.lang.Number)obj).byteValue();
+                    this.intendedClass = intendedClass;
+                    return;
+                }
                 throw new ClassCastException(obj + " can not be cast to " + intendedClass);
             }
         }




More information about the armedbear-cvs mailing list