Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

jcast

Cast a Java object to another class


Description

.jcast returns a Java object reference cast to another Java class.

Usage

.jcast(obj, new.class = "java/lang/Object", check = FALSE, convert.array = FALSE)

Arguments

obj

a Java object reference

new.class

fully qualified class name in JNI notation (e.g. "java/lang/String").

check

logical. If TRUE, it is checked that the object effectively is an instance of the new class. See %instanceof%. Using FALSE (the default) for this argument, rJava does not perform type check and this will cause an error on the first use if the cast is illegal.

convert.array

logical. If TRUE and the object is an array, it is converted into a jarrayRef reference.

Details

This function is necessary if a argument of .jcall or .jnew is defined as the superclass of the object to be passed (see .jcall). The original object is not modified.

The default values for the arguments check and convert.array is FALSE in order to guarantee backwards compatibility, but it is recommended to set the arguments to TRUE

Value

Returns a Java object reference (jobjRef) to the object obj, changing the object class.

See Also

Examples

## Not run: 
v <- .jnew("java/util/Vector")
.jcall("java/lang/System","I","identityHashCode",.jcast(v, "java/lang/Object"))

## End(Not run)

rJava

Low-Level R to Java Interface

v1.0-4
LGPL-2.1
Authors
Simon Urbanek <simon.urbanek@r-project.org>
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.