public static class GroovyClassLoader.InnerLoader
extends GroovyClassLoader
Loader used while defining classes during a compilation round.
| Fields inherited from class | Fields |
|---|---|
class GroovyClassLoader |
classCache, sourceCache |
| Constructor and description |
|---|
InnerLoader(GroovyClassLoader delegate)Creates an inner loader delegating to the supplied outer Groovy class loader. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public void |
addClasspath(String path)* adds a classpath to this classloader. * *
|
|
public void |
addURL(URL url)* adds a URL to the classloader. * *
|
|
public void |
clearAssertionStatus()Sets the default assertion status for this class loader to false and discards any package defaults or class assertion
status settings associated with the class loader. This method is
provided so that class loaders can be made to ignore any command line or
persistent assertion status settings and "start with a clean slate."
|
|
public void |
clearCache()* Removes all classes from the class cache. * * In addition to internal caches this method also clears any * previously set MetaClass information for the given set of * classes being removed. * *
|
|
public void |
close()* Closes this GroovyClassLoader and clears any caches it maintains. * * No use should be made of this instance after this method is * invoked. Any classes that are already loaded are still accessible. * *
|
|
public Class |
defineClass(ClassNode classNode, String file, String newCodeBase)* Compiles the given ClassNode returning the resulting Class.
* * WARNING: compilation is not synchronized |
|
public Class |
defineClass(String name, byte[] b)* Converts an array of bytes into an instance of Class. Before the
* class can be used it must be resolved.
|
|
public URL |
findResource(String name)Finds the resource with the specified name on the URL search path.
|
|
public Enumeration<URL> |
findResources(String name)Returns an Enumeration of URLs representing all of the resources on the URL search path having the specified name.
|
|
public String |
generateScriptName()* Generates a unique script name for unnamed parsed sources. * *
|
|
public Class[] |
getLoadedClasses()* Returns all Groovy classes loaded by this class loader. * *
|
|
public URL |
getResource(String name)Finds the resource with the given name. A resource is some data (images, audio, text, etc) that can be accessed by class code in a way that is independent of the location of the code. The name of a resource is a ' Resources in named modules are subject to the encapsulation rules
specified by Module.getResourceAsStream.
Additionally, and except for the special case where the resource has a
name ending with "
|
|
public InputStream |
getResourceAsStream(String name)Returns an input stream for reading the specified resource. If this loader is closed, then any resources opened by this method will be closed. The search order is described in the documentation for getResource(String).
|
|
public GroovyResourceLoader |
getResourceLoader()* Returns the resource loader used to resolve Groovy source by script name. * *
|
|
public Enumeration<URL> |
getResources(String name)Finds all the resources with the given name. A resource is some data (images, audio, text, etc) that can be accessed by class code in a way that is independent of the location of the code. The name of a resource is a Resources in named modules are subject to the encapsulation rules
specified by Module.getResourceAsStream.
Additionally, and except for the special case where the resource has a
name ending with "
|
|
public long |
getTimeStamp()Returns the creation timestamp of this inner loader. |
|
public URL[] |
getURLs()Returns the search path of URLs for loading classes and resources. This includes the original list of URLs specified to the constructor, along with any URLs subsequently appended by the addURL() method.
|
|
public Boolean |
isShouldRecompile()* gets the currently set recompilation mode. null means, the * compiler configuration is used. False means no recompilation and * true means that recompilation will be done if needed. * *
|
|
public Class<?> |
loadClass(String name)* Loads the class with the specified binary name. This method searches for classes in the same manner as the loadClass(String, boolean) method. It is invoked by the Java virtual machine to resolve class references. Invoking this method is equivalent to invoking loadClass(name,.
|
|
public Class |
loadClass(String name, boolean lookupScriptFiles, boolean preferClassOverScript)* Loads a class from a file or a parent loader. This method delegates to: *
*
*
|
|
public Class |
loadClass(String name, boolean lookupScriptFiles, boolean preferClassOverScript, boolean resolve)* Loads a class from a file or a parent loader. * *
|
|
public Class |
parseClass(File file)* Parses the given file into a Java class capable of being run * *
|
|
public Class |
parseClass(GroovyCodeSource codeSource)* Parses Groovy source described by a GroovyCodeSource. * *
|
|
public Class |
parseClass(GroovyCodeSource codeSource, boolean shouldCache)* Parses the given code source into a Java class. If there is a class file * for the given code source, then no parsing is done, instead the cached class is returned. * *
|
|
public Class |
parseClass(Reader reader, String fileName)* Parses Groovy source read from a Reader. * *
|
|
public Class |
parseClass(String text)* Parses the given text into a Java class capable of being run * *
|
|
public Class |
parseClass(String text, String fileName)* Parses the given text into a Java class capable of being run * *
|
|
public void |
setClassAssertionStatus(String className, boolean enabled)Sets the desired assertion status for the named top-level class in this class loader and any nested classes contained therein. This setting takes precedence over the class loader's default assertion status, and over any applicable per-package default. This method has no effect if the named class has already been initialized. (Once a class is initialized, its assertion status cannot change.) If the named class is not a top-level class, this invocation will have no effect on the actual assertion status of any class.
|
|
public void |
setDefaultAssertionStatus(boolean enabled)Sets the default assertion status for this class loader. This setting determines whether classes loaded by this class loader and initialized in the future will have assertions enabled or disabled by default. This setting may be overridden on a per-package or per-class basis by invoking setPackageAssertionStatus(String, boolean) or setClassAssertionStatus(String, boolean).
|
|
public void |
setPackageAssertionStatus(String packageName, boolean enabled)Sets the package default assertion status for the named package. The package default assertion status determines the assertion status for classes initialized in the future that belong to the named package or any of its "subpackages". A subpackage of a package named p is any package whose name begins
with " In the event that multiple package defaults apply to a given class,
the package default pertaining to the most specific package takes
precedence over the others. For example, if Package defaults take precedence over the class loader's default assertion status, and may be overridden on a per-class basis by invoking setClassAssertionStatus(String, boolean).
|
|
public void |
setResourceLoader(GroovyResourceLoader resourceLoader)* Sets the resource loader used to resolve Groovy source by script name. * *
|
|
public void |
setShouldRecompile(Boolean mode)* sets if the recompilation should be enabled. There are 3 possible * values for this. Any value different from null overrides the * value from the compiler configuration. true means to recompile if needed * false means to never recompile. * *
|
| Methods inherited from class | Name |
|---|---|
class GroovyClassLoader |
addClasspath, addURL, clearCache, close, createCollector, createCompilationUnit, defineClass, defineClass, genEncodingString, generateScriptName, getClassCacheEntry, getClassPath, getLoadedClasses, getPermissions, getResourceLoader, getTimeStamp, hasCompatibleConfiguration, isRecompilable, isShouldRecompile, isSourceNewer, loadClass, loadClass, loadClass, loadClass, parseClass, parseClass, parseClass, parseClass, parseClass, parseClass, recompile, removeClassCacheEntry, setClassCacheEntry, setResourceLoader, setShouldRecompile |
Creates an inner loader delegating to the supplied outer Groovy class loader.
delegate - the outer loader that owns caches and resources* adds a classpath to this classloader. * *
path - is a jar file or a directory.
** adds a URL to the classloader. * *
url - the new classpath element Sets the default assertion status for this class loader to
false and discards any package defaults or class assertion
status settings associated with the class loader. This method is
provided so that class loaders can be made to ignore any command line or
persistent assertion status settings and "start with a clean slate."
* Removes all classes from the class cache. *
* In addition to internal caches this method also clears any * previously set MetaClass information for the given set of * classes being removed. * *
* Closes this GroovyClassLoader and clears any caches it maintains. *
* No use should be made of this instance after this method is * invoked. Any classes that are already loaded are still accessible. * *
* Compiles the given ClassNode returning the resulting Class.
*
* WARNING: compilation is not synchronized
* Converts an array of bytes into an instance of Class. Before the
* class can be used it must be resolved.
Finds the resource with the specified name on the URL search path.
name - the name of the resourceURL for the resource, or null
if the resource could not be found, or if the loader is closed.Returns an Enumeration of URLs representing all of the resources on the URL search path having the specified name.
name - the resource nameEnumeration of URLs.
If the loader is closed, the Enumeration contains no elements.* Generates a unique script name for unnamed parsed sources. * *
.groovy*
Returns all Groovy classes loaded by this class loader. * *
Finds the resource with the given name. A resource is some data (images, audio, text, etc) that can be accessed by class code in a way that is independent of the location of the code.
The name of a resource is a '/'-separated path name that
identifies the resource.
Resources in named modules are subject to the encapsulation rules
specified by Module.getResourceAsStream.
Additionally, and except for the special case where the resource has a
name ending with ".class", this method will only find resources in
packages of named modules when the package is opened unconditionally (even if the caller of this method is in the
same module as the resource).
name is nullnull the path of the
class loader built into the virtual machine is searched. If not found,
this method will invoke findResource(String) to find the resource.name
- The resource nameURL object for reading the resource; null if
the resource could not be found, a URL could not be
constructed to locate the resource, the resource is in a package
that is not opened unconditionally, or access to the resource is
denied by the security manager.Returns an input stream for reading the specified resource. If this loader is closed, then any resources opened by this method will be closed.
The search order is described in the documentation for getResource(String).
name is nullname
- The resource namenull
if the resource could not be found* Returns the resource loader used to resolve Groovy source by script name. * *
Finds all the resources with the given name. A resource is some data (images, audio, text, etc) that can be accessed by class code in a way that is independent of the location of the code.
The name of a resource is a /-separated path name that
identifies the resource.
Resources in named modules are subject to the encapsulation rules
specified by Module.getResourceAsStream.
Additionally, and except for the special case where the resource has a
name ending with ".class", this method will only find resources in
packages of named modules when the package is opened unconditionally (even if the caller of this method is in the
same module as the resource).
name is nullnull the path of the
class loader built into the virtual machine is searched. It then
invokes findResources(String) to find the resources with the
name in this class loader. It returns an enumeration whose elements
are the URLs found by searching the parent class loader followed by
the elements found with findResources.nextElement method is the same resource that the
getResource(String) method would return.name
- The resource nameURL cannot be
constructed, are in a package that is not opened
unconditionally, or access to the resource is denied by the
security manager, are not returned in the enumeration.Returns the creation timestamp of this inner loader.
Returns the search path of URLs for loading classes and resources. This includes the original list of URLs specified to the constructor, along with any URLs subsequently appended by the addURL() method.
* gets the currently set recompilation mode. null means, the * compiler configuration is used. False means no recompilation and * true means that recompilation will be done if needed. * *
* Loads the class with the specified binary name. This method searches for classes in the same manner as the loadClass(String, boolean) method. It is invoked by the Java virtual machine to resolve class references. Invoking this method is equivalent to invoking loadClass(name,.
name
- The binary name of the classClass object* Loads a class from a file or a parent loader. This method delegates to: *
* loadClass(name, lookupScriptFiles, preferClassOverScript, false);
*
*
** Loads a class from a file or a parent loader. * *
name - of the class to be loaded
*lookupScriptFiles - if false no lookup at files is done at all
*preferClassOverScript - if true the file lookup is only done if there is no class
*resolve - see ClassLoader.loadClass
** Parses the given file into a Java class capable of being run * *
file - the file name to parse
** Parses Groovy source described by a GroovyCodeSource. * *
codeSource - the code source to compile
** Parses the given code source into a Java class. If there is a class file * for the given code source, then no parsing is done, instead the cached class is returned. * *
shouldCacheSource - if true then the generated class will be stored in the source cache
** Parses Groovy source read from a Reader. * *
reader - the reader supplying source text
*fileName - the logical script name
** Parses the given text into a Java class capable of being run * *
text - the text of the script/class to parse
** Parses the given text into a Java class capable of being run * *
text - the text of the script/class to parse
*fileName - the file name to use as the name of the class
*Sets the desired assertion status for the named top-level class in this class loader and any nested classes contained therein. This setting takes precedence over the class loader's default assertion status, and over any applicable per-package default. This method has no effect if the named class has already been initialized. (Once a class is initialized, its assertion status cannot change.)
If the named class is not a top-level class, this invocation will have no effect on the actual assertion status of any class.
className
- The fully qualified class name of the top-level class whose
assertion status is to be set.enabled
- true if the named class is to have assertions
enabled when (and if) it is initialized, false if the
class is to have assertions disabled.Sets the default assertion status for this class loader. This setting determines whether classes loaded by this class loader and initialized in the future will have assertions enabled or disabled by default. This setting may be overridden on a per-package or per-class basis by invoking setPackageAssertionStatus(String, boolean) or setClassAssertionStatus(String, boolean).
enabled
- true if classes loaded by this class loader will
henceforth have assertions enabled by default, false
if they will have assertions disabled by default.Sets the package default assertion status for the named package. The package default assertion status determines the assertion status for classes initialized in the future that belong to the named package or any of its "subpackages".
A subpackage of a package named p is any package whose name begins
with "p.". For example, javax.swing.text is a
subpackage of javax.swing, and both java.util and
java.lang.reflect are subpackages of java.
In the event that multiple package defaults apply to a given class,
the package default pertaining to the most specific package takes
precedence over the others. For example, if javax.lang and
javax.lang.reflect both have package defaults associated with
them, the latter package default applies to classes in
javax.lang.reflect.
Package defaults take precedence over the class loader's default assertion status, and may be overridden on a per-class basis by invoking setClassAssertionStatus(String, boolean).
packageName
- The name of the package whose package default assertion status
is to be set. A null value indicates the unnamed
package that is "current"
(see section {@jls 7.4.2} of
The Java Language Specification.)enabled
- true if classes loaded by this classloader and
belonging to the named package or any of its subpackages will
have assertions enabled by default, false if they will
have assertions disabled by default.* Sets the resource loader used to resolve Groovy source by script name. * *
resourceLoader - the resource loader to use* sets if the recompilation should be enabled. There are 3 possible * values for this. Any value different from null overrides the * value from the compiler configuration. true means to recompile if needed * false means to never recompile. * *
mode - the recompilation mode
*Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.