@@ -399,6 +399,14 @@ get_method_id(method::JMethod) = @checknull JNI.FromReflectedMethod(method)
399
399
(m:: JMethod )(obj, args... ) = jcall (obj, m, args... )
400
400
401
401
402
+ """
403
+ jfield(ref, field, [fieldType])
404
+
405
+ Get a pointer to a field of of a Java class or object.
406
+ * `ref` could be a JavaObject{T} type or a JavaObject
407
+ * `field` can be an AbstractString or JField
408
+ * `fieldType` is a Type
409
+ """
402
410
function jfield (ref, field, fieldType)
403
411
assertroottask_or_goodenv () && assertloaded ()
404
412
jfieldID = get_field_id (ref, field, fieldType)
@@ -412,6 +420,14 @@ function jfield(ref, field)
412
420
_jfield (_jcallable (ref), jfieldID, fieldType)
413
421
end
414
422
423
+ function jfield (ref, field:: AbstractString )
424
+ assertroottask_or_goodenv () && assertloaded ()
425
+ field = listfields (ref, field)[]
426
+ fieldType = jimport (gettype (field))
427
+ jfieldID = get_field_id (ref, field, fieldType)
428
+ _jfield (_jcallable (ref), jfieldID, fieldType)
429
+ end
430
+
415
431
function get_field_id (typ:: Type{JavaObject{T}} , field:: AbstractString , fieldType:: Type ) where T
416
432
@checknull JNI. GetStaticFieldID (Ptr (metaclass (T)), String (field), signature (fieldType))
417
433
end
0 commit comments