rJava (version 0.4-11)

jreflection: Simple helper functions for Java reflection

Description

.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.

Usage

.jconstructors(o)
.jmethods(o, name = NULL)
.jfields(o)

Arguments

o
Name of a class (either notation is fine) or an object whose class will be queried
name
Name of the method to look for. May contain regular expressions except for ^$.

Value

  • Returns a character vector. Each entry corresponds to toString() call on the Constructor resp. Method resp. Field object.

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.

See Also

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

Examples

Run this code
.jconstructors("java/util/Vector")
v <- .jnew("java/util/Vector")
.jmethods(v, "add")

Run the code above in your browser using DataCamp Workspace