Package groovy.lang
Class GroovyClassLoader.InnerLoader
java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
groovy.lang.GroovyClassLoader
groovy.lang.GroovyClassLoader.InnerLoader
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Enclosing class:
- GroovyClassLoader
-
Nested Class Summary
Nested classes/interfaces inherited from class groovy.lang.GroovyClassLoader
GroovyClassLoader.ClassCollector, GroovyClassLoader.InnerLoader
-
Field Summary
Fields inherited from class groovy.lang.GroovyClassLoader
classCache, sourceCache
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addClasspath
(String path) adds a classpath to this classloader.void
adds a URL to the classloader.void
void
Removes all classes from the class cache.void
close()
Closes this GroovyClassLoader and clears any caches it maintains.defineClass
(String name, byte[] b) Converts an array of bytes into an instance ofClass
.defineClass
(ClassNode classNode, String file, String newCodeBase) Compiles the givenClassNode
returning the resultingClass
.findResource
(String name) findResources
(String name) Class[]
Returns all Groovy classes loaded by this class loader.getResource
(String name) getResourceAsStream
(String name) getResources
(String name) long
URL[]
getURLs()
gets the currently set recompilation mode.Class<?>
Loads a class from a file or a parent loader.Loads a class from a file or a parent loader.parseClass
(GroovyCodeSource codeSource) parseClass
(GroovyCodeSource codeSource, boolean shouldCache) Parses the given code source into a Java class.parseClass
(File file) Parses the given file into a Java class capable of being runparseClass
(Reader reader, String fileName) parseClass
(String text) Parses the given text into a Java class capable of being runparseClass
(String text, String fileName) Parses the given text into a Java class capable of being runvoid
setClassAssertionStatus
(String className, boolean enabled) void
setDefaultAssertionStatus
(boolean enabled) void
setPackageAssertionStatus
(String packageName, boolean enabled) void
setResourceLoader
(GroovyResourceLoader resourceLoader) void
setShouldRecompile
(Boolean mode) sets if the recompilation should be enabled.Methods inherited from class groovy.lang.GroovyClassLoader
createCollector, createCompilationUnit, getClassCacheEntry, getClassPath, getPermissions, getTimeStamp, hasCompatibleConfiguration, isRecompilable, isSourceNewer, loadClass, recompile, removeClassCacheEntry, setClassCacheEntry
Methods inherited from class java.net.URLClassLoader
definePackage, findClass, newInstance, newInstance
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass
Methods inherited from class java.lang.ClassLoader
defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, registerAsParallelCapable, resolveClass, resources, setSigners
-
Constructor Details
-
InnerLoader
-
-
Method Details
-
addClasspath
Description copied from class:GroovyClassLoader
adds a classpath to this classloader.- Overrides:
addClasspath
in classGroovyClassLoader
- Parameters:
path
- is a jar file or a directory.- See Also:
-
addURL
Description copied from class:GroovyClassLoader
adds a URL to the classloader.- Overrides:
addURL
in classGroovyClassLoader
- Parameters:
url
- the new classpath element
-
clearAssertionStatus
public void clearAssertionStatus()- Overrides:
clearAssertionStatus
in classClassLoader
-
clearCache
public void clearCache()Description copied from class:GroovyClassLoader
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.
-
close
Description copied from class:GroovyClassLoader
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.
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classGroovyClassLoader
- Throws:
IOException
- See Also:
-
defineClass
Description copied from class:GroovyClassLoader
Compiles the givenClassNode
returning the resultingClass
.WARNING: compilation is not synchronized
- Overrides:
defineClass
in classGroovyClassLoader
-
defineClass
Description copied from class:GroovyClassLoader
Converts an array of bytes into an instance ofClass
. Before the class can be used it must be resolved.- Overrides:
defineClass
in classGroovyClassLoader
-
findResource
- Overrides:
findResource
in classURLClassLoader
-
findResources
- Overrides:
findResources
in classURLClassLoader
- Throws:
IOException
-
generateScriptName
- Overrides:
generateScriptName
in classGroovyClassLoader
-
getLoadedClasses
Description copied from class:GroovyClassLoader
Returns all Groovy classes loaded by this class loader.
- Overrides:
getLoadedClasses
in classGroovyClassLoader
- Returns:
- all classes loaded by this class loader
-
getResource
- Overrides:
getResource
in classClassLoader
-
getResourceAsStream
- Overrides:
getResourceAsStream
in classURLClassLoader
-
getResourceLoader
- Overrides:
getResourceLoader
in classGroovyClassLoader
-
getResources
- Overrides:
getResources
in classClassLoader
- Throws:
IOException
-
getTimeStamp
public long getTimeStamp() -
getURLs
- Overrides:
getURLs
in classURLClassLoader
-
isShouldRecompile
Description copied from class:GroovyClassLoader
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.- Overrides:
isShouldRecompile
in classGroovyClassLoader
- Returns:
- the recompilation mode
-
loadClass
Description copied from class:GroovyClassLoader
- Overrides:
loadClass
in classGroovyClassLoader
- Throws:
ClassNotFoundException
- See Also:
-
loadClass
public Class loadClass(String name, boolean lookupScriptFiles, boolean preferClassOverScript) throws ClassNotFoundException, CompilationFailedException Description copied from class:GroovyClassLoader
Loads a class from a file or a parent loader. This method delegates to:loadClass(name, lookupScriptFiles, preferClassOverScript, false);
- Overrides:
loadClass
in classGroovyClassLoader
- Throws:
ClassNotFoundException
- if class could not be foundCompilationFailedException
- if compilation of script failed
-
loadClass
public Class loadClass(String name, boolean lookupScriptFiles, boolean preferClassOverScript, boolean resolve) throws ClassNotFoundException, CompilationFailedException Description copied from class:GroovyClassLoader
Loads a class from a file or a parent loader.- Overrides:
loadClass
in classGroovyClassLoader
- Parameters:
name
- of the class to be loadedlookupScriptFiles
- if false no lookup at files is done at allpreferClassOverScript
- if true the file lookup is only done if there is no classresolve
- seeClassLoader.loadClass(java.lang.String, boolean)
- Returns:
- the class found or the class created from a file lookup
- Throws:
ClassNotFoundException
- if class could not be foundCompilationFailedException
- if compilation of script failed
-
parseClass
Description copied from class:GroovyClassLoader
Parses the given file into a Java class capable of being run- Overrides:
parseClass
in classGroovyClassLoader
- Parameters:
file
- the file name to parse- Returns:
- the main class defined in the given script
- Throws:
CompilationFailedException
IOException
-
parseClass
- Overrides:
parseClass
in classGroovyClassLoader
- Throws:
CompilationFailedException
-
parseClass
public Class parseClass(GroovyCodeSource codeSource, boolean shouldCache) throws CompilationFailedException Description copied from class:GroovyClassLoader
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.- Overrides:
parseClass
in classGroovyClassLoader
shouldCache
- if true then the generated class will be stored in the source cache- Returns:
- the main class defined in the given script
- Throws:
CompilationFailedException
-
parseClass
- Overrides:
parseClass
in classGroovyClassLoader
- Throws:
CompilationFailedException
-
parseClass
Description copied from class:GroovyClassLoader
Parses the given text into a Java class capable of being run- Overrides:
parseClass
in classGroovyClassLoader
- Parameters:
text
- the text of the script/class to parse- Returns:
- the main class defined in the given script
- Throws:
CompilationFailedException
-
parseClass
Description copied from class:GroovyClassLoader
Parses the given text into a Java class capable of being run- Overrides:
parseClass
in classGroovyClassLoader
- Parameters:
text
- the text of the script/class to parsefileName
- the file name to use as the name of the class- Returns:
- the main class defined in the given script
- Throws:
CompilationFailedException
-
setClassAssertionStatus
- Overrides:
setClassAssertionStatus
in classClassLoader
-
setDefaultAssertionStatus
public void setDefaultAssertionStatus(boolean enabled) - Overrides:
setDefaultAssertionStatus
in classClassLoader
-
setPackageAssertionStatus
- Overrides:
setPackageAssertionStatus
in classClassLoader
-
setResourceLoader
- Overrides:
setResourceLoader
in classGroovyClassLoader
-
setShouldRecompile
Description copied from class:GroovyClassLoader
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.- Overrides:
setShouldRecompile
in classGroovyClassLoader
- Parameters:
mode
- the recompilation mode- See Also:
-