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.
|
RJavaClassLoader(java.lang.String path,
java.lang.String libpath,
RJavaClassLoader parent)
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, newInstanceclearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLoadedClass, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSignerspublic static RJavaClassLoader primaryLoader
public static boolean verbose
truepublic 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 RJavaClassLoader(java.lang.String path,
java.lang.String libpath,
RJavaClassLoader parent)
path - path of the rJava packagelibpath - lib sub directory of the rJava packageparent - parent loader if we should fall back upstream or NULLpublic static RJavaClassLoader getPrimaryLoader()
protected java.lang.Class findClass(java.lang.String name)
throws java.lang.ClassNotFoundException
findClass in class java.net.URLClassLoaderjava.lang.ClassNotFoundExceptionpublic java.net.URL findResource(java.lang.String name)
findResource in class java.net.URLClassLoaderpublic 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.ClassLoaderpublic 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.IllegalAccessExceptionjava.lang.reflect.InvocationTargetExceptionjava.lang.NoSuchMethodExceptionjava.lang.ClassNotFoundExceptionpublic 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.Exceptionpublic java.lang.Object toObject(byte[] byteArray)
throws java.lang.Exception
byteArray - java.lang.Exceptionpublic static java.lang.Object toObjectPL(byte[] byteArray)
throws java.lang.Exception
java.lang.Exception