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:
java.io.Closeable, java.lang.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

    Modifier and Type Method Description
    void addClasspath​(java.lang.String path)
    adds a classpath to this classloader.
    void addURL​(java.net.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.
    java.lang.Class defineClass​(java.lang.String name, byte[] b)
    open up the super class define that takes raw bytes
    java.lang.Class defineClass​(ClassNode classNode, java.lang.String file, java.lang.String newCodeBase)
    Loads the given class node returning the implementation Class.
    java.net.URL findResource​(java.lang.String name)  
    java.util.Enumeration<java.net.URL> findResources​(java.lang.String name)  
    java.lang.String generateScriptName()  
    java.lang.Class[] getLoadedClasses()
    Returns all Groovy classes loaded by this class loader.
    java.net.URL getResource​(java.lang.String name)  
    java.io.InputStream getResourceAsStream​(java.lang.String name)  
    GroovyResourceLoader getResourceLoader()  
    java.util.Enumeration<java.net.URL> getResources​(java.lang.String name)  
    long getTimeStamp()  
    java.net.URL[] getURLs()  
    java.lang.Boolean isShouldRecompile()
    gets the currently set recompilation mode.
    java.lang.Class<?> loadClass​(java.lang.String name)  
    java.lang.Class loadClass​(java.lang.String name, boolean lookupScriptFiles, boolean preferClassOverScript)
    loads a class from a file or a parent classloader.
    java.lang.Class loadClass​(java.lang.String name, boolean lookupScriptFiles, boolean preferClassOverScript, boolean resolve)
    loads a class from a file or a parent classloader.
    java.lang.Class parseClass​(GroovyCodeSource codeSource)  
    java.lang.Class parseClass​(GroovyCodeSource codeSource, boolean shouldCache)
    Parses the given code source into a Java class.
    java.lang.Class parseClass​(java.io.File file)
    Parses the given file into a Java class capable of being run
    java.lang.Class parseClass​(java.io.InputStream in, java.lang.String fileName)
    Deprecated.
    java.lang.Class parseClass​(java.io.Reader reader, java.lang.String fileName)  
    java.lang.Class parseClass​(java.lang.String text)
    Parses the given text into a Java class capable of being run
    java.lang.Class parseClass​(java.lang.String text, java.lang.String fileName)
    Parses the given text into a Java class capable of being run
    void setClassAssertionStatus​(java.lang.String className, boolean enabled)  
    void setDefaultAssertionStatus​(boolean enabled)  
    void setPackageAssertionStatus​(java.lang.String packageName, boolean enabled)  
    void setResourceLoader​(GroovyResourceLoader resourceLoader)  
    void setShouldRecompile​(java.lang.Boolean mode)
    sets if the recompilation should be enable.

    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

  • Method Details

    • addClasspath

      public void addClasspath​(java.lang.String path)
      Description copied from class: GroovyClassLoader
      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)
    • 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.

      Overrides:
      clearCache in class GroovyClassLoader
      See Also:
      GroovyClassLoader.getClassCacheEntry(String), GroovyClassLoader.setClassCacheEntry(Class), GroovyClassLoader.removeClassCacheEntry(String)
    • findResource

      public java.net.URL findResource​(java.lang.String name)
      Overrides:
      findResource in class java.net.URLClassLoader
    • findResources

      public java.util.Enumeration<java.net.URL> findResources​(java.lang.String name) throws java.io.IOException
      Overrides:
      findResources in class java.net.URLClassLoader
      Throws:
      java.io.IOException
    • getLoadedClasses

      public java.lang.Class[] getLoadedClasses()
      Description copied from class: GroovyClassLoader

      Returns all Groovy classes loaded by this class loader.

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

      public java.net.URL getResource​(java.lang.String name)
      Overrides:
      getResource in class java.lang.ClassLoader
    • getResourceAsStream

      public java.io.InputStream getResourceAsStream​(java.lang.String name)
      Overrides:
      getResourceAsStream in class java.net.URLClassLoader
    • getResourceLoader

      public GroovyResourceLoader getResourceLoader()
      Overrides:
      getResourceLoader in class GroovyClassLoader
    • getURLs

      public java.net.URL[] getURLs()
      Overrides:
      getURLs in class java.net.URLClassLoader
    • loadClass

      public java.lang.Class loadClass​(java.lang.String name, boolean lookupScriptFiles, boolean preferClassOverScript, boolean resolve) throws java.lang.ClassNotFoundException, CompilationFailedException
      Description copied from class: GroovyClassLoader
      loads a class from a file or a parent classloader.
      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:
      java.lang.ClassNotFoundException - if the class could not be found
      CompilationFailedException - if the source file could not be compiled
    • parseClass

      public java.lang.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 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
    • setResourceLoader

      public void setResourceLoader​(GroovyResourceLoader resourceLoader)
      Overrides:
      setResourceLoader in class GroovyClassLoader
    • addURL

      public void addURL​(java.net.URL url)
      Description copied from class: GroovyClassLoader
      adds a URL to the classloader.
      Overrides:
      addURL in class GroovyClassLoader
      Parameters:
      url - the new classpath element
    • defineClass

      public java.lang.Class defineClass​(ClassNode classNode, java.lang.String file, java.lang.String newCodeBase)
      Description copied from class: GroovyClassLoader
      Loads the given class node returning the implementation Class.

      WARNING: this compilation is not synchronized

      Overrides:
      defineClass in class GroovyClassLoader
      Returns:
      a class
    • parseClass

      public java.lang.Class parseClass​(java.io.File file) throws CompilationFailedException, java.io.IOException
      Description copied from class: GroovyClassLoader
      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
      java.io.IOException
    • parseClass

      public java.lang.Class parseClass​(java.lang.String text, java.lang.String fileName) throws CompilationFailedException
      Description copied from class: GroovyClassLoader
      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
    • parseClass

      public java.lang.Class parseClass​(java.lang.String text) throws CompilationFailedException
      Description copied from class: GroovyClassLoader
      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
    • generateScriptName

      public java.lang.String generateScriptName()
      Overrides:
      generateScriptName in class GroovyClassLoader
    • parseClass

      public java.lang.Class parseClass​(java.io.Reader reader, java.lang.String fileName) throws CompilationFailedException
      Overrides:
      parseClass in class GroovyClassLoader
      Throws:
      CompilationFailedException
    • parseClass

      @Deprecated public java.lang.Class parseClass​(java.io.InputStream in, java.lang.String fileName) throws CompilationFailedException
      Deprecated.
      Overrides:
      parseClass in class GroovyClassLoader
      Throws:
      CompilationFailedException
    • parseClass

      public java.lang.Class parseClass​(GroovyCodeSource codeSource) throws CompilationFailedException
      Overrides:
      parseClass in class GroovyClassLoader
      Throws:
      CompilationFailedException
    • defineClass

      public java.lang.Class defineClass​(java.lang.String name, byte[] b)
      Description copied from class: GroovyClassLoader
      open up the super class define that takes raw bytes
      Overrides:
      defineClass in class GroovyClassLoader
    • loadClass

      public java.lang.Class loadClass​(java.lang.String name, boolean lookupScriptFiles, boolean preferClassOverScript) throws java.lang.ClassNotFoundException, CompilationFailedException
      Description copied from class: GroovyClassLoader
      loads 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:
      loadClass in class GroovyClassLoader
      Throws:
      CompilationFailedException - if compilation was not successful
      java.lang.ClassNotFoundException
    • setShouldRecompile

      public void setShouldRecompile​(java.lang.Boolean mode)
      Description copied from class: GroovyClassLoader
      sets 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:
      setShouldRecompile in class GroovyClassLoader
      Parameters:
      mode - the recompilation mode
      See Also:
      CompilerConfiguration
    • isShouldRecompile

      public java.lang.Boolean 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 class GroovyClassLoader
      Returns:
      the recompilation mode
    • loadClass

      public java.lang.Class<?> loadClass​(java.lang.String name) throws java.lang.ClassNotFoundException
      Overrides:
      loadClass in class GroovyClassLoader
      Throws:
      java.lang.ClassNotFoundException
    • getResources

      public java.util.Enumeration<java.net.URL> getResources​(java.lang.String name) throws java.io.IOException
      Overrides:
      getResources in class java.lang.ClassLoader
      Throws:
      java.io.IOException
    • setDefaultAssertionStatus

      public void setDefaultAssertionStatus​(boolean enabled)
      Overrides:
      setDefaultAssertionStatus in class java.lang.ClassLoader
    • setPackageAssertionStatus

      public void setPackageAssertionStatus​(java.lang.String packageName, boolean enabled)
      Overrides:
      setPackageAssertionStatus in class java.lang.ClassLoader
    • setClassAssertionStatus

      public void setClassAssertionStatus​(java.lang.String className, boolean enabled)
      Overrides:
      setClassAssertionStatus in class java.lang.ClassLoader
    • clearAssertionStatus

      public void clearAssertionStatus()
      Overrides:
      clearAssertionStatus in class java.lang.ClassLoader
    • close

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

      public long getTimeStamp()