AntClassLoader5 (Apache Ant API)
Description: declaration: package: org.apache.tools.ant.loader, class: AntClassLoader5

# Class AntClassLoader5

java.lang.Object
java.lang.ClassLoader
org.apache.tools.ant.AntClassLoader
org.apache.tools.ant.loader.AntClassLoader5

All Implemented Interfaces:
  `Closeable, AutoCloseable, EventListener, BuildListener, SubBuildListener`

public class AntClassLoader5 extends AntClassLoader
Deprecated.
since 1.9.7 Just use `AntClassLoader` itself.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AntClassLoader5(ClassLoader parent, Project project, Path classpath, boolean parentFirst)`
  Deprecated.
  Creates a classloader for the given project using the classpath given.

- ## Method Summary

  ### Methods inherited from class AntClassLoader

  `addJavaLibraries, addLoaderPackageRoot, addPathComponent, addPathElement, addPathFile, addSystemPackageRoot, buildFinished, buildStarted, cleanup, close, defineClassFromData, definePackage, definePackage, findClass, findResource, findResources, findResources, forceLoadClass, forceLoadSystemClass, getClasspath, getConfiguredParent, getNamedResources, getResource, getResourceAsStream, getResources, getResourceURL, initializeClass, isInPath, loadClass, log, messageLogged, newAntClassLoader, resetThreadContextLoader, setClassPath, setIsolated, setParent, setParentFirst, setProject, setThreadContextLoader, subBuildFinished, subBuildStarted, targetFinished, targetStarted, taskFinished, taskStarted, toString`
  Modifier and Type
  Method
  Description
  `void`
  `addJavaLibraries()`
  add any libraries that come with different java versions here
  `void`
  `addLoaderPackageRoot(String packageRoot)`
  Adds a package root to the list of packages which must be loaded using this loader.
  `void`
  `addPathComponent(File file)`
  Add a path component.
  `void`
  `addPathElement(String pathElement)`
  Adds an element to the classpath to be searched.
  `protected void`
  `addPathFile(File pathComponent)`
  Add a file to the path.
  `void`
  `addSystemPackageRoot(String packageRoot)`
  Adds a package root to the list of packages which must be loaded on the parent loader.
  `void`
  `buildFinished(BuildEvent event)`
  Cleans up any resources held by this classloader at the end of a build.
  `void`
  `buildStarted(BuildEvent event)`
  Empty implementation to satisfy the BuildListener interface.
  `void`
  `cleanup()`
  Cleans up any resources held by this classloader.
  `void`
  `close()`
  `protected Class<?>`
  `defineClassFromData(File container, byte[] classData, String classname)`
  Define a class given its bytes
  `protected void`
  `definePackage(File container, String className)`
  Define the package information associated with a class.
  `protected void`
  `definePackage(File container, String packageName, Manifest manifest)`
  Define the package information when the class comes from a jar with a manifest
  `Class<?>`
  `findClass(String name)`
  Searches for and load a class on the classpath of this class loader.
  `protected URL`
  `findResource(String name)`
  Finds the resource with the given name.
  `protected Enumeration<URL>`
  `findResources(String name)`
  Returns an enumeration of URLs representing all the resources with the given name by searching the class loader's classpath.
  `protected Enumeration<URL>`
  `findResources(String name, boolean skipParent)`
  Returns an enumeration of URLs representing all the resources with the given name by searching the class loader's classpath.
  `Class<?>`
  `forceLoadClass(String classname)`
  Loads a class through this class loader even if that class is available on the parent classpath.
  `Class<?>`
  `forceLoadSystemClass(String classname)`
  Loads a class through this class loader but defer to the parent class loader.
  `String`
  `getClasspath()`
  Returns the classpath this classloader will consult.
  `ClassLoader`
  `getConfiguredParent()`
  Gets the parent as has been specified in the constructor or via setParent.
  `Enumeration<URL>`
  `getNamedResources(String name)`
  Finds all the resources with the given name.
  `URL`
  `getResource(String name)`
  Finds the resource with the given name.
  `InputStream`
  `getResourceAsStream(String name)`
  Returns a stream to read the requested resource name.
  `Enumeration<URL>`
  `getResources(String name)`
  `protected URL`
  `getResourceURL(File file, String resourceName)`
  Returns the URL of a given resource in the given file which may either be a directory or a zip file.
  `static void`
  `initializeClass(Class<?> theClass)`
  Deprecated.
  since 1.6.x.
  `protected boolean`
  `isInPath(File component)`
  Indicate if the given file is in this loader's path
  `protected Class<?>`
  `loadClass(String classname, boolean resolve)`
  Loads a class with this class loader.
  `protected void`
  `log(String message, int priority)`
  Logs a message through the project object if one has been provided.
  `void`
  `messageLogged(BuildEvent event)`
  Empty implementation to satisfy the BuildListener interface.
  `static AntClassLoader`
  `newAntClassLoader(ClassLoader parent, Project project, Path path, boolean parentFirst)`
  Factory method
  `void`
  `resetThreadContextLoader()`
  Resets the current thread's context loader to its original value.
  `void`
  `setClassPath(Path classpath)`
  Set the classpath to search for classes to load.
  `void`
  `setIsolated(boolean isolated)`
  Sets whether this classloader should run in isolated mode.
  `void`
  `setParent(ClassLoader parent)`
  Set the parent for this class loader.
  `void`
  `setParentFirst(boolean parentFirst)`
  Control whether class lookup is delegated to the parent loader first or after this loader.
  `void`
  `setProject(Project project)`
  Set the project associated with this class loader
  `void`
  `setThreadContextLoader()`
  Sets the current thread's context loader to this classloader, storing the current loader value for later resetting.
  `void`
  `subBuildFinished(BuildEvent event)`
  Cleans up any resources held by this classloader at the end of a subbuild if it has been created for the subbuild's project instance.
  `void`
  `subBuildStarted(BuildEvent event)`
  Empty implementation to satisfy the BuildListener interface.
  `void`
  `targetFinished(BuildEvent event)`
  Empty implementation to satisfy the BuildListener interface.
  `void`
  `targetStarted(BuildEvent event)`
  Empty implementation to satisfy the BuildListener interface.
  `void`
  `taskFinished(BuildEvent event)`
  Empty implementation to satisfy the BuildListener interface.
  `void`
  `taskStarted(BuildEvent event)`
  Empty implementation to satisfy the BuildListener interface.
  `String`
  `toString()`
  Returns a `String` representing this loader.

  ### Methods inherited from class ClassLoader

  `clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### AntClassLoader5

    public AntClassLoader5(ClassLoader parent, Project project, Path classpath, boolean parentFirst)
    Deprecated.
    Creates a classloader for the given project using the classpath given.
    Parameters:
      `parent` - The parent classloader to which unsatisfied loading attempts are delegated. May be `null`, in which case the classloader which loaded this class is used as the parent.
      `project` - The project to which this classloader is to belong. Must not be `null`.
      `classpath` - the classpath to use to load the classes. May be `null`, in which case no path elements are set up to start with.
      `parentFirst` - If `true`, indicates that the parent classloader should be consulted before trying to load the a class through this loader.