public class RJavaClassLoader
extends java.net.URLClassLoader
Modifier and Type | Field and Description |
---|---|
static RJavaClassLoader |
primaryLoader
singleton
|
boolean |
useSystem
Should the system class loader be used to resolve classes
as well as this class loader
|
static boolean |
verbose
Print debug messages if is set to
true |
Constructor and Description |
---|
RJavaClassLoader(java.lang.String path,
java.lang.String libpath)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addClassPath(java.lang.String cp)
adds an entry to the class path
|
void |
addClassPath(java.lang.String[] cp)
adds several entries to the class path
|
void |
addRLibrary(java.lang.String name,
java.lang.String path)
add a library to path mapping for a native library
|
void |
bootClass(java.lang.String cName,
java.lang.String mName,
java.lang.String[] args)
Boots the specified method of the specified class
|
protected java.lang.Class |
findClass(java.lang.String name) |
protected java.lang.String |
findLibrary(java.lang.String name) |
java.net.URL |
findResource(java.lang.String name) |
java.lang.String[] |
getClassPath() |
static RJavaClassLoader |
getPrimaryLoader()
Returns the singleton instance of RJavaClassLoader
|
static void |
main(java.lang.String[] args)
main method
This uses the system properties:
rjava.path : path of the rJava package
rjava.lib : lib sub directory of the rJava package
main.class : main class to "boot", assumes Main if not specified
rjava.class.path : set of paths to populate the initiate the class path
and boots the "main" method of the specified main.class ,
passing the args down to the booted class
This makes sure R and rJava are known by the class loader |
static void |
setDebug(int level)
Set the debug level.
|
static byte[] |
toByte(java.lang.Object object)
Serialize an object to a byte array.
|
java.lang.Object |
toObject(byte[] byteArray)
Deserialize an object from a byte array.
|
static java.lang.Object |
toObjectPL(byte[] byteArray)
converts the byte array into an Object using the primary RJavaClassLoader
|
static java.lang.String |
u2w(java.lang.String fn)
Utility to convert paths for windows.
|
addURL, close, definePackage, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLoadedClass, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
public static RJavaClassLoader primaryLoader
public static boolean verbose
true
public boolean useSystem
public RJavaClassLoader(java.lang.String path, java.lang.String libpath)
path
- path of the rJava packagelibpath
- lib sub directory of the rJava packagepublic static RJavaClassLoader getPrimaryLoader()
protected java.lang.Class findClass(java.lang.String name) throws java.lang.ClassNotFoundException
findClass
in class java.net.URLClassLoader
java.lang.ClassNotFoundException
public java.net.URL findResource(java.lang.String name)
findResource
in class java.net.URLClassLoader
public void addRLibrary(java.lang.String name, java.lang.String path)
public void addClassPath(java.lang.String cp)
public void addClassPath(java.lang.String[] cp)
public java.lang.String[] getClassPath()
protected java.lang.String findLibrary(java.lang.String name)
findLibrary
in class java.lang.ClassLoader
public void bootClass(java.lang.String cName, java.lang.String mName, java.lang.String[] args) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException, java.lang.ClassNotFoundException
cName
- class to bootmName
- method to boot (typically main). The method must take a String[] as parameterargs
- arguments to pass to the methodjava.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
java.lang.ClassNotFoundException
public static void setDebug(int level)
level
- debug level. verbose (>0), quiet otherwisepublic static java.lang.String u2w(java.lang.String fn)
fn
- file namepublic static void main(java.lang.String[] args)
This uses the system properties:
rjava.path
: path of the rJava packagerjava.lib
: lib sub directory of the rJava packagemain.class
: main class to "boot", assumes Main if not specifiedrjava.class.path
: set of paths to populate the initiate the class pathand boots the "main" method of the specified main.class
,
passing the args down to the booted class
This makes sure R and rJava are known by the class loader
public static byte[] toByte(java.lang.Object object) throws java.lang.Exception
object
- object to serializejava.lang.Exception
public java.lang.Object toObject(byte[] byteArray) throws java.lang.Exception
byteArray
- java.lang.Exception
public static java.lang.Object toObjectPL(byte[] byteArray) throws java.lang.Exception
java.lang.Exception