[graalvm-users] Strange error

Stepan stepan.sindelar at oracle.com
Fri Jul 27 08:52:45 PDT 2018

Hi Rodrigo,

this is indeed an inconsistency in how FastR was giving out its objects 
to other languages. It is fixed in the development version and will be 
fixed in the next release: your example should print "[3]" in both cases.

For more details here is the description from changelog with few notes:

* R code evaluated via interop never returns a Java primitive type, but 
always a vector
* Vectors of size 1 that do not contain NA can be unboxed (i.e. you 
should be able to use them in Ruby anywhere where a primitive value is 
* Sending the READ message to an atomic R vector (array subscript in 
most languages) gives
   * Java primitive type as long as the value is not `NA`
   * if the value is `NA`, a special value that responds to `IS_NULL` 
with `true`. If this value is passed back to R it behaves as `NA` again
* Note that sending the READ message to a list, environment, or other 
heterogenous data structure never gives atomic Java type but a primitive 
R vector
* Note: if you want to check for NA, the easiest is Polyglot.eval('R', 
'is.na').execute(myvector) or Polyglot.eval('R', 
'is.na').execute(myvector[0]). Both return a vector of booleans, but in 
the second case it will always contain single element.


More information about the GraalVM-Users mailing list