jcast

0th

Percentile

Cast a Java object to another class

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

Keywords
interface
Usage
.jcast(obj, new.class)
Arguments
obj
a Java object reference
new.class
fully qualified class name in JNI notation (e.g. "java/lang/String"). Although rJava itself performs no type check in .jcast, Java will produce an exception on the first use if the cast is illegal.
Details

This function is necesary if the argument of .jcall or link{.jnew} is defined as the superclass of the object to be passed. (See .jcall) No type check is performed and the original object is not modified.

Value

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

See Also

.jcall

Aliases
  • .jcast
Examples
v <- .jnew("java/util/Vector")
.jcall("java/lang/System","I","identityHashCode",.jcast(v, "java/lang/Object"))
Documentation reproduced from package rJava, version 0.4-3, License: GPL version 2

Community examples

Looks like there are no examples yet.