Package ch.grengine.load
Class SourceClassLoader
java.lang.Object
java.lang.ClassLoader
ch.grengine.load.SourceClassLoader
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
BytecodeClassLoader,LayeredClassLoader
Abstract class loader that can load the main and other classes of a source.
- Since:
- 1.0
- Author:
- Alain Stalder, Made in Switzerland.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract SourceClassLoaderclone()creates a clone with identical behavior, typically sharing the same bytecode.abstract BytecodeClassLoadertries to find the bytecode class loader that can load classes that were created by compiling the given source.abstract LoadModegets the load mode.abstract Class<?>loads a class with the given name and from the given source.abstract Class<?>loadMainClass(Source source) loads the main class of the given source.abstract voidreleaseClasses(ClassReleaser releaser) release metadata for all classed ever loaded by this class loader.Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findClass, findLibrary, findLoadedClass, findResource, findResource, findResources, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Constructor Details
-
SourceClassLoader
constructor from parent class loader.- Parameters:
parent- parent class loader- Since:
- 1.0
-
-
Method Details
-
loadMainClass
loads the main class of the given source.First searches for the source, then loads the main class that resulted from compiling the source.
- Parameters:
source- source- Returns:
- main class
- Throws:
CompileException- if compilation was necessary to load the class and failedLoadException- if loading failed, including if the class was not found- Since:
- 1.0
-
loadClass
loads a class with the given name and from the given source.First searches for the source, only then for the class with given name as part of the classes that resulted from compiling the source.
- Parameters:
source- sourcename- class name- Returns:
- class
- Throws:
CompileException- if compilation was necessary to load the class and failedLoadException- if loading failed, including if the class was not found- Since:
- 1.0
-
findBytecodeClassLoaderBySource
tries to find the bytecode class loader that can load classes that were created by compiling the given source.- Parameters:
source- source- Returns:
- bytecode class loader if found, null otherwise
- Since:
- 1.0
-
getLoadMode
gets the load mode.- Returns:
- load mode
- Since:
- 1.0
-
clone
creates a clone with identical behavior, typically sharing the same bytecode. -
releaseClasses
release metadata for all classed ever loaded by this class loader.Allows to remove metadata associated by Groovy (or Java) with a class, which is often necessary to get on-the-fly garbage collection.
Generally call only when really done using this class loader and all loaded classes; subsequently trying to use this class loader or its classes results generally in undefined behavior.
- Parameters:
releaser- class releaser- Since:
- 1.1
-