Class ReflectorLoader

java.lang.Object
java.lang.ClassLoader
org.codehaus.groovy.runtime.metaclass.ReflectorLoader

@Deprecated(since="6.0.0", forRemoval=true) public class ReflectorLoader extends ClassLoader
Deprecated, for removal: This API element is subject to removal in a future version.
No production callers remain; kept only for binary compatibility.
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.

  • Constructor Details

    • ReflectorLoader

      public ReflectorLoader(ClassLoader parent)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a new ReflectorLoader with the specified parent class loader.
      Parameters:
      parent - the parent class loader (should never be null)
  • Method Details

    • findClass

      protected Class<?> findClass(String name) throws ClassNotFoundException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Tries to find a Groovy class. Uses the delegation loader to load classes when available.
      Overrides:
      findClass in class ClassLoader
      Parameters:
      name - the fully qualified name of the class to find
      Returns:
      the class if found
      Throws:
      ClassNotFoundException - if the class cannot be found
    • loadClass

      protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
      Deprecated, for removal: This API element is subject to removal in a future version.
      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.
      Overrides:
      loadClass in class ClassLoader
      Parameters:
      name - of the class to load
      resolve - is true if the class should be resolved
      Throws:
      ClassNotFoundException
      See Also:
    • defineClass

      public Class<?> defineClass(String name, byte[] bytecode, ProtectionDomain domain)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Defines a Reflector class via ClassLoader.defineClass(byte[], int, int) 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
    • getLoadedClass

      public Class<?> getLoadedClass(String name)
      Deprecated, for removal: This API element is subject to removal in a future version.
      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