Class RecipeClassLoader

All Implemented Interfaces:
Closeable, AutoCloseable

public class RecipeClassLoader extends URLClassLoader
A classloader that provides maximum isolation for recipe implementations while delegating to the parent for OpenRewrite API types that must be shared.
  • Constructor Details

    • RecipeClassLoader

      public RecipeClassLoader(Path recipeJar, List<Path> classpath)
    • RecipeClassLoader

      public RecipeClassLoader(URL[] urls, ClassLoader parent)
  • Method Details

    • loadClass

      protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
      Overrides:
      loadClass in class ClassLoader
      Throws:
      ClassNotFoundException
    • getAdditionalParentDelegatedPackages

      protected List<String> getAdditionalParentDelegatedPackages()
      Returns:
      List of class/package prefixes to delegate to parent classloader
    • forScanning

      public static ClassLoader forScanning(Path recipeJar, List<Path> classpath)
      Create a standard ClassLoader for the recipe JAR and its dependencies. This is primarily used for scanning operations where ClassGraph needs standard parent delegation.
    • getUrls

      public static URL[] getUrls(Path recipeJar, List<Path> classpath)
      Convert paths to URL array for URLClassLoader.