Skip to content
Snippets Groups Projects
Commit c02b7610 authored by Tomas Stupka's avatar Tomas Stupka
Browse files

rJava rewrite - fastr changes:

- removed jri
- removed all native code and replced with fastr interop based impl in R
- some tweaks in original rjava R code
- java build part of install
parent 30adbacc
No related branches found
No related tags found
No related merge requests found
Showing
with 1049 additions and 827 deletions
Package: rJava
Version: (populated by mkdist!)
Title: Low-Level R to Java Interface
Author: Simon Urbanek <simon.urbanek@r-project.org>
Maintainer: Simon Urbanek <simon.urbanek@r-project.org>
Depends: R (>= 2.5.0), methods
Description: Low-level interface to Java VM very much like .C/.Call and friends. Allows creation of objects, calling methods and accessing fields.
License: GPL-2
URL: http://www.rforge.net/rJava/
SystemRequirements: Java JDK 1.2 or higher (for JRI/REngine JDK 1.4 or higher), GNU make
BugReports: https://github.com/s-u/rJava/issues
Type: Package
Title: FastR rJava compatibility layer
Version: 1.0
Date: 2017-05-18
Author: Tomas Stupka
Maintainer: Tomas Stupka <tomas.stupka@oracle.com>
Description: Provides rJava R interface backed by FastR interoperability builtins.
License: GPL-2
\ No newline at end of file
......@@ -4,7 +4,7 @@ export( "%instanceof%" )
export( clone )
S3method( clone, default )
export(is.jnull, .r2j, .rJava.base.path, toJava)
export(is.jnull, .rJava.base.path)
exportClasses(jobjRef, jarrayRef, jrectRef, jfloat, jlong, jbyte, jchar, jclassName)
exportMethods(show, "$", "$<-",
"==", "!=", "<", ">", "<=", ">=",
......
This diff is collapsed.
##
# This material is distributed under the GNU General Public License
# Version 2. You may review the terms of this license at
# http://www.gnu.org/licenses/gpl-2.0.html
#
# Copyright (c) 2006 Simon Urbanek <simon.urbanek@r-project.org>
# Copyright (c) 2018 Oracle and/or its affiliates
#
# All rights reserved.
##
## S4 classes (jobjRef is re-defined in .First.lib to contain valid jobj)
#' java object reference
setClass("jobjRef", representation(jobj="externalptr", jclass="character"),
......
##
# This material is distributed under the GNU General Public License
# Version 2. You may review the terms of this license at
# http://www.gnu.org/licenses/gpl-2.0.html
#
# Copyright (c) 2006 Simon Urbanek <simon.urbanek@r-project.org>
# Copyright (c) 2018, Oracle and/or its affiliates
#
# All rights reserved.
##
setClass("jclassName", representation(name="character", jobj="jobjRef"))
jclassName <- function(class){
if( is( class, "jobjRef" ) && .jinherits(class, "java/lang/Class" ) ){
......@@ -27,7 +38,13 @@ setMethod("$", c(x="jclassName"), function(x, name) {
stop("no static field, method or inner class called `", name, "' in `", x@name, "'")
}
})
setMethod("$<-", c(x="jclassName"), function(x, name, value) .jfield(x@name, name) <- value)
setMethod("$<-", c(x="jclassName"), function(x, name, value) {
.jfield(x@jobj, name) <- value
# FASTR <<<<<
# Fix: return x, otherwise LHS of $<- is overriden with
# the result of .jfield(x@jobj, name) <- value which is the field value
x
})
setMethod("show", c(object="jclassName"), function(object) invisible(show(paste("Java-Class-Name:",object@name))))
setMethod("as.character", c(x="jclassName"), function(x, ...) x@name)
......
##
# This material is distributed under the GNU General Public License
# Version 2. You may review the terms of this license at
# http://www.gnu.org/licenses/gpl-2.0.html
#
# Copyright (c) 2006 Simon Urbanek <simon.urbanek@r-project.org>
# Copyright (c) 2018, Oracle and/or its affiliates
#
# All rights reserved.
##
# :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1:
# {{{ utilities to deal with arrays
......
##
# This material is distributed under the GNU General Public License
# Version 2. You may review the terms of this license at
# http://www.gnu.org/licenses/gpl-2.0.html
#
# Copyright (c) 2006 Simon Urbanek <simon.urbanek@r-project.org>
# Copyright (c) 2018, Oracle and/or its affiliates
#
# All rights reserved.
##
## This file is part of the rJava package - low-level R/Java interface
## (C)2006 Simon Urbanek <simon.urbanek@r-project.org>
## For license terms see DESCRIPTION and/or LICENSE
......@@ -94,7 +105,8 @@
simplify=FALSE, use.true.class = FALSE) {
if (check) .jcheck()
iaddr <- .env[[interface]]
interface <- if (is.null(iaddr)) getNativeSymbolInfo(interface, "rJava", TRUE, FALSE)$address else iaddr
# TODO
#interface <- if (is.null(iaddr)) getNativeSymbolInfo(interface, "rJava", TRUE, FALSE)$address else iaddr
r<-NULL
# S is a shortcut for Ljava/lang/String;
if (returnSig=="S")
......@@ -109,14 +121,49 @@
r<-.External(interface, obj@jobj, returnSig, method, ...)
else
r<-.External(interface, as.character(obj), returnSig, method, ...)
if (returnSig=="V") return(invisible(NULL))
if (returnSig=="V") {
# FASTR <<<<<
# FIX check for exceptions before return; like in other cases in this function
if (check) {
.jcheck()
}
# FASTR >>>>>
return(invisible(NULL))
}
if( use.true.class && !is.null( r ) ){
if( ! ( isPrimitiveTypeName(returnSig) || isArraySignature(returnSig) ) ){
# avoid calling .jcall since we work on external pointers directly here
clazz <- .External(interface, r , "Ljava/lang/Class;", "getClass")
clazzname <- .External(interface, clazz, "Ljava/lang/String;", "getName")
clazzname <- .External(RgetStringValue, clazzname)
# FASTR <<<<<
# retrieve the clazzname via fastr interop
# avoid calling .jcall since we work on external pointers directly here
#clazz <- .External(interface, r , "Ljava/lang/Class;", "getClass")
#clazzname <- .External(interface, clazz, "Ljava/lang/String;", "getName")
#clazzname <- .External("RgetStringValue", clazzname)
o <- r
if(inherits(r, "externalptr")) {
o <- attr(r, "external.object")
}
clazzname <- attr(r, "external.classname")
if(is.null(clazzname)) {
# returnSig is not primitive, but we might have an unboxed primitive value
# typicaly, this can happen when called from .jrcall (in cases like rJavaObject$someMethodReturningInt())
# and .jrcall for now always simplyfies the return value and dumps the class name anyway
# so lets retrieve it "just in case"
if (is.character(o)) {
clazzname <- "java.lang.String"
} else if (is.integer(o)) {
clazzname <- "java.lang.Integer"
} else if (is.double(o)) {
clazzname <- "java.lang.Double"
} else if (is.logical(o)) {
clazzname <- "java.lang.Boolean"
} else {
clazzname <- java.class(o, getClassName = TRUE)
}
}
# FASTR >>>>>>
returnSig <- tojniSignature( clazzname )
}
}
......@@ -313,6 +360,7 @@ is.jnull <- function(x) {
# return class object for a given class name; silent determines whether
# an error should be thrown on failure (FALSE) or just null reference (TRUE)
.jfindClass <- function(cl, silent=FALSE) {
# FASTR TODO check all usecases, some of them might try to do e.g. newInstance, getMethods (if methods are a problem too?) etc
if (inherits(cl, "jclassName")) return(cl@jobj)
if (!is.character(cl) || length(cl)!=1)
stop("invalid class name")
......
##
# This material is distributed under the GNU General Public License
# Version 2. You may review the terms of this license at
# http://www.gnu.org/licenses/gpl-2.0.html
#
# Copyright (c) 2006 Simon Urbanek <simon.urbanek@r-project.org>
# Copyright (c) 2018, Oracle and/or its affiliates
#
# All rights reserved.
##
#' if a and b are compatable,
#' in the sense of the java.util.Comparable interface
......
##
# This material is distributed under the GNU General Public License
# Version 2. You may review the terms of this license at
# http://www.gnu.org/licenses/gpl-2.0.html
#
# Copyright (c) 2006 Simon Urbanek <simon.urbanek@r-project.org>
# Copyright (c) 2018, Oracle and/or its affiliates
#
# All rights reserved.
##
# :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1:
# S4 dispatch does not work for .DollarNames, so we'll use S3
......
##
# This material is distributed under the GNU General Public License
# Version 2. You may review the terms of this license at
# http://www.gnu.org/licenses/gpl-2.0.html
#
# Copyright (c) 2006 Simon Urbanek <simon.urbanek@r-project.org>
# Copyright (c) 2018, Oracle and/or its affiliates
#
# All rights reserved.
##
# in: Java -> R
.conv.in <- new.env(parent=emptyenv())
.conv.in$. <- FALSE
......
##
# This material is distributed under the GNU General Public License
# Version 2. You may review the terms of this license at
# http://www.gnu.org/licenses/gpl-2.0.html
#
# Copyright (c) 2006 Simon Urbanek <simon.urbanek@r-project.org>
# Copyright (c) 2018, Oracle and/or its affiliates
#
# All rights reserved.
##
## functions for some basic exception handling
# FIXME: should all these actually be deprecated or defunct
......
##
# This material is distributed under the GNU General Public License
# Version 2. You may review the terms of this license at
# http://www.gnu.org/licenses/gpl-2.0.html
#
# Copyright (c) 2006 Simon Urbanek <simon.urbanek@r-project.org>
# Copyright (c) 2018, Oracle and/or its affiliates
#
# All rights reserved.
##
IMPORTER <- ".__rjava__import"
......@@ -136,9 +146,11 @@ lookup <- function( name = "Object", ..., caller = sys.function(-1L) ){
javaImport <- function( packages = "java.lang" ){
importer <- .jnew( "RJavaImport", .jcast( .rJava.class.loader, "java/lang/ClassLoader" ) )
.jcall( importer, "V", "importPackage", packages )
.Call( "newRJavaLookupTable" , importer,
PACKAGE = "rJava" )
# FASTR TODO
stop("javaImport not yet implemented")
# importer <- .jnew( "RJavaImport", .jcast( .rJava.class.loader, "java/lang/ClassLoader" ) )
# .jcall( importer, "V", "importPackage", packages )
# .Call( "newRJavaLookupTable" , importer,
# PACKAGE = "rJava" )
}
##
# This material is distributed under the GNU General Public License
# Version 2. You may review the terms of this license at
# http://www.gnu.org/licenses/gpl-2.0.html
#
# Copyright (c) 2006 Simon Urbanek <simon.urbanek@r-project.org>
# Copyright (c) 2018, Oracle and/or its affiliates
#
# All rights reserved.
##
`%instanceof%` <- .jinstanceof <- function( o, cl ){
if( !inherits( o, "jobjRef" ) ){
......
This diff is collapsed.
##
# This material is distributed under the GNU General Public License
# Version 2. You may review the terms of this license at
# http://www.gnu.org/licenses/gpl-2.0.html
#
# Copyright (c) 2006 Simon Urbanek <simon.urbanek@r-project.org>
# Copyright (c) 2018, Oracle and/or its affiliates
#
# All rights reserved.
##
## This file is part of the rJava package - low-level R/Java interface
## (C)2006 Simon Urbanek <simon.urbanek@r-project.org>
## For license terms see DESCRIPTION and/or LICENSE
......@@ -85,71 +96,83 @@
assign(".jclassClass", .jcall("java/lang/Class","Ljava/lang/Class;","forName","java.lang.Class"), .env)
assign(".jclassString", .jcall("java/lang/Class","Ljava/lang/Class;","forName","java.lang.String"), .env)
ic <- .jcall("java/lang/Class","Ljava/lang/Class;","forName","java.lang.Integer")
f<-.jcall(ic,"Ljava/lang/reflect/Field;","getField", "TYPE")
assign(".jclass.int", .jcast(.jcall(f,"Ljava/lang/Object;","get",.jcast(ic,"java/lang/Object")),"java/lang/Class"), .env)
ic <- .jcall("java/lang/Class","Ljava/lang/Class;","forName","java.lang.Double")
f<-.jcall(ic,"Ljava/lang/reflect/Field;","getField", "TYPE")
assign(".jclass.double", .jcast(.jcall(f,"Ljava/lang/Object;","get",.jcast(ic,"java/lang/Object")),"java/lang/Class"), .env)
ic <- .jcall("java/lang/Class","Ljava/lang/Class;","forName","java.lang.Float")
f<-.jcall(ic,"Ljava/lang/reflect/Field;","getField", "TYPE")
assign(".jclass.float", .jcast(.jcall(f,"Ljava/lang/Object;","get",.jcast(ic,"java/lang/Object")),"java/lang/Class"), .env)
ic <- .jcall("java/lang/Class","Ljava/lang/Class;","forName","java.lang.Boolean")
f<-.jcall(ic,"Ljava/lang/reflect/Field;","getField", "TYPE")
assign(".jclass.boolean", .jcast(.jcall(f,"Ljava/lang/Object;","get",.jcast(ic,"java/lang/Object")),"java/lang/Class"), .env)
ic <- .jcall("java/lang/Class","Ljava/lang/Class;","forName","java.lang.Void")
f<-.jcall(ic,"Ljava/lang/reflect/Field;","getField", "TYPE")
assign(".jclass.void", .jcast(.jcall(f,"Ljava/lang/Object;","get",.jcast(ic,"java/lang/Object")),"java/lang/Class"), .env)
# copied from bellow, need the RJavaTools to invoke $getField("TYPE") instead of not working .jcall
.Call( initRJavaTools)
.jaddClassPath(file.path(.rJava.base.path,"java"))
# FASTR <<<<<
# ic <- .jcall("java/lang/Class","Ljava/lang/Class;","forName","java.lang.Integer")
# # TODO .jcall does not work because in RcallMethod we do javaObejct[getField]("TYPE") and truffle does not allow it?
# # on the other hand ic$getField() is routed via the reflective RJavaTools.invokeMethod()
# #f<-.jcall(ic,"Ljava/lang/reflect/Field;","getField", "TYPE")
# f <- ic$getField("TYPE")
# assign(".jclass.int", .jcast(.jcall(f,"Ljava/lang/Object;","get",.jcast(ic,"java/lang/Object")),"java/lang/Class"), .env)
# ic <- .jcall("java/lang/Class","Ljava/lang/Class;","forName","java.lang.Double")
# # f<-.jcall(ic,"Ljava/lang/reflect/Field;","getField", "TYPE")
# f <- ic$getField("TYPE")
# assign(".jclass.double", .jcast(.jcall(f,"Ljava/lang/Object;","get",.jcast(ic,"java/lang/Object")),"java/lang/Class"), .env)
# ic <- .jcall("java/lang/Class","Ljava/lang/Class;","forName","java.lang.Float")
# # f<-.jcall(ic,"Ljava/lang/reflect/Field;","getField", "TYPE")
# f <- ic$getField("TYPE")
# assign(".jclass.float", .jcast(.jcall(f,"Ljava/lang/Object;","get",.jcast(ic,"java/lang/Object")),"java/lang/Class"), .env)
# ic <- .jcall("java/lang/Class","Ljava/lang/Class;","forName","java.lang.Boolean")
# # f<-.jcall(ic,"Ljava/lang/reflect/Field;","getField", "TYPE")
# f <- ic$getField("TYPE")
# assign(".jclass.boolean", .jcast(.jcall(f,"Ljava/lang/Object;","get",.jcast(ic,"java/lang/Object")),"java/lang/Class"), .env)
# ic <- .jcall("java/lang/Class","Ljava/lang/Class;","forName","java.lang.Void")
# # f<-.jcall(ic,"Ljava/lang/reflect/Field;","getField", "TYPE")
# f <- ic$getField("TYPE")
# assign(".jclass.void", .jcast(.jcall(f,"Ljava/lang/Object;","get",.jcast(ic,"java/lang/Object")),"java/lang/Class"), .env)
## if NOAWT is set, set AWT to headless
if (nzchar(Sys.getenv("NOAWT"))) .jcall("java/lang/System","S","setProperty","java.awt.headless","true")
lib <- "libs"
if (nchar(.Platform$r_arch)) lib <- file.path("libs", .Platform$r_arch)
rjcl <- NULL
if (xr==1) { # && nchar(classpath)>0) {
# ok, so we're attached to some other JVM - now we need to make sure that
# we can load our class loader. If we can't then we have to use our bad hack
# to be able to squeeze our loader in
# first, see if this is actually JRIBootstrap so we have a loader already
rjcl <- .Call(RJava_primary_class_loader)
if (is.null(rjcl) || .jidenticalRef(rjcl,.jzeroRef)) rjcl <- NULL
else rjcl <- new("jobjRef", jobj=rjcl, jclass="RJavaClassLoader")
if (is.jnull(rjcl))
rjcl <- .jnew("RJavaClassLoader", .rJava.base.path,
file.path(.rJava.base.path, lib), check=FALSE)
.jcheck(silent=TRUE)
if (is.jnull(rjcl)) {
## it's a hack, so we run it in try(..) in case BadThings(TM) happen ...
cpr <- try(.jmergeClassPath(boot.classpath), silent=TRUE)
if (inherits(cpr, "try-error")) {
.jcheck(silent=TRUE)
if (!silent) warning("Another VM is running already and the VM did not allow me to append paths to the class path.")
assign(".jinit.merge.error", cpr, .env)
}
if (length(parameters)>0 && any(parameters!=getOption("java.parameters")) && !silent)
warning("Cannot set VM parameters, because VM is running already.")
}
}
#if (nzchar(Sys.getenv("NOAWT"))) .jcall("java/lang/System","S","setProperty","java.awt.headless","true")
#lib <- "libs"
#if (nchar(.Platform$r_arch)) lib <- file.path("libs", .Platform$r_arch)
# TODO classloader stuff, ignore for now, maybe forever
# rjcl <- NULL
# if (xr==1) { # && nchar(classpath)>0) {
# # ok, so we're attached to some other JVM - now we need to make sure that
# # we can load our class loader. If we can't then we have to use our bad hack
# # to be able to squeeze our loader in
if (is.jnull(rjcl))
rjcl <- .jnew("RJavaClassLoader", .rJava.base.path,
file.path(.rJava.base.path, lib), check=FALSE )
# # first, see if this is actually JRIBootstrap so we have a loader already
# rjcl <- .Call(RJava_primary_class_loader)
# if (is.null(rjcl) || .jidenticalRef(rjcl,.jzeroRef)) rjcl <- NULL
# else rjcl <- new("jobjRef", jobj=rjcl, jclass="RJavaClassLoader")
# if (is.jnull(rjcl))
# rjcl <- .jnew("RJavaClassLoader", .rJava.base.path,
# file.path(.rJava.base.path, lib), check=FALSE)
# .jcheck(silent=TRUE)
# if (is.jnull(rjcl)) {
# ## it's a hack, so we run it in try(..) in case BadThings(TM) happen ...
# cpr <- try(.jmergeClassPath(boot.classpath), silent=TRUE)
# if (inherits(cpr, "try-error")) {
# .jcheck(silent=TRUE)
# if (!silent) warning("Another VM is running already and the VM did not allow me to append paths to the class path.")
# assign(".jinit.merge.error", cpr, .env)
# }
# if (length(parameters)>0 && any(parameters!=getOption("java.parameters")) && !silent)
# warning("Cannot set VM parameters, because VM is running already.")
# }
# }
if (!is.jnull(rjcl)) {
## init class loader
assign(".rJava.class.loader", rjcl, .env)
# if (is.jnull(rjcl))
# rjcl <- .jnew("RJavaClassLoader", .rJava.base.path,
# file.path(.rJava.base.path, lib), check=FALSE )
##-- set the class for native code
.Call(RJava_set_class_loader, .env$.rJava.class.loader@jobj)
# if (!is.jnull(rjcl)) {
# ## init class loader
# assign(".rJava.class.loader", rjcl, .env)
## now it's time to add any additional class paths
# ##-- set the class for native code
# .Call(RJava_set_class_loader, .env$.rJava.class.loader@jobj)
# ## now it's time to add any additional class paths
cpc <- unique(strsplit(classpath, .Platform$path.sep)[[1]])
if (length(cpc)) .jaddClassPath(cpc)
} else stop("Unable to create a Java class loader.")
# } else stop("Unable to create a Java class loader.")
# FASTR >>>>>
##.Call(RJava_new_class_loader, .rJava.base.path, file.path(.rJava.base.path, lib))
## lock namespace bindings
......
## bindings into JRI
## warning: JRI REXP class has currently no finalizers! (RReleaseREXP must be used manually for now)
## warning: this produces JRI-API pbjects - that should go away! use toJava below
.r2j <- function(x, engine = NULL, convert = TRUE) {
if (is.null(engine)) engine <- .jcall("org/rosuda/JRI/Rengine","Lorg/rosuda/JRI/Rengine;","getMainEngine")
if (!is(engine, "jobjRef")) stop("invalid or non-existent engine")
new("jobjRef",jobj=.Call(PushToREXP,"org/rosuda/JRI/REXP",engine@jobj,engine@jclass,x,convert),jclass="org/rosuda/JRI/REXP")
}
toJava <- function(x, engine = NULL) {
## this is really the wrong place for all this REngine checking stuff, but so far .jengine uses JRI API only and legacy code may rely on that
## so this is the only place that assumes REngine API and thus will load it ...
ec <- .jfindClass("org.rosuda.JRI.Rengine", silent=TRUE)
if (is.jnull(ec)) {
.jcheck(TRUE)
stop("JRI is not loaded. Please start JRI first - see ?.jengine")
}
ec <- .jfindClass("org.rosuda.REngine.REngine", silent=TRUE)
if (is.jnull(ec)) {
.jcheck(TRUE)
fn <- system.file("jri","REngine.jar",package="rJava")
if (nzchar(fn)) .jaddClassPath(fn)
fn <- system.file("jri","JRIEngine.jar",package="rJava")
if (nzchar(fn)) .jaddClassPath(fn)
ec <- .jfindClass("org.rosuda.REngine.REngine", silent=TRUE)
if (is.jnull(ec)) {
.jcheck(TRUE)
stop("Cannot find REngine API classes. Please make sure you have installed and loaded the REngine API")
}
}
if (is.null(engine)) engine <- .jcall("org/rosuda/REngine/REngine","Lorg/rosuda/REngine/REngine;","getLastEngine")
if (is.jnull(engine)) { # no last engine, but there may be JRI engine already running ...
me <- .jcall("org/rosuda/JRI/Rengine","Lorg/rosuda/JRI/Rengine;","getMainEngine", check=FALSE)
.jcheck(TRUE)
if (is.jnull(me)) stop("JRI is not running. Please start JRI first - see ?.jengine")
engine <- .jnew("org/rosuda/REngine/JRI/JRIEngine", me)
.jcheck(TRUE)
}
.jcheck(TRUE)
if (!is(engine, "jobjRef")) stop("invalid or non-existent engine")
new("jobjRef",jobj=.Call(PushToREXP,"org/rosuda/REngine/REXPReference",engine@jobj,"org/rosuda/REngine/REngine",x,NULL),jclass="org/rosuda/REngine/REXPReference")
}
.setupJRI <- function(new=TRUE) {
ec <- .jfindClass("org.rosuda.JRI.Rengine", silent=TRUE)
if (is.jnull(ec)) {
.jcheck(TRUE)
.jaddClassPath(system.file("jri","JRI.jar",package="rJava"))
ec <- .jfindClass("org.rosuda.JRI.Rengine", silent=TRUE)
.jcheck(TRUE)
if (is.jnull(ec))
stop("Cannot find JRI classes")
}
me <- .jcall("org/rosuda/JRI/Rengine","Lorg/rosuda/JRI/Rengine;","getMainEngine", check=FALSE)
.jcheck(TRUE)
if (!is.jnull(me)) {
if (!new) return(TRUE)
warning("JRI engine is already running.")
return(FALSE)
}
e <- .jnew("org/rosuda/JRI/Rengine")
!is.jnull(e)
}
.jengine <- function(start=FALSE, silent=FALSE) {
me <- NULL
ec <- .jfindClass("org.rosuda.JRI.Rengine", silent=TRUE)
.jcheck(TRUE)
if (!is.jnull(ec)) {
me <- .jcall("org/rosuda/JRI/Rengine","Lorg/rosuda/JRI/Rengine;","getMainEngine", check=FALSE)
.jcheck(TRUE)
}
if (is.jnull(me)) {
if (!start) {
if (silent) return(NULL)
stop("JRI engine is not running.")
}
.setupJRI(FALSE)
me <- .jcall("org/rosuda/JRI/Rengine","Lorg/rosuda/JRI/Rengine;","getMainEngine", check=FALSE)
.jcheck(TRUE)
}
if (is.jnull(me) && !silent)
stop("JRI engine is not running.")
me
}
##
# This material is distributed under the GNU General Public License
# Version 2. You may review the terms of this license at
# http://www.gnu.org/licenses/gpl-2.0.html
#
# Copyright (c) 2006 Simon Urbanek <simon.urbanek@r-project.org>
# Copyright (c) 2018, Oracle and/or its affiliates
#
# All rights reserved.
##
.jaddClassPath <- function(path) {
if (!length(path)) return(invisible(NULL))
if (!is.jnull(.rJava.class.loader))
invisible(.jcall(.rJava.class.loader,"V","addClassPath",as.character(path)))
else {
cpr <- try(.jmergeClassPath(paste(path,collapse=.Platform$path.sep)), silent=TRUE)
invisible(!inherits(cpr, "try-error"))
}
# FASTR <<<<<
# if (!is.jnull(.rJava.class.loader))
# invisible(.jcall(.rJava.class.loader,"V","addClassPath",as.character(path)))
# else {
# cpr <- try(.jmergeClassPath(paste(path,collapse=.Platform$path.sep)), silent=TRUE)
# invisible(!inherits(cpr, "try-error"))
#}
invisible(java.addToClasspath(path))
# FASTR >>>>>
}
.jclassPath <- function() {
if (is.jnull(.rJava.class.loader)) {
cp <- .jcall("java/lang/System", "S", "getProperty", "java.class.path")
unlist(strsplit(cp, .Platform$path.sep))
} else {
.jcall(.rJava.class.loader,"[Ljava/lang/String;","getClassPath")
}
# FASTR <<<<<
# if (is.jnull(.rJava.class.loader)) {
# cp <- .jcall("java/lang/System", "S", "getProperty", "java.class.path")
# unlist(strsplit(cp, .Platform$path.sep))
# } else {
# .jcall(.rJava.class.loader,"[Ljava/lang/String;","getClassPath")
# }
java.classpath()
# FASTR >>>>>
}
.jaddLibrary <- function(name, path) {
if (!is.jnull(.rJava.class.loader))
invisible(.jcall(.rJava.class.loader, "V", "addRLibrary", as.character(name)[1], as.character(path)[1]))
# FASTR TODO
stop(".jaddLibrary overriden but not yet implemented")
# if (!is.jnull(.rJava.class.loader))
# invisible(.jcall(.rJava.class.loader, "V", "addRLibrary", as.character(name)[1], as.character(path)[1]))
}
.jrmLibrary <- function(name) {
......@@ -27,7 +46,9 @@
}
.jclassLoader <- function() {
.rJava.class.loader
# FASTR TODO
stop(".jclassLoader overriden but not yet implemented")
#.rJava.class.loader
}
.jpackage <- function(name, jars='*', morePaths='', nativeLibrary=FALSE, lib.loc=NULL) {
......
##
# This material is distributed under the GNU General Public License
# Version 2. You may review the terms of this license at
# http://www.gnu.org/licenses/gpl-2.0.html
#
# Copyright (c) 2006 Simon Urbanek <simon.urbanek@r-project.org>
# Copyright (c) 2018, Oracle and/or its affiliates
#
# All rights reserved.
##
.jmemprof <- function(file = "-") {
if (is.null(file)) file <- ""
invisible(.Call(RJava_set_memprof, as.character(file)))
......
##
# This material is distributed under the GNU General Public License
# Version 2. You may review the terms of this license at
# http://www.gnu.org/licenses/gpl-2.0.html
#
# Copyright (c) 2006 Simon Urbanek <simon.urbanek@r-project.org>
# Copyright (c) 2018, Oracle and/or its affiliates
#
# All rights reserved.
##
## methods for jobjRef class
##
## additional methods ($ and $<-) are defined in reflection.R
......
##
# This material is distributed under the GNU General Public License
# Version 2. You may review the terms of this license at
# http://www.gnu.org/licenses/gpl-2.0.html
#
# Copyright (c) 2006 Simon Urbanek <simon.urbanek@r-project.org>
# Copyright (c) 2018, Oracle and/or its affiliates
#
# All rights reserved.
##
.joptions <- function(...) {
l <- list(...)
if (length(l)==0) return(list())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment