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

astalla at common-lisp.net astalla at common-lisp.net
Wed Jun 29 22:04:37 UTC 2011


Author: astalla
Date: Wed Jun 29 15:04:37 2011
New Revision: 13368

Log:
Better separation between java-collections and the Java FFI. java-collections should be easily moved to contrib now.

Modified:
   trunk/abcl/src/org/armedbear/lisp/java-collections.lisp
   trunk/abcl/src/org/armedbear/lisp/java.lisp

Modified: trunk/abcl/src/org/armedbear/lisp/java-collections.lisp
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/java-collections.lisp	Wed Jun 29 08:35:07 2011	(r13367)
+++ trunk/abcl/src/org/armedbear/lisp/java-collections.lisp	Wed Jun 29 15:04:37 2011	(r13368)
@@ -4,6 +4,25 @@
 
 (in-package :java)
 
+(let* ((jclass (jclass "java.util.List"))
+       (class (%find-java-class jclass)))
+  (if class
+      (error "java.util.List is already registered as a Lisp class; since JAVA-CLASSes can't be redefined, I can't inject SEQUENCE in its class precedence list. Ensure that you require :java-collections before specializing any method on java.util.List and in general before using java.util.List as a CLOS class.")
+      ;;The code below is adapted from ensure-java-class in java.lisp
+      (%register-java-class
+       jclass (mop::ensure-class
+               (make-symbol (jclass-name jclass))
+               :metaclass (find-class 'java-class)
+               :direct-superclasses
+               (let ((supers
+                      (mapcar #'ensure-java-class
+                              (delete nil
+                                      (concatenate 'list
+                                                   (list (jclass-superclass jclass))
+                                                   (jclass-interfaces jclass))))))
+                 (append supers (list (find-class 'sequence)) (jclass-additional-superclasses jclass)))
+               :java-class jclass))))
+
 (defmethod print-object ((coll (jclass "java.util.Collection")) stream)
   (print-unreadable-object (coll stream :type t :identity t)
     (format stream "~A ~A"
@@ -115,7 +134,7 @@
   (declare (ignore s iterator))
   (error "iterator-copy not supported for Java iterators."))
 
-;;However, it makes sense to have some sequence functions available for Sets
+;;It makes sense to have some sequence functions available for Sets
 ;;(java.util.Set) too, even if they're not sequences.
 (defun jset-add (set item)
   (jcall (jmethod "java.util.Set" "add" "java.lang.Object")

Modified: trunk/abcl/src/org/armedbear/lisp/java.lisp
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/java.lisp	Wed Jun 29 08:35:07 2011	(r13367)
+++ trunk/abcl/src/org/armedbear/lisp/java.lisp	Wed Jun 29 15:04:37 2011	(r13368)
@@ -431,8 +431,6 @@
   (let ((supers nil))
     (when (jclass-interface-p jclass)
       (push (find-class 'java-object) supers))
-    (when (jequal jclass (jclass "java.util.List"))
-      (push (find-class 'sequence) supers))
     supers))
 
 (defun ensure-java-class (jclass)




More information about the armedbear-cvs mailing list