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

Alessio Stalla astalla at common-lisp.net
Tue May 5 22:01:52 UTC 2009


Author: astalla
Date: Tue May  5 18:01:50 2009
New Revision: 11834

Log:
Relaxed type checking when invoking Java methods from Lisp, as discussed on the mailing list.


Modified:
   trunk/abcl/src/org/armedbear/lisp/Java.java
   trunk/abcl/src/org/armedbear/lisp/LispObject.java

Modified: trunk/abcl/src/org/armedbear/lisp/Java.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Java.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/Java.java	Tue May  5 18:01:50 2009
@@ -625,10 +625,7 @@
         else if (instanceArg instanceof JavaObject)
             instance = ((JavaObject)instanceArg).getObject();
         else {
-            type_error(instanceArg,
-                            list(Symbol.OR, Symbol.STRING, Symbol.JAVA_OBJECT));
-            // Not reached.
-            return null;
+	    instance = instanceArg.javaInstance();
         }
         try {
             final Method method;

Modified: trunk/abcl/src/org/armedbear/lisp/LispObject.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/LispObject.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/LispObject.java	Tue May  5 18:01:50 2009
@@ -102,16 +102,14 @@
   public Object javaInstance() throws ConditionThrowable
   {
         return this;
-    /*return error(new LispError("The value " + writeToString() +
-                                " is not of primitive type."));*/
   }
 
   public Object javaInstance(Class c) throws ConditionThrowable
   {
-    if (c == LispObject.class)
-      return this;
-    return error(new LispError("The value " + writeToString() +
-                                " is not of primitive type."));
+      if (getClass().isAssignableFrom(c))
+	  return this;
+      return error(new LispError("The value " + writeToString() +
+				 " is not of class " + c.getName()));
   }
 
   public LispObject car() throws ConditionThrowable




More information about the armedbear-cvs mailing list