[armedbear-cvs] r13909 - trunk/abcl/contrib/jss

mevenson at common-lisp.net mevenson at common-lisp.net
Tue Apr 10 15:00:48 UTC 2012


Author: mevenson
Date: Tue Apr 10 08:00:46 2012
New Revision: 13909

Log:
jss-3.0.2: fix SET-JAVA-FIELD.

Use the setf'able JAVA:JFIELD primitive to handle setting Java fields,
performing additional conversion when passed object of type
JAVA:JAVA-OBJECT.

Modified:
   trunk/abcl/contrib/jss/invoke.lisp
   trunk/abcl/contrib/jss/jss.asd
   trunk/abcl/contrib/jss/packages.lisp

Modified: trunk/abcl/contrib/jss/invoke.lisp
==============================================================================
--- trunk/abcl/contrib/jss/invoke.lisp	Fri Apr  6 04:59:48 2012	(r13908)
+++ trunk/abcl/contrib/jss/invoke.lisp	Tue Apr 10 08:00:46 2012	(r13909)
@@ -319,8 +319,9 @@
 
 (defvar *running-in-osgi* (ignore-errors (jclass "org.osgi.framework.BundleActivator")))
 
-
 (defun get-java-field (object field &optional (try-harder *running-in-osgi*))
+  "Get the value of the FIELD contained in OBJECT.
+If OBJECT is a symbol it names a dot qualified static FIELD."
   (if try-harder
       (let* ((class (if (symbolp object)
 			(setq object (find-java-class object))
@@ -338,8 +339,13 @@
             (jfield class field))
           (jfield field object))))
 
-;; use #"getSuperclass" and #"getInterfaces" to see whether there are fields in superclasses that we might set
+;; TODO use #"getSuperclass" and #"getInterfaces" to see whether there
+;; are fields in superclasses that we might set
 (defun set-java-field (object field value &optional (try-harder *running-in-osgi*))
+  "Set the FIELD of OBJECT to VALUE.
+If OBJECT is a symbol, it names a dot qualified Java class to look for
+a static FIELD.  If OBJECT is an instance of java:java-object, the
+associated is used to look up the static FIELD."
   (if try-harder
       (let* ((class (if (symbolp object)
 			(setq object (find-java-class object))
@@ -353,8 +359,11 @@
 	(values (#"set" jfield object value) jfield))
     (if (symbolp object)
 	(let ((class (find-java-class object)))
-	  (#"pokeStatic" 'invoke class field value))
-      (#"poke" 'invoke object field value))))
+          (setf (jfield (#"getName" class) field) value))
+        (if (typep object 'java-object)
+            (setf (jfield (jclass-of object) field) value)
+            (setf (jfield object field) value)))))
+
 
 (defconstant +for-name+ 
   (jmethod "java.lang.Class" "forName" "java.lang.String" "boolean" "java.lang.ClassLoader"))

Modified: trunk/abcl/contrib/jss/jss.asd
==============================================================================
--- trunk/abcl/contrib/jss/jss.asd	Fri Apr  6 04:59:48 2012	(r13908)
+++ trunk/abcl/contrib/jss/jss.asd	Tue Apr 10 08:00:46 2012	(r13909)
@@ -3,7 +3,7 @@
 
 (defsystem :jss
   :author "Alan Ruttenberg, Mark Evenson"
-  :version "3.0.1" 
+  :version "3.0.2" 
   :components 
   ((:module base 
             :pathname "" :serial t 

Modified: trunk/abcl/contrib/jss/packages.lisp
==============================================================================
--- trunk/abcl/contrib/jss/packages.lisp	Fri Apr  6 04:59:48 2012	(r13908)
+++ trunk/abcl/contrib/jss/packages.lisp	Tue Apr 10 08:00:46 2012	(r13909)
@@ -26,8 +26,11 @@
    #:vector-to-list
    #:jarray-to-list
 
-;;; deprecated
+;;; XXX Necessary to work in OSGi?
    #:get-java-field ; use JAVA:JFIELD
+   #:set-java-field ; use JAVA-JFIELD
+
+;;; deprecated
    #:list-to-list
 
 ;;; Move to JAVA?




More information about the armedbear-cvs mailing list