Class FilteredClassLoader

java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
org.springframework.boot.test.context.FilteredClassLoader
All Implemented Interfaces:
Closeable, AutoCloseable, org.springframework.core.SmartClassLoader

public class FilteredClassLoader extends URLClassLoader implements org.springframework.core.SmartClassLoader
Test URLClassLoader that can filter the classes and resources it can load.
Since:
2.0.0
  • Constructor Details

    • FilteredClassLoader

      public FilteredClassLoader(Class<?>... hiddenClasses)
      Create a FilteredClassLoader that hides the given classes.
      Parameters:
      hiddenClasses - the classes to hide
    • FilteredClassLoader

      public FilteredClassLoader(String... hiddenPackages)
      Create a FilteredClassLoader that hides classes from the given packages.
      Parameters:
      hiddenPackages - the packages to hide
    • FilteredClassLoader

      public FilteredClassLoader(org.springframework.core.io.ClassPathResource... hiddenResources)
      Create a FilteredClassLoader that hides resources from the given classpath resources.
      Parameters:
      hiddenResources - the resources to hide
      Since:
      2.1.0
    • FilteredClassLoader

      @SafeVarargs public FilteredClassLoader(Predicate<String>... filters)
      Create a FilteredClassLoader that filters based on the given predicate.
      Parameters:
      filters - a set of filters to determine when a class name or resource should be hidden. A result of true indicates a filtered class or resource. The input of the predicate can either be the binary name of a class or a resource name.
  • Method Details