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
Loader used while defining classes during a compilation round.

- ## 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)`
  Creates an inner loader delegating to the supplied outer Groovy class loader.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addClasspath(String path)`
  adds a classpath to this classloader.
  `void`
  `addURL(URL url)`
  adds a URL to the classloader.
  `void`
  `clearAssertionStatus()`
  `void`
  `clearCache()`
  Removes all classes from the class cache.
  `void`
  `close()`
  Closes this GroovyClassLoader and clears any caches it maintains.
  `Class`
  `defineClass(String name, byte[] b)`
  Converts an array of bytes into an instance of `Class`.
  `Class`
  `defineClass(ClassNode classNode, String file, String newCodeBase)`
  Compiles the given `ClassNode` returning the resulting `Class`.
  `URL`
  `findResource(String name)`
  `Enumeration<URL>`
  `findResources(String name)`
  `String`
  `generateScriptName()`
  Generates a unique script name for unnamed parsed sources.
  `Class[]`
  `getLoadedClasses()`
  Returns all Groovy classes loaded by this class loader.
  `URL`
  `getResource(String name)`
  `InputStream`
  `getResourceAsStream(String name)`
  `GroovyResourceLoader`
  `getResourceLoader()`
  Returns the resource loader used to resolve Groovy source by script name.
  `Enumeration<URL>`
  `getResources(String name)`
  `long`
  `getTimeStamp()`
  Returns the creation timestamp of this inner loader.
  `URL[]`
  `getURLs()`
  `Boolean`
  `isShouldRecompile()`
  gets the currently set recompilation mode.
  `Class<?>`
  `loadClass(String name)`
  `Class`
  `loadClass(String name, boolean lookupScriptFiles, boolean preferClassOverScript)`
  Loads a class from a file or a parent loader.
  `Class`
  `loadClass(String name, boolean lookupScriptFiles, boolean preferClassOverScript, boolean resolve)`
  Loads a class from a file or a parent loader.
  `Class`
  `parseClass(GroovyCodeSource codeSource)`
  Parses Groovy source described by a `GroovyCodeSource`.
  `Class`
  `parseClass(GroovyCodeSource codeSource, boolean shouldCache)`
  Parses the given code source into a Java class.
  `Class`
  `parseClass(File file)`
  Parses the given file into a Java class capable of being run
  `Class`
  `parseClass(Reader reader, String fileName)`
  Parses Groovy source read from a `Reader`.
  `Class`
  `parseClass(String text)`
  Parses the given text into a Java class capable of being run
  `Class`
  `parseClass(String text, String fileName)`
  Parses the given text into a Java class capable of being run
  `void`
  `setClassAssertionStatus(String className, boolean enabled)`
  `void`
  `setDefaultAssertionStatus(boolean enabled)`
  `void`
  `setPackageAssertionStatus(String packageName, boolean enabled)`
  `void`
  `setResourceLoader(GroovyResourceLoader resourceLoader)`
  Sets the resource loader used to resolve Groovy source by script name.
  `void`
  `setShouldRecompile(Boolean mode)`
  sets if the recompilation should be enabled.

  ### Methods inherited from class groovy.lang.GroovyClassLoader

  `createCollector, createCompilationUnit, genEncodingString, 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`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### InnerLoader

    public InnerLoader(GroovyClassLoader delegate)
    Creates an inner loader delegating to the supplied outer Groovy class loader.
    Parameters:
      `delegate` - the outer loader that owns caches and resources

- ## Method Details

  - ### addClasspath

    public void addClasspath(String path)
    adds a classpath to this classloader.
    Overrides:
      `addClasspath` in class `GroovyClassLoader`
    Parameters:
      `path` - is a jar file or a directory.
    See Also:
      - `GroovyClassLoader.addURL(URL)`

  - ### addURL

    public void addURL(URL url)
    adds a URL to the classloader.
    Overrides:
      `addURL` in class `GroovyClassLoader`
    Parameters:
      `url` - the new classpath element

  - ### clearAssertionStatus

    public void clearAssertionStatus()
    Overrides:
      `clearAssertionStatus` in class `ClassLoader`

  - ### clearCache

    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.

    Overrides:
      `clearCache` in class `GroovyClassLoader`
    See Also:
      - `GroovyClassLoader.getClassCacheEntry(String)`
      - `GroovyClassLoader.setClassCacheEntry(Class)`
      - `GroovyClassLoader.removeClassCacheEntry(String)`

  - ### close

    public void close() throws IOException
    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 interface `AutoCloseable`
    Specified by:
      `close` in interface `Closeable`
    Overrides:
      `close` in class `GroovyClassLoader`
    Throws:
      `IOException`
    See Also:
      - `URLClassLoader.close()`
      - `GroovyClassLoader.clearCache()`

  - ### defineClass

    public Class defineClass(ClassNode classNode, String file, String newCodeBase)
    Compiles the given `ClassNode` returning the resulting `Class`.

    WARNING: compilation is not synchronized

    Overrides:
      `defineClass` in class `GroovyClassLoader`

  - ### defineClass

    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.
    Overrides:
      `defineClass` in class `GroovyClassLoader`

  - ### findResource

    public URL findResource(String name)
    Overrides:
      `findResource` in class `URLClassLoader`

  - ### findResources

    public Enumeration<URL> findResources(String name) throws IOException
    Overrides:
      `findResources` in class `URLClassLoader`
    Throws:
      `IOException`

  - ### generateScriptName

    public String generateScriptName()
    Generates a unique script name for unnamed parsed sources.
    Overrides:
      `generateScriptName` in class `GroovyClassLoader`
    Returns:
      a unique script name ending in `.groovy`

  - ### getLoadedClasses

    public Class[] getLoadedClasses()

    Returns all Groovy classes loaded by this class loader.

    Overrides:
      `getLoadedClasses` in class `GroovyClassLoader`
    Returns:
      all classes loaded by this class loader

  - ### getResource

    public URL getResource(String name)
    Overrides:
      `getResource` in class `ClassLoader`

  - ### getResourceAsStream

    public InputStream getResourceAsStream(String name)
    Overrides:
      `getResourceAsStream` in class `URLClassLoader`

  - ### getResourceLoader

    public GroovyResourceLoader getResourceLoader()
    Returns the resource loader used to resolve Groovy source by script name.
    Overrides:
      `getResourceLoader` in class `GroovyClassLoader`
    Returns:
      the current resource loader

  - ### getResources

    public Enumeration<URL> getResources(String name) throws IOException
    Overrides:
      `getResources` in class `ClassLoader`
    Throws:
      `IOException`

  - ### getTimeStamp

    public long getTimeStamp()
    Returns the creation timestamp of this inner loader.
    Returns:
      the timestamp captured when the loader was created

  - ### getURLs

    public URL[] getURLs()
    Overrides:
      `getURLs` in class `URLClassLoader`

  - ### isShouldRecompile

    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.
    Overrides:
      `isShouldRecompile` in class `GroovyClassLoader`
    Returns:
      the recompilation mode

  - ### loadClass

    public Class<?> loadClass(String name) throws ClassNotFoundException
    Overrides:
      `loadClass` in class `GroovyClassLoader`
    Throws:
      `ClassNotFoundException`
    See Also:
      - `ClassLoader.loadClass(java.lang.String,boolean)`

  - ### loadClass

    public Class loadClass(String name, boolean lookupScriptFiles, boolean preferClassOverScript) throws ClassNotFoundException, CompilationFailedException
    Loads a class from a file or a parent loader. This method delegates to:

         loadClass(name, lookupScriptFiles, preferClassOverScript, false);

    Overrides:
      `loadClass` in class `GroovyClassLoader`
    Throws:
      `ClassNotFoundException` - if class could not be found
      `CompilationFailedException` - if compilation of script failed

  - ### loadClass

    public Class loadClass(String name, boolean lookupScriptFiles, boolean preferClassOverScript, boolean resolve) throws ClassNotFoundException, CompilationFailedException
    Loads a class from a file or a parent loader.
    Overrides:
      `loadClass` in class `GroovyClassLoader`
    Parameters:
      `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(java.lang.String, boolean)`
    Returns:
      the class found or the class created from a file lookup
    Throws:
      `ClassNotFoundException` - if class could not be found
      `CompilationFailedException` - if compilation of script failed

  - ### parseClass

    public Class parseClass(File file) throws CompilationFailedException, IOException
    Parses the given file into a Java class capable of being run
    Overrides:
      `parseClass` in class `GroovyClassLoader`
    Parameters:
      `file` - the file name to parse
    Returns:
      the main class defined in the given script
    Throws:
      `CompilationFailedException`
      `IOException`

  - ### parseClass

    public Class parseClass(GroovyCodeSource codeSource) throws CompilationFailedException
    Parses Groovy source described by a `GroovyCodeSource`.
    Overrides:
      `parseClass` in class `GroovyClassLoader`
    Parameters:
      `codeSource` - the code source to compile
    Returns:
      the main class defined by the source
    Throws:
      `CompilationFailedException` - if compilation fails

  - ### parseClass

    public Class parseClass(GroovyCodeSource codeSource, boolean shouldCache) throws CompilationFailedException
    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 class `GroovyClassLoader`
      `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

    public Class parseClass(Reader reader, String fileName) throws CompilationFailedException
    Parses Groovy source read from a `Reader`.
    Overrides:
      `parseClass` in class `GroovyClassLoader`
    Parameters:
      `reader` - the reader supplying source text
      `fileName` - the logical script name
    Returns:
      the main class defined by the source
    Throws:
      `CompilationFailedException` - if compilation fails

  - ### parseClass

    public Class parseClass(String text) throws CompilationFailedException
    Parses the given text into a Java class capable of being run
    Overrides:
      `parseClass` in class `GroovyClassLoader`
    Parameters:
      `text` - the text of the script/class to parse
    Returns:
      the main class defined in the given script
    Throws:
      `CompilationFailedException`

  - ### parseClass

    public Class parseClass(String text, String fileName) throws CompilationFailedException
    Parses the given text into a Java class capable of being run
    Overrides:
      `parseClass` in class `GroovyClassLoader`
    Parameters:
      `text` - the text of the script/class to parse
      `fileName` - the file name to use as the name of the class
    Returns:
      the main class defined in the given script
    Throws:
      `CompilationFailedException`

  - ### setClassAssertionStatus

    public void setClassAssertionStatus(String className, boolean enabled)
    Overrides:
      `setClassAssertionStatus` in class `ClassLoader`

  - ### setDefaultAssertionStatus

    public void setDefaultAssertionStatus(boolean enabled)
    Overrides:
      `setDefaultAssertionStatus` in class `ClassLoader`

  - ### setPackageAssertionStatus

    public void setPackageAssertionStatus(String packageName, boolean enabled)
    Overrides:
      `setPackageAssertionStatus` in class `ClassLoader`

  - ### setResourceLoader

    public void setResourceLoader(GroovyResourceLoader resourceLoader)
    Sets the resource loader used to resolve Groovy source by script name.
    Overrides:
      `setResourceLoader` in class `GroovyClassLoader`
    Parameters:
      `resourceLoader` - the resource loader to use

  - ### setShouldRecompile

    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.
    Overrides:
      `setShouldRecompile` in class `GroovyClassLoader`
    Parameters:
      `mode` - the recompilation mode
    See Also:
      - `CompilerConfiguration`