Changeset 14718


Ignore:
Timestamp:
08/17/14 18:04:52 (7 years ago)
Author:
Mark Evenson
Message:

Extend JSS fix for GET-JAVA-FIELD to SET-JAVA-FIELD.

Thanks to Robert Goldman.

<http://abcl.org/trac/ticket/362>

File:
1 edited

Legend:

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

    r14715 r14718  
    315315(defvar *running-in-osgi* (ignore-errors (jclass "org.osgi.framework.BundleActivator")))
    316316
     317(define-condition no-such-java-field (error)
     318  ((field-name
     319    :initarg :field-name
     320    :reader field-name
     321    )
     322   (object
     323    :initarg :object
     324    :reader object
     325    ))
     326  (:report (lambda (c stream)
     327             (error 'no-such-java-field :field-name field :object object))))
     328
    317329(defun get-java-field (object field &optional (try-harder *running-in-osgi*))
    318330  "Get the value of the FIELD contained in OBJECT.
     
    368380       (jfield (if (java-object-p field)
    369381       field
    370            (find field (#"getDeclaredFields" class) :key 'jfield-name :test 'equal))))
     382                        (or (find-declared-field field class)
     383+                            (error 'no-such-java-field :field-name field :object object)))))
    371384  (#"setAccessible" jfield +true+)
    372385  (values (#"set" jfield object value) jfield))
     
    377390            (setf (jfield (jclass-of object) field) value)
    378391            (setf (jfield object field) value)))))
     392
     393(defun (setf get-java-field) (value object field &optional (try-harder *running-in-osgi*))
     394  (set-java-field object field value try-harder))
    379395
    380396
Note: See TracChangeset for help on using the changeset viewer.