jreflection

0th

Percentile

Simple helper functions for Java reflection

.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 fileds (aka attributes) for a given class or object.

Keywords
interface
Usage
.jconstructors(o, as.obj = FALSE)
.jmethods(o, name = NULL, as.obj = FALSE)
.jfields(o, name = NULL, as.obj = FALSE)
Arguments
o

Name of a class (either notation is fine) or an object whose class will be queried

name

Name of the method/field to look for. May contain regular expressions except for ^$.

as.obj

if TRUE then a list of Java objects is returned, otherwise a character vector (obtained by calling toString() on each entry).

Details

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.

Value

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.

See Also

.jcall, .jnew, .jcast or $,jobjRef-method

Aliases
  • .jmethods
  • .jfields
  • .jconstructors
Examples
# NOT RUN {
.jconstructors("java/util/Vector")
v <- .jnew("java/util/Vector")
.jmethods(v, "add")
# }
Documentation reproduced from package rJava, version 0.9-10, License: GPL-2

Community examples

Looks like there are no examples yet.