s-u / rJava

R to Java interface
https://RForge.net/rJava
235 stars 77 forks source link

R did not generate REngineEvalException on RTest #29

Closed AlexBurdu closed 10 years ago

AlexBurdu commented 10 years ago

I am testing JRI using the RTest class in the org.rosuda.REngine.JRI.test package and I am getting the following error:

    rnorm(5); stop('error'); rnorm(2)Error: error
    Exception: org.rosuda.REngine.JRI.test.TestException: error in R did not generate REngineEvalException
    org.rosuda.REngine.JRI.test.TestException: error in R did not generate REngineEvalException at org.rosuda.REngine.JRI.test.RTest.main(RTest.java:283)

I tried to trace the error into the JRIEngine object and rni.Parse(text, -1) returns 139793149998072 and is compared with R_NilValue = 139793132433096 and 0 in order to check if it throws a REngineException. I don't know what 139793149998072 means and how to fix this. Any hints?

s-u commented 10 years ago

Sorry, you'll have to provide a bit more detail - the test works just fine for me. Please provide full sesionInfo(), your OS version, Java version and how you started the test.

Also the point you're pointing to has nothing to do with it - the parse step won't fail in that test so it's correct that the reference is different from both null and R_NilValue.

AlexBurdu commented 10 years ago

Hi @s-u ,

sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=ro_RO.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=ro_RO.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=ro_RO.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=ro_RO.UTF-8 LC_IDENTIFICATION=C
$ java -version
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
$ uname -a
Linux 3.13.0-29-generic #53-Ubuntu SMP Wed Jun 4 21:00:20 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

I'm just running the RTest.java class from netbeans to test the environment. Here's the output:

R version 3.0.2 (2013-09-25) -- "Frisbee Sailing"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

* Test string and list retrieval
PASSED
* Test NA/NaN support in double vectors...
[1] 1.0 0.5  NA NaN 3.5
  v = org.rosuda.REngine.REXPDouble@6d06d69c[3]{1.5,NaN,NaN}
PASSED
* Test assigning of lists and vectors ...
  assign x=pairlist
  assign y=vector
  assign z=data.frame
  pull all three back to Java
  x = org.rosuda.REngine.REXPList@7852e922[2]named
  y = org.rosuda.REngine.REXPGenericVector@4e25154f+[2]named
  z = org.rosuda.REngine.REXPGenericVector@70dea4e+[2]named
PASSED
* Testing functionality of assembled S3 objects ...
  z[2,2] = org.rosuda.REngine.REXPDouble@5c647e05[1]
PASSED
* Testing pass-though capability for data.frames ...
  identical(df, iris) = org.rosuda.REngine.REXPLogical@33909752[1]
PASSED
* Test support of factors
  f=org.rosuda.REngine.REXPFactor@55f96302+[20][5]
  isFactor: true, asFactor: org.rosuda.REngine.RFactor@3d4eac69[20,5,#1]
  singe-level factor used to degenerate:
  isFactor: true, asFactor: org.rosuda.REngine.RFactor@42a57993[1,1,#1]
  test factors with null elements contents:
  f = org.rosuda.REngine.RFactor@75b84c92[6,2,#1]
  f = org.rosuda.REngine.REXPFactor@6bc7c054+[5][3]
PASSED
* Lowess test
  RList[org.rosuda.REngine.REXPDouble@232204a1[100], org.rosuda.REngine.REXPDouble@4aa298b7[100]]{named,2}
PASSED
* Test multi-line expressions
    multi-line single expression    : ok
    multitle expressions    : ok
    comment (0 expressions)    : ok
PASSED
* Matrix tests
  matrix: create a matrix
  matrix: assign a matrix
matrix: cross-product
PASSED
* Test handling of NAs in character vectors ('foo', NA, 'NA')
  push String[] with NAs: 0 1 0  - OK
  pull String[] with NAs: foo null NA  - OK
  compare pushed and constructed strings:  - OK
  check isNA() for REXPString false true false - OK
PASSED
* Test serialization and raw vectors
  serialized ls is 6123 bytes long
  we have 12 items in the workspace
PASSED
* Test environment support
  new.env() = org.rosuda.REngine.REXPEnvironment@7d4991ad
  get("foo") = org.rosuda.REngine.REXPString@28d93b30[1]
  eng.newEnvironment() = org.rosuda.REngine.REXPEnvironment@1b6d3586
  parent = org.rosuda.REngine.REXPEnvironment@4554617c
  get("foo",parent) = org.rosuda.REngine.REXPString@74a14482[1]

  R> { .env <- new.env(); .env$x <- 2 }
  env = eng.get(".env", null, false )  
  parseAndEval( "x+1", env, true)  == 3.0     : ok
PASSED
* Test generation of exceptions
  eng.parse("rnorm(10))", false )     ->  REngineException( "Parse Error" ) 
  eng.parseAndEval("rnorm(10))" )     ->  REngineException( "Parse Error" ) 
  rnorm(5); stop('error'); rnorm(2)Error: error
Exception: org.rosuda.REngine.JRI.test.TestException: error in R did not generate REngineEvalException
org.rosuda.REngine.JRI.test.TestException: error in R did not generate REngineEvalException
    at org.rosuda.REngine.JRI.test.RTest.main(RTest.java:283)
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 2.407s
Finished at: Fri Sep 05 21:33:45 EEST 2014
Final Memory: 4M/149M
s-u commented 10 years ago

Thanks, this is a different test than what I thought you're using (I assumed JRI while this is actually in REngine). Yes, I can replicate it now. Instead of throwing an exception it returns NULL, I'm looking into this.