Class RJavaClassLoader
- java.lang.Object
- 
- java.lang.ClassLoader
- 
- java.security.SecureClassLoader
- 
- java.net.URLClassLoader
- 
- RJavaClassLoader
 
 
 
 
- 
- All Implemented Interfaces:
- java.io.Closeable,- java.lang.AutoCloseable
 
 public class RJavaClassLoader extends java.net.URLClassLoaderClass loader used internally by rJava The class manages the class paths and the native libraries (jri, ...)
- 
- 
Field SummaryFields Modifier and Type Field Description static RJavaClassLoaderprimaryLoadersingletonbooleanuseSystemShould the system class loader be used to resolve classes as well as this class loaderstatic booleanverbosePrint debug messages if is set totrue
 - 
Constructor SummaryConstructors Constructor Description RJavaClassLoader(java.lang.String path, java.lang.String libpath)Constructor.RJavaClassLoader(java.lang.String path, java.lang.String libpath, RJavaClassLoader parent)Constructor.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddClassPath(java.lang.String cp)adds an entry to the class pathvoidaddClassPath(java.lang.String[] cp)adds several entries to the class pathvoidaddRLibrary(java.lang.String name, java.lang.String path)add a library to path mapping for a native libraryvoidbootClass(java.lang.String cName, java.lang.String mName, java.lang.String[] args)Boots the specified method of the specified classprotected java.lang.ClassfindClass(java.lang.String name)protected java.lang.StringfindLibrary(java.lang.String name)java.net.URLfindResource(java.lang.String name)java.lang.String[]getClassPath()static RJavaClassLoadergetPrimaryLoader()Returns the singleton instance of RJavaClassLoaderstatic voidmain(java.lang.String[] args)main methodstatic voidsetDebug(int level)Set the debug level.static byte[]toByte(java.lang.Object object)Serialize an object to a byte array.java.lang.ObjecttoObject(byte[] byteArray)Deserialize an object from a byte array.static java.lang.ObjecttoObjectPL(byte[] byteArray)converts the byte array into an Object using the primary RJavaClassLoaderstatic java.lang.Stringu2w(java.lang.String fn)Utility to convert paths for windows.- 
Methods inherited from class java.net.URLClassLoaderaddURL, close, definePackage, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
 - 
Methods inherited from class java.lang.ClassLoaderclearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
- 
 
- 
- 
- 
Field Detail- 
primaryLoaderpublic static RJavaClassLoader primaryLoader singleton
 - 
verbosepublic static boolean verbose Print debug messages if is set totrue
 - 
useSystempublic boolean useSystem Should the system class loader be used to resolve classes as well as this class loader
 
- 
 - 
Constructor Detail- 
RJavaClassLoaderpublic RJavaClassLoader(java.lang.String path, java.lang.String libpath)Constructor. The first time an RJavaClassLoader is created, it is cached as the primary loader.- Parameters:
- path- path of the rJava package
- libpath- lib sub directory of the rJava package
 
 - 
RJavaClassLoaderpublic RJavaClassLoader(java.lang.String path, java.lang.String libpath, RJavaClassLoader parent)Constructor. The first time an RJavaClassLoader is created, it is cached as the primary loader.- Parameters:
- path- path of the rJava package
- libpath- lib sub directory of the rJava package
- parent- parent loader if we should fall back upstream or NULL
 
 
- 
 - 
Method Detail- 
getPrimaryLoaderpublic static RJavaClassLoader getPrimaryLoader() Returns the singleton instance of RJavaClassLoader
 - 
findClassprotected java.lang.Class findClass(java.lang.String name) throws java.lang.ClassNotFoundException- Overrides:
- findClassin class- java.net.URLClassLoader
- Throws:
- java.lang.ClassNotFoundException
 
 - 
findResourcepublic java.net.URL findResource(java.lang.String name) - Overrides:
- findResourcein class- java.net.URLClassLoader
 
 - 
addRLibrarypublic void addRLibrary(java.lang.String name, java.lang.String path)add a library to path mapping for a native library
 - 
addClassPathpublic void addClassPath(java.lang.String cp) adds an entry to the class path
 - 
addClassPathpublic void addClassPath(java.lang.String[] cp) adds several entries to the class path
 - 
getClassPathpublic java.lang.String[] getClassPath() - Returns:
- the array of class paths used by this class loader
 
 - 
findLibraryprotected java.lang.String findLibrary(java.lang.String name) - Overrides:
- findLibraryin class- java.lang.ClassLoader
 
 - 
bootClasspublic 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.ClassNotFoundExceptionBoots the specified method of the specified class- Parameters:
- cName- class to boot
- mName- method to boot (typically main). The method must take a String[] as parameter
- args- arguments to pass to the method
- Throws:
- java.lang.IllegalAccessException
- java.lang.reflect.InvocationTargetException
- java.lang.NoSuchMethodException
- java.lang.ClassNotFoundException
 
 - 
setDebugpublic static void setDebug(int level) Set the debug level. At the moment, there is only verbose (level > 0) or quiet- Parameters:
- level- debug level. verbose (>0), quiet otherwise
 
 - 
u2wpublic static java.lang.String u2w(java.lang.String fn) Utility to convert paths for windows. Converts / to the path separator in use- Parameters:
- fn- file name
 
 - 
mainpublic static void main(java.lang.String[] args) main methodThis 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 classThis makes sure R and rJava are known by the class loader 
 - 
toBytepublic static byte[] toByte(java.lang.Object object) throws java.lang.ExceptionSerialize an object to a byte array. (code by CB)- Parameters:
- object- object to serialize
- Returns:
- byte array that represents the object
- Throws:
- java.lang.Exception
 
 - 
toObjectpublic java.lang.Object toObject(byte[] byteArray) throws java.lang.ExceptionDeserialize an object from a byte array. (code by CB)- Parameters:
- byteArray-
- Returns:
- the object that is represented by the byte array
- Throws:
- java.lang.Exception
 
 - 
toObjectPLpublic static java.lang.Object toObjectPL(byte[] byteArray) throws java.lang.Exceptionconverts the byte array into an Object using the primary RJavaClassLoader- Throws:
- java.lang.Exception
 
 
- 
 
-