Note that this classloader has a feature to allow loading in reverse order and for "isolation". Due to the fact that a number of methods in java.lang.ClassLoader are final (at least in java 1.4 getResources) this means that the class has to fake the given parent.
| Modifier and Type | Class and Description |
|---|---|
| private class | AntClassLoader.ResourceEnumeration
An enumeration of all resources of a given name found within the classpath of this class loader. |
| Modifier and Type | Field and Description |
|---|---|
| private static final int | BUFFER_SIZE
The size of buffers to be used in this classloader. |
| private static final ZipLong | |
| private static final FileUtils | |
| private boolean | ignoreBase
Whether or not this classloader will ignore the base classloader if it can't find a class. |
| private static final boolean | |
| private boolean | isContextLoaderSaved
Whether or not the context loader is currently saved. |
| private Hashtable | jarFiles
A hashtable of zip files opened by the classloader (File to JarFile). |
| private final Vector | loaderPackages
These are the package roots that are to be loaded by this class loader regardless of whether the parent class loader is being searched first or not. |
| private static final Class | |
| private static final Object | |
| private static final int | NUMBER_OF_STRINGS
Number of array elements in a test array of strings |
| private ClassLoader | parent
Hides java. |
| private boolean | parentFirst
Indicates whether the parent class loader should be consulted before trying to load with this class loader. |
| private final Vector | pathComponents
The components of the classpath that the classloader searches for classes. |
| private static Map | pathMap
Static map of jar file/time to manifest class-path entries |
| private Project | project
The project to which this class loader belongs. |
| private ClassLoader | savedContextLoader
The context loader saved when setting the thread's current context loader. |
| private static final ZipLong | |
| private final Vector | systemPackages
These are the package roots that are to be loaded by the parent class loader regardless of whether the parent class loader is being searched first or not. |
| Access | Constructor and Description |
|---|---|
| public | AntClassLoader(final ClassLoader
the parent for this classloader. parent, final Project The project to which this classloader is to
belong. project, final Path The classpath to use to load classes. classpath)Create an Ant ClassLoader for a given project, with a parent classloader and an initial classpath. |
| public | |
| public | AntClassLoader(final Project
The project to which this classloader is to belong.
Must not be project, final Path null.The classpath to use to load the classes. This
is combined with the system classpath in a manner
determined by the value of ${build.sysclasspath}.
May be classpath)null, in which case no path
elements are set up to start with.Creates a classloader for the given project using the classpath given. |
| public | AntClassLoader(final ClassLoader
The parent classloader to which unsatisfied loading
attempts are delegated. May be parent, final Project null,
in which case the classloader which loaded this
class is used as the parent.The project to which this classloader is to belong.
Must not be project, final Path null.the classpath to use to load the classes.
May be classpath, final boolean null, in which case no path
elements are set up to start with.If parentFirst)true, indicates that the parent
classloader should be consulted before trying to
load the a class through this loader.Creates a classloader for the given project using the classpath given. |
| public | AntClassLoader(final Project
The project to which this classloader is to belong.
Must not be project, final Path null.The classpath to use to load the classes. May be
classpath, final boolean null, in which case no path
elements are set up to start with.If parentFirst)true, indicates that the parent
classloader should be consulted before trying to
load the a class through this loader.Creates a classloader for the given project using the classpath given. |
| public | AntClassLoader(final ClassLoader
The parent classloader to which unsatisfied loading
attempts are delegated. May be parent, final boolean null,
in which case the classloader which loaded this
class is used as the parent.If parentFirst)true, indicates that the parent
classloader should be consulted before trying to
load the a class through this loader.Creates an empty class loader. |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | addLoaderPackageRoot(final String
The root of all packages to be included.
Should not be packageRoot)null.Adds a package root to the list of packages which must be loaded using this loader. |
| public void | |
| public void | addPathElement(final String
The path element to add. Must not be
pathElement)null.Adds an element to the classpath to be searched. |
| protected void | addPathFile(final File
the file which is to be added to the path for
this class loader pathComponent)Add a file to the path. |
| public void | addSystemPackageRoot(final String
The root of all packages to be included.
Should not be packageRoot)null.Adds a package root to the list of packages which must be loaded on the parent loader. |
| private static Enumeration | |
| public void | buildFinished(final BuildEvent
the buildFinished event event)Implements org. |
| public void | buildStarted(final BuildEvent
the buildStarted event event)Implements org. |
| public synchronized void | |
| public void | close()
Implements java. |
| protected Class | Returns: the Class instance created from the given datathe container from which the class data has been read
may be a directory or a jar/zip file. container, final byte[] the bytecode data for the class classData, final String the name of the class classname)Define a class given its bytes |
| protected void | definePackage(final File
the file containing the class definition. container, final String the class name of for which the package information
is to be determined. className)Define the package information associated with a class. |
| protected void | definePackage(final File
the jar file containing the manifest container, final String the name of the package being defined. packageName, final Manifest the jar's manifest manifest)Define the package information when the class comes from a jar with a manifest |
| private Class | Returns: the required Class objectThe name of the class to be loaded.
Must not be name)null.Finds a system class (which should be loaded from the same classloader as the Ant core). |
| public Class | Returns: the required Class objectThe name of the class to be loaded. Must not be
name)null.Overrides java. |
| private Class | Returns: the required Class objectThe name of the class to be loaded. Must not be
name)null.Finds a class on the given classpath. |
| protected URL | Returns: AURL object for reading the resource, or null if the
resource could not be foundThe resource name name)Overrides java. |
| protected Enumeration | Returns: an enumeration of URLs for the resourcesThe resource name to search for.
Must not be name)null.Overrides java. |
| protected Enumeration | Returns: an enumeration of URLs for the resourcesThe resource name to search for.
Must not be name, final boolean null.whether to skip searching the parent first - will be false if the method is
invoked from skipParent)getResources(String) or getNamedResources(String) and true
if the method is invoked from findResources(String).Returns an enumeration of URLs representing all the resources with the given name by searching the class loader's classpath. |
| public Class | Returns: the required Class objectThe name of the class to be loaded.
Must not be classname)null.Loads a class through this class loader even if that class is available on the parent classpath. |
| public Class | Returns: the required Class objectThe name of the class to be loaded.
Must not be classname)null.Loads a class through this class loader but defer to the parent class loader. |
| private Certificate[] | Returns: the entry's certificates or null is the container is not a jar or it has no certificates.the File from which to read the entry container, final String the entry of which the certificates are requested entry)Get the certificates for a given jar entry, if it is indeed a jar. |
| private String | Returns: the classname in filesystem format (eg java/lang/Integer.class)The class name in dot format (eg java.lang.Integer).
Must not be classname)null.Converts the class dot notation to a filesystem equivalent for searching purposes. |
| private Class | Returns: the Class object read from the stream.The stream from which the class is to be read.
Must not be stream, final String null.The name of the class in the stream.
Must not be classname, final File null.the file or directory containing the class. container)Reads a class definition from a stream. |
| public String | Returns: the classpath used for this classloader, with elements separated by the path separator for the system.Returns the classpath this classloader will consult. |
| public ClassLoader | Returns: classloaderGets the parent as has been specified in the constructor or via setParent. |
| private Manifest | Returns: the jar's manifest or null is the container is not a jar or it has no manifest.the File from which a manifest is required. container)Get the manifest from the given jar, if it is indeed a jar and it has a manifest |
| public Enumeration | Returns: possible URLs as enumerationname of the resource name)Finds all the resources with the given name. |
| public URL | Returns: a URL for reading the resource, ornull if the
resource could not be found or the caller doesn't have
adequate privileges to get the resource.The name of the resource for which a stream is required.
Must not be name)null.Overrides java. |
| public InputStream | Returns: a stream to the required resource ornull if the
resource cannot be found on the loader's classpath.The name of the resource for which a stream is required.
Must not be name)null.Overrides java. |
| public Enumeration | getResources(String
The resource name name)Overrides java. |
| private InputStream | Returns: a stream to the required resource ornull if
the resource cannot be found in the given file.the file (directory or jar) in which to search for the
resource. Must not be file, final String null.The name of the resource for which a stream is
required. Must not be resourceName)null.Returns an inputstream to a given resource in the given file which may either be a directory or a zip file. |
| protected URL | Returns: a stream to the required resource ornull if the
resource cannot be found in the given file object.The file (directory or jar) in which to search for
the resource. Must not be file, final String null.The name of the resource for which a stream
is required. Must not be resourceName)null.Returns the URL of a given resource in the given file which may either be a directory or a zip file. |
| private ClassLoader | Returns: the root classloader of AntClassLoader.Used for isolated resource searching. |
| private URL | |
| public static void | initializeClass(final Class<?>
The class to initialize.
Must not be theClass)null.
Deprecated
since 1.6.x.
Use Class.forName with initialize=true instead.
Forces initialization of a class in a JDK 1.1 compatible, albeit hacky
way.
|
| protected boolean | |
| private boolean | Returns: whether or not the parent classloader should be checked for a resource before this one is.The name of the resource to check. Must not be
resourceName)null.Tests whether or not the parent classloader should be checked for a resource before this one. |
| private static boolean | |
| private InputStream | Returns: a stream to the named resource, ornull if
the resource cannot be found.The name of the system resource to load.
Must not be name)null.Finds a system resource (which should be loaded from the parent classloader). |
| protected synchronized Class | Returns: the required Class objectThe name of the class to be loaded.
Must not be classname, final boolean null.true if all classes upon which this class
depends are to be loaded.Overrides java. |
| private InputStream | Returns: a stream to the required resource ornull if
the resource cannot be found on the loader's classpath.The name of the resource for which a stream is required.
Must not be name)null.Returns a stream to read the requested resource name from this loader. |
| protected void | |
| public void | messageLogged(final BuildEvent
the messageLogged event event)Implements org. |
| public static AntClassLoader | Returns: AntClassLoaderClassLoader parent, final Project Project project, final Path Path path, final boolean boolean parentFirst)Factory method |
| private static JarFile | Returns: Returns aJarFile instance, which is constructed based upon the Java runtime version.
Depending on the Java runtime version, the returned instance may or may not be multi-release
aware (a feature introduced in Java 9)The file representing the jar file)
|
| private static boolean | |
| public void | |
| public void | setClassPath(final Path
the search classpath consisting of directories and
jar/zip files. classpath)Set the classpath to search for classes to load. |
| public synchronized void | setIsolated(final boolean
Whether or not this classloader should run in
isolated mode. isolated)Sets whether this classloader should run in isolated mode. |
| public void | |
| public void | setParentFirst(final boolean
if true, delegate initial class search to the parent
classloader. parentFirst)Control whether class lookup is delegated to the parent loader first or after this loader. |
| public void | setProject(final Project
the project instance project)Set the project associated with this class loader |
| public void | setThreadContextLoader()
Sets the current thread's context loader to this classloader, storing the current loader value for later resetting. |
| public void | subBuildFinished(final BuildEvent
the buildFinished event event)Implements org. |
| public void | subBuildStarted(final BuildEvent
the buildStarted event event)Implements org. |
| public void | targetFinished(final BuildEvent
the targetFinished event event)Implements org. |
| public void | targetStarted(final BuildEvent
the targetStarted event event)Implements org. |
| public void | taskFinished(final BuildEvent
the taskFinished event event)Implements org. |
| public void | taskStarted(final BuildEvent
the taskStarted event event)Implements org. |
| public String | Returns: the path that this classloader has.Overrides java. String representing this loader.
|