diff --git a/contrib/jss/invoke.lisp b/contrib/jss/invoke.lisp
index f23095d..b462f26 100644
a
|
b
|
CLASS-NAME may either be a symbol or a string according to the usual JSS convent |
314 | 314 | |
315 | 315 | (defvar *running-in-osgi* (ignore-errors (jclass "org.osgi.framework.BundleActivator"))) |
316 | 316 | |
| 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 | (format stream "Unable to find a FIELD named ~a for ~a" |
| 328 | (field-name c) (object c)))) |
| 329 | ) |
| 330 | |
317 | 331 | (defun get-java-field (object field &optional (try-harder *running-in-osgi*)) |
318 | 332 | "Get the value of the FIELD contained in OBJECT. |
319 | 333 | If OBJECT is a symbol it names a dot qualified static FIELD." |
… |
… |
If OBJECT is a symbol it names a dot qualified static FIELD." |
326 | 340 | (jfield (if (java-object-p field) |
327 | 341 | field |
328 | 342 | (or (find-declared-field field class) |
329 | | (error "Unable to find a FIELD named ~a for ~a" |
330 | | field object))))) |
| 343 | (error 'no-such-java-field :field-name field :object object))))) |
331 | 344 | (#"setAccessible" jfield +true+) |
332 | 345 | (values (#"get" jfield object) jfield)) |
333 | 346 | (if (symbolp object) |
… |
… |
associated is used to look up the static FIELD." |
367 | 380 | (jobject-class object)))) |
368 | 381 | (jfield (if (java-object-p field) |
369 | 382 | field |
370 | | (find field (#"getDeclaredFields" class) :key 'jfield-name :test 'equal)))) |
| 383 | (or (find-declared-field field class) |
| 384 | (error 'no-such-java-field :field-name field :object object))))) |
371 | 385 | (#"setAccessible" jfield +true+) |
372 | 386 | (values (#"set" jfield object value) jfield)) |
373 | 387 | (if (symbolp object) |
… |
… |
associated is used to look up the static FIELD." |
377 | 391 | (setf (jfield (jclass-of object) field) value) |
378 | 392 | (setf (jfield object field) value))))) |
379 | 393 | |
| 394 | (defun (setf get-java-field) (value object field &optional (try-harder *running-in-osgi*)) |
| 395 | (set-java-field object field value try-harder)) |
| 396 | |
380 | 397 | |
381 | 398 | (defconstant +for-name+ |
382 | 399 | (jmethod "java.lang.Class" "forName" "java.lang.String" "boolean" "java.lang.ClassLoader")) |