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
public static class GroovyClassLoader.InnerLoader extends 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
Constructors Constructor Description InnerLoader(GroovyClassLoader delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddClasspath(String path)adds a classpath to this classloader.voidaddURL(URL url)adds a URL to the classloader.voidclearAssertionStatus()voidclearCache()Removes all classes from the class cache.voidclose()Closes this GroovyClassLoader and clears any caches it maintains.ClassdefineClass(String name, byte[] b)open up the super class define that takes raw bytesClassdefineClass(ClassNode classNode, String file, String newCodeBase)Loads the given class node returning the implementation Class.URLfindResource(String name)Enumeration<URL>findResources(String name)StringgenerateScriptName()Class[]getLoadedClasses()Returns all Groovy classes loaded by this class loader.URLgetResource(String name)InputStreamgetResourceAsStream(String name)GroovyResourceLoadergetResourceLoader()Enumeration<URL>getResources(String name)longgetTimeStamp()URL[]getURLs()BooleanisShouldRecompile()gets the currently set recompilation mode.Class<?>loadClass(String name)ClassloadClass(String name, boolean lookupScriptFiles, boolean preferClassOverScript)loads a class from a file or a parent classloader.ClassloadClass(String name, boolean lookupScriptFiles, boolean preferClassOverScript, boolean resolve)loads a class from a file or a parent classloader.ClassparseClass(GroovyCodeSource codeSource)ClassparseClass(GroovyCodeSource codeSource, boolean shouldCache)Parses the given code source into a Java class.ClassparseClass(File file)Parses the given file into a Java class capable of being runClassparseClass(InputStream in, String fileName)Deprecated.ClassparseClass(Reader reader, String fileName)ClassparseClass(String text)Parses the given text into a Java class capable of being runClassparseClass(String text, String fileName)Parses the given text into a Java class capable of being runvoidsetClassAssertionStatus(String className, boolean enabled)voidsetDefaultAssertionStatus(boolean enabled)voidsetPackageAssertionStatus(String packageName, boolean enabled)voidsetResourceLoader(GroovyResourceLoader resourceLoader)voidsetShouldRecompile(Boolean mode)sets if the recompilation should be enable.-
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 Detail
-
InnerLoader
public InnerLoader(GroovyClassLoader delegate)
-
-
Method Detail
-
addClasspath
public void addClasspath(String path)
Description copied from class:GroovyClassLoaderadds a classpath to this classloader.- Overrides:
addClasspathin classGroovyClassLoader- Parameters:
path- is a jar file or a directory.- See Also:
GroovyClassLoader.addURL(URL)
-
clearCache
public void clearCache()
Description copied from class:GroovyClassLoaderRemoves 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.
-
findResource
public URL findResource(String name)
- Overrides:
findResourcein classURLClassLoader
-
findResources
public Enumeration<URL> findResources(String name) throws IOException
- Overrides:
findResourcesin classURLClassLoader- Throws:
IOException
-
getLoadedClasses
public Class[] getLoadedClasses()
Description copied from class:GroovyClassLoaderReturns all Groovy classes loaded by this class loader.
- Overrides:
getLoadedClassesin classGroovyClassLoader- Returns:
- all classes loaded by this class loader
-
getResource
public URL getResource(String name)
- Overrides:
getResourcein classClassLoader
-
getResourceAsStream
public InputStream getResourceAsStream(String name)
- Overrides:
getResourceAsStreamin classURLClassLoader
-
getResourceLoader
public GroovyResourceLoader getResourceLoader()
- Overrides:
getResourceLoaderin classGroovyClassLoader
-
getURLs
public URL[] getURLs()
- Overrides:
getURLsin classURLClassLoader
-
loadClass
public Class loadClass(String name, boolean lookupScriptFiles, boolean preferClassOverScript, boolean resolve) throws ClassNotFoundException, CompilationFailedException
Description copied from class:GroovyClassLoaderloads a class from a file or a parent classloader.- Overrides:
loadClassin 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 the class could not be foundCompilationFailedException- if the source file could not be compiled
-
parseClass
public Class parseClass(GroovyCodeSource codeSource, boolean shouldCache) throws CompilationFailedException
Description copied from class:GroovyClassLoaderParses 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:
parseClassin classGroovyClassLoadershouldCache- if true then the generated class will be stored in the source cache- Returns:
- the main class defined in the given script
- Throws:
CompilationFailedException
-
setResourceLoader
public void setResourceLoader(GroovyResourceLoader resourceLoader)
- Overrides:
setResourceLoaderin classGroovyClassLoader
-
addURL
public void addURL(URL url)
Description copied from class:GroovyClassLoaderadds a URL to the classloader.- Overrides:
addURLin classGroovyClassLoader- Parameters:
url- the new classpath element
-
defineClass
public Class defineClass(ClassNode classNode, String file, String newCodeBase)
Description copied from class:GroovyClassLoaderLoads the given class node returning the implementation Class.WARNING: this compilation is not synchronized
- Overrides:
defineClassin classGroovyClassLoader- Returns:
- a class
-
parseClass
public Class parseClass(File file) throws CompilationFailedException, IOException
Description copied from class:GroovyClassLoaderParses the given file into a Java class capable of being run- Overrides:
parseClassin classGroovyClassLoader- Parameters:
file- the file name to parse- Returns:
- the main class defined in the given script
- Throws:
CompilationFailedExceptionIOException
-
parseClass
public Class parseClass(String text, String fileName) throws CompilationFailedException
Description copied from class:GroovyClassLoaderParses the given text into a Java class capable of being run- Overrides:
parseClassin 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
-
parseClass
public Class parseClass(String text) throws CompilationFailedException
Description copied from class:GroovyClassLoaderParses the given text into a Java class capable of being run- Overrides:
parseClassin classGroovyClassLoader- Parameters:
text- the text of the script/class to parse- Returns:
- the main class defined in the given script
- Throws:
CompilationFailedException
-
generateScriptName
public String generateScriptName()
- Overrides:
generateScriptNamein classGroovyClassLoader
-
parseClass
public Class parseClass(Reader reader, String fileName) throws CompilationFailedException
- Overrides:
parseClassin classGroovyClassLoader- Throws:
CompilationFailedException
-
parseClass
@Deprecated public Class parseClass(InputStream in, String fileName) throws CompilationFailedException
Deprecated.- Overrides:
parseClassin classGroovyClassLoader- Throws:
CompilationFailedException
-
parseClass
public Class parseClass(GroovyCodeSource codeSource) throws CompilationFailedException
- Overrides:
parseClassin classGroovyClassLoader- Throws:
CompilationFailedException
-
defineClass
public Class defineClass(String name, byte[] b)
Description copied from class:GroovyClassLoaderopen up the super class define that takes raw bytes- Overrides:
defineClassin classGroovyClassLoader
-
loadClass
public Class loadClass(String name, boolean lookupScriptFiles, boolean preferClassOverScript) throws ClassNotFoundException, CompilationFailedException
Description copied from class:GroovyClassLoaderloads a class from a file or a parent classloader. This method does call loadClass(String, boolean, boolean, boolean) with the last parameter set to false.- Overrides:
loadClassin classGroovyClassLoader- Throws:
CompilationFailedException- if compilation was not successfulClassNotFoundException
-
setShouldRecompile
public void setShouldRecompile(Boolean mode)
Description copied from class:GroovyClassLoadersets if the recompilation should be enable. There are 3 possible values for this. Any value different than null overrides the value from the compiler configuration. true means to recompile if needed false means to never recompile.- Overrides:
setShouldRecompilein classGroovyClassLoader- Parameters:
mode- the recompilation mode- See Also:
CompilerConfiguration
-
isShouldRecompile
public Boolean isShouldRecompile()
Description copied from class:GroovyClassLoadergets 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:
isShouldRecompilein classGroovyClassLoader- Returns:
- the recompilation mode
-
loadClass
public Class<?> loadClass(String name) throws ClassNotFoundException
- Overrides:
loadClassin classGroovyClassLoader- Throws:
ClassNotFoundException
-
getResources
public Enumeration<URL> getResources(String name) throws IOException
- Overrides:
getResourcesin classClassLoader- Throws:
IOException
-
setDefaultAssertionStatus
public void setDefaultAssertionStatus(boolean enabled)
- Overrides:
setDefaultAssertionStatusin classClassLoader
-
setPackageAssertionStatus
public void setPackageAssertionStatus(String packageName, boolean enabled)
- Overrides:
setPackageAssertionStatusin classClassLoader
-
setClassAssertionStatus
public void setClassAssertionStatus(String className, boolean enabled)
- Overrides:
setClassAssertionStatusin classClassLoader
-
clearAssertionStatus
public void clearAssertionStatus()
- Overrides:
clearAssertionStatusin classClassLoader
-
close
public void close() throws IOExceptionDescription copied from class:GroovyClassLoaderCloses 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classGroovyClassLoader- Throws:
IOException- See Also:
URLClassLoader.close(),GroovyClassLoader.clearCache()
-
getTimeStamp
public long getTimeStamp()
-
-