public class BytecodeClassLoader extends SourceClassLoader
SourceClassLoader
interface.
Loads classes based on given bytecode or from the parent class loader. Depending on the given load mode, the parent class loader is searched first or last.
| Constructor and Description |
|---|
BytecodeClassLoader(ClassLoader parent,
LoadMode loadMode,
Code code)
constructor.
|
| Modifier and Type | Method and Description |
|---|---|
BytecodeClassLoader |
clone()
creates a clone with identical behavior, typically sharing the same bytecode.
|
BytecodeClassLoader |
findBytecodeClassLoaderBySource(Source source)
tries to find the bytecode class loader that can load classes that were created
by compiling the given source.
|
protected Class<?> |
findClass(String name) |
Code |
getCode()
gets the code.
|
LoadMode |
getLoadMode()
gets the load mode.
|
Class<?> |
loadClass(Source source,
String name)
loads a class with the given name and from the given source.
|
protected Class<?> |
loadClass(String name,
boolean resolve) |
static Class<?> |
loadClassBySourceAndName(ClassLoader classLoader,
Source source,
String name)
Helper method for loading a class with the given name and from the given source
from the given class loader.
|
Class<?> |
loadMainClass(Source source)
loads the main class of the given source.
|
static Class<?> |
loadMainClassBySource(ClassLoader classLoader,
Source source)
Helper method for loading the main class of the given source from the given class loader.
|
void |
releaseClasses(ClassReleaser releaser)
release metadata for all classed ever loaded by this class loader.
|
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSignerspublic BytecodeClassLoader(ClassLoader parent, LoadMode loadMode, Code code)
parent - parent class loaderloadMode - load modecode - code with bytecode for one or more classesNullPointerException - if any of the arguments is nullprotected Class<?> findClass(String name) throws ClassNotFoundException
findClass in class ClassLoaderClassNotFoundExceptionprotected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
loadClass in class ClassLoaderClassNotFoundExceptionpublic Class<?> loadMainClass(Source source)
SourceClassLoaderFirst searches for the source, then loads the main class that resulted from compiling the source.
loadMainClass in class SourceClassLoadersource - sourcepublic Class<?> loadClass(Source source, String name)
SourceClassLoaderFirst searches for the source, only then for the class with given name as part of the classes that resulted from compiling the source.
loadClass in class SourceClassLoadersource - sourcename - class namepublic BytecodeClassLoader findBytecodeClassLoaderBySource(Source source)
SourceClassLoaderfindBytecodeClassLoaderBySource in class SourceClassLoadersource - sourcepublic LoadMode getLoadMode()
SourceClassLoadergetLoadMode in class SourceClassLoaderpublic static Class<?> loadMainClassBySource(ClassLoader classLoader, Source source)
classLoader - class loadersource - sourceLoadException - if loading failed, including if the class was not foundpublic static Class<?> loadClassBySourceAndName(ClassLoader classLoader, Source source, String name)
classLoader - class loadersource - sourcename - class nameLoadException - if loading failed, including if the class was not foundpublic BytecodeClassLoader clone()
SourceClassLoaderclone in class SourceClassLoaderpublic void releaseClasses(ClassReleaser releaser)
SourceClassLoaderAllows 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.
releaseClasses in class SourceClassLoaderreleaser - class releaserpublic Code getCode()