.jconstructors
returns a character vector with all constructors for
a given class or object.
.jmethods
returns a character vector with all methods for
a given class or object.
.jfields
returns a character vector with all fields (aka attributes) for a given class or object.
.jconstructors(o, as.obj = FALSE, class.loader=.rJava.class.loader)
.jmethods(o, name = NULL, as.obj = FALSE, class.loader=.rJava.class.loader)
.jfields(o, name = NULL, as.obj = FALSE, class.loader=.rJava.class.loader)
Returns a character vector (if as.obj
is FALSE
) or a
list of Java objects. Each entry corresponds to the
Constructor
resp. Method
resp. Field
object. The string result is constructed by calling
toString()
on the objects.
Name of a class (either notation is fine) or an object whose class will be queried
string, regular expression of the method/field to look for
if TRUE
then a list of Java objects is
returned, otherwise a character vector (obtained by calling
toString()
on each entry).
optional, class loader to use for class look up if
needed (i.e., if o
is a string)
There first two functions are intended to help with finding correct signatures for methods and constructors. Since the low-level API in rJava doesn't use reflection automatically, it is necessary to provide a proper signature. That is somewhat easier using the above methods.
.jcall
, .jnew
, .jcast
or $,jobjRef-method
if (FALSE) {
.jconstructors("java.util.Vector")
v <- .jnew("java.util.Vector")
.jmethods(v, "add")
}
Run the code above in your browser using DataLab