java.lang.Object
org.dellroad.jct.jshell.MemoryLoaderDelegate
- All Implemented Interfaces:
LoaderDelegate
A JShell
LoaderDelegate that uses a MemoryClassLoader.
This class accepts --class-path components that refer to JAR file contents using the jar: URL syntax,
e.g., jar:file:/some/dir/foo.jar!/BOOT-INF/lib/bar.jar. However, this is only partially useful because
(a) you can't build a classpath with components that contain colon characters, and (b) the jshell tool rejects
classpath components that aren't real files.
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.MemoryLoaderDelegate(org.dellroad.stuff.java.MemoryClassLoader loader) Primary constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToClasspath(String path) voidclassesRedefined(ExecutionControl.ClassBytecodes[] classes) Class<?>org.dellroad.stuff.java.MemoryClassLoaderGet theMemoryClassLoaderassociated with this instance.voidload(ExecutionControl.ClassBytecodes[] classes)
-
Constructor Details
-
MemoryLoaderDelegate
public MemoryLoaderDelegate()Default constructor.Uses the current thread's context loader as the parent loader for a newly created
MemoryClassLoader. -
MemoryLoaderDelegate
public MemoryLoaderDelegate(org.dellroad.stuff.java.MemoryClassLoader loader) Primary constructor.- Parameters:
loader- associated class loader- Throws:
IllegalArgumentException- ifloaderis null
-
-
Method Details
-
getClassLoader
public org.dellroad.stuff.java.MemoryClassLoader getClassLoader()Get theMemoryClassLoaderassociated with this instance.- Returns:
- associated class loader
-
addToClasspath
public void addToClasspath(String path) throws ExecutionControl.EngineTerminationException, ExecutionControl.InternalException - Specified by:
addToClasspathin interfaceLoaderDelegate- Throws:
ExecutionControl.EngineTerminationExceptionExecutionControl.InternalException
-
classesRedefined
- Specified by:
classesRedefinedin interfaceLoaderDelegate
-
findClass
- Specified by:
findClassin interfaceLoaderDelegate- Throws:
ClassNotFoundException
-
load
public void load(ExecutionControl.ClassBytecodes[] classes) throws ExecutionControl.ClassInstallException, ExecutionControl.EngineTerminationException - Specified by:
loadin interfaceLoaderDelegate- Throws:
ExecutionControl.ClassInstallExceptionExecutionControl.EngineTerminationException
-