.jarray
: The input can be either a vector of some sort (such as
numeric, integer, logical, ...) or a list of Java references. The
contents is pushed to the Java side and a corresponding array is
created. The type of the array depends on the input vector type. For
example numeric vector creates double[]
array, integer vector
creates int[]
array, character vector String[]
array and
so on. If x
is a list, it must contain Java references only (or
NULL
s which will be treated as NULL
references).
The contents.class
parameter is used only if x
is a list
of Java object references and it can specify the class that will be
used for all objects in the array. If set to NULL
no assumption
is made and java/lang/Object
will be used. Use with care and
only if you know what you're doing - you can always use
.jcast
to cast the entire array to another type even if
you use a more general object type. One typical use is to construct
multi-dimensional arrays which mandates passing the array type as
contents.class
.
The result is a reference to the newly created array.
The inverse function which fetches the elements of an array reference
is .jevalArray
.
.jevalArray
currently supports only a subset of all possible
array types. Recursive arrays are handled by returning a list of
references which can then be evaluated separately. The only exception
is simplify=TRUE
in which case .jevalArray
attempts to
convert multi-dimensional arrays into native R type if there is a
such. This only works for rectangular arrays of the same basic type
(i.e. the length and type of each referenced array is the same -
sometimes matrices are represented that way in Java).