Changeset 13909


Ignore:
Timestamp:
04/10/12 15:00:46 (10 years ago)
Author:
Mark Evenson
Message:

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.

Location:
trunk/abcl/contrib/jss
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/contrib/jss/invoke.lisp

    r13430 r13909  
    320320(defvar *running-in-osgi* (ignore-errors (jclass "org.osgi.framework.BundleActivator")))
    321321
    322 
    323322(defun get-java-field (object field &optional (try-harder *running-in-osgi*))
     323  "Get the value of the FIELD contained in OBJECT.
     324If OBJECT is a symbol it names a dot qualified static FIELD."
    324325  (if try-harder
    325326      (let* ((class (if (symbolp object)
     
    339340          (jfield field object))))
    340341
    341 ;; use #"getSuperclass" and #"getInterfaces" to see whether there are fields in superclasses that we might set
     342;; TODO use #"getSuperclass" and #"getInterfaces" to see whether there
     343;; are fields in superclasses that we might set
    342344(defun set-java-field (object field value &optional (try-harder *running-in-osgi*))
     345  "Set the FIELD of OBJECT to VALUE.
     346If OBJECT is a symbol, it names a dot qualified Java class to look for
     347a static FIELD.  If OBJECT is an instance of java:java-object, the
     348associated is used to look up the static FIELD."
    343349  (if try-harder
    344350      (let* ((class (if (symbolp object)
     
    354360    (if (symbolp object)
    355361  (let ((class (find-java-class object)))
    356     (#"pokeStatic" 'invoke class field value))
    357       (#"poke" 'invoke object field value))))
     362          (setf (jfield (#"getName" class) field) value))
     363        (if (typep object 'java-object)
     364            (setf (jfield (jclass-of object) field) value)
     365            (setf (jfield object field) value)))))
     366
    358367
    359368(defconstant +for-name+
  • trunk/abcl/contrib/jss/jss.asd

    r13431 r13909  
    44(defsystem :jss
    55  :author "Alan Ruttenberg, Mark Evenson"
    6   :version "3.0.1"
     6  :version "3.0.2"
    77  :components
    88  ((:module base
  • trunk/abcl/contrib/jss/packages.lisp

    r13430 r13909  
    2727   #:jarray-to-list
    2828
     29;;; XXX Necessary to work in OSGi?
     30   #:get-java-field ; use JAVA:JFIELD
     31   #:set-java-field ; use JAVA-JFIELD
     32
    2933;;; deprecated
    30    #:get-java-field ; use JAVA:JFIELD
    3134   #:list-to-list
    3235
Note: See TracChangeset for help on using the changeset viewer.