Call a Java method
.jcall calls a Java method with the supplied arguments.
.jcall(obj, returnSig = "V", method, ..., evalArray = TRUE, evalString = TRUE, check = TRUE, interface = "RcallMethod")
- Java object (
jobjRefas returned by
.jnew) or fully qualified class name in JNI notation (e.g.
- Return signature in JNI notation (e.g. "V" for void,
intetc.). For convenience additional type
"S"is supported and expanded to
"T"to represent t
- 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
jobjRefobject. All named parameters are discarded.
- This flag determines whether the array return value
is evaluated (
TRUE) or passed back as Java object reference (
- This flag determines whether string result is returned as characters or as Java object reference.
- If set to
TRUEthen checks for exceptions are performed before and after the call using
.jcheck(silent=FALSE). This is usually the desired behavior, because all calls fail until an
- This option is experimental and specifies the
interface used for calling the Java method; the current
implementation supports two interfaces:
.jcall requires exact match of argument and return types. For
.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
null arguments also needs a
proper class specification with
Java also distinguishes scalar and array types whereas R doesn't have
the concept of a scalar. In R a scalar is basically a vector (called
array in Java-speak) of the length 1. Therefore passing vectors of the
length 1 is ambiguous.
.jcall assumes that any vector of the
length 1 that corresponds to a native Java type is a scalar. All other
vectors are passed as arrays. Therefore it is important to use
.jarray if an arbitrary vector (including those of the
length 1) is to be passed as an array parameter.
- Returns the result of the method.
.jcall("java/lang/System","S","getProperty","os.name") f <- .jnew("java/awt/Frame","Hello") .jcall(f,,"setVisible",TRUE)