jcall
From rJava v0.4-3
by Simon Urbanek
Call a Java method
.jcall
calls a Java method with the supplied arguments.
- Keywords
- interface
Usage
.jcall(obj, returnSig = "V", method, ..., evalArray = TRUE,
evalString = TRUE, interface = "RcallMethod")
Arguments
- obj
- Java object (
jobjRef
as returned by.jcall
or.jnew
) or fully qualified class name in JNI notation (e.g."java/lang/String"
). - returnSig
- Return signature in JNI notation (e.g. "V" for void,
"[I" for
int[]
etc.). For convenience additional type"S"
is supported and expanded to"Ljava/lang/String;"
. - method
- The name of the method to be called
- ...
- Any parametes that will be passed to the Java method. The parameter
types are determined automatically and/or taken from the
jobjRef
object. - evalArray
- This flag determines whether the array return value
is evaluated (
TRUE
) or passed back as Java object reference (FALSE
). - evalString
- This flag determines whether string result is returned as characters or as Java object reference.
- interface
- This option is experimental and specifies the
interface used for calling the Java method; the current
implementation supports two interfaces:
"RcallMethod"
"RcallSyncMeth
Details
.jcall
requires exact match of argument and return types. For
higher efficiency .jcall
doens't perform any lookup in the
reflection tables. This means that passing subclasses of the classes
present in the method definition requires explicit casting using
.jcast
. Passing null
arguments also needs a
proper class specification with .jnull
.
Value
- Returns the result of the method.
See Also
Examples
.jcall("java/lang/System","S","getProperty","os.name")
f <- .jnew("java/awt/Frame","Hello")
.jcall(f,,"setVisible",TRUE)
Community examples
Looks like there are no examples yet.