Package: org.codehaus.groovy.runtime.metaclass

## [Java] Class ReflectorLoader

- org.codehaus.groovy.runtime.metaclass.ReflectorLoader

-     @Deprecated(since = "6.0.0", forRemoval = true)
      public class ReflectorLoader
      extends ClassLoader

  Reflector creation helper historically used to define Reflector subclasses.

  Deprecated since 6.0.0. Production MetaClass / call-site paths no longer construct or use this loader; the only remaining references are tests. Prefer modern reflective / method-handle dispatch. Retained for binary compatibility only; will be removed in a future major release.

  Special about this loader is that it knows the classes from the Groovy runtime. During class definition Reflector resolves to the runtime's Reflector even if a different one exists in the parent loader.

  deprecated:
    No production callers remain; kept only for binary compatibility.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `ReflectorLoader(ClassLoader parent)` Creates a new ReflectorLoader with the specified parent class loader.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public Class<?>` | `defineClass(String name, byte[] bytecode, ProtectionDomain domain)` Defines a Reflector class via ClassLoader.defineClass and caches it under `name`.
    `` | `protected Class<?>` | `findClass(String name)` Tries to find a Groovy class.
    `` | `public Class<?>` | `getLoadedClass(String name)` Retrieves a previously defined Reflector class by name from the cache.
    `` | `protected Class<?>` | `loadClass(String name, boolean resolve)` Loads a class per name.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class ClassLoader` | `clearAssertionStatus, equals, getClass, getDefinedPackage, getDefinedPackages, getName, getParent, getPlatformClassLoader, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, hashCode, isRegisteredAsParallelCapable, loadClass, notify, notifyAll, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### public ReflectorLoader(ClassLoader parent)

      Creates a new ReflectorLoader with the specified parent class loader.

      Parameters:
        `parent` - the parent class loader (should never be `null`)

  - ### Method Detail

    - #### public Class<?> defineClass(String name, byte[] bytecode, ProtectionDomain domain)

      Defines a Reflector class via ClassLoader.defineClass and caches it under `name`.

      Sets `inDefine` during definition so Reflector resolves to the runtime class.

      Parameters:
        `name` - cache key and binary name of the Reflector class
        `bytecode` - the bytecode of the Reflector class
        `domain` - the protection domain
      Returns:
        the newly defined class

    - #### protected Class<?> findClass(String name)

      Tries to find a Groovy class. Uses the delegation loader to load classes when available.

      throws:
        ClassNotFoundException if the class cannot be found
      Parameters:
        `name` - the fully qualified name of the class to find
      Returns:
        the class if found

    - #### public Class<?> getLoadedClass(String name)

      Retrieves a previously defined Reflector class by name from the cache.

      Parameters:
        `name` - the fully qualified name of the Reflector class
      Returns:
        the Reflector class if it has been defined, or `null` otherwise

    - #### protected Class<?> loadClass(String name, boolean resolve)

      Loads a class per name. Unlike a normal `loadClass` this version behaves differently during a class definition. In that case it checks if the class we want to load is Reflector and returns that class if the check is successful. If it is not during a class definition it just calls the super class version of `loadClass`.

      Parameters:
        `name` - of the class to load
        `resolve` - is `true` if the class should be resolved
      See Also:
        Reflector
        ClassLoader.loadClass