Top Description Fields Constructors Methods
org.aspectj.util

public Class UtilClassLoader

extends URLClassLoader
Class Inheritance
Imports
java.io.ByteArrayOutputStream, .File, .FileInputStream, .IOException, .InputStream, java.net.URL, .URLClassLoader, java.util.ArrayList, .Arrays, .Collections, .List

Load classes as File from File[] dirs or URL[] jars.

Field Summary

Modifier and TypeField and Description
pack-priv List<File>
dirs

seek classes in dirs first

private URL[]
urlsForDebugString

save URL[] only for toString

Constructor Summary

AccessConstructor and Description
public
UtilClassLoader(URL[] urls, File[] dirs)

Method Summary

Modifier and TypeMethod and Description
private byte[]
public URL
getResource(String
The resource name
name
)

Overrides java.lang.ClassLoader.getResource.

Finds the resource with the given name.
public InputStream
getResourceAsStream(String
The resource name
name
)

Overrides java.net.URLClassLoader.getResourceAsStream.

Returns an input stream for reading the specified resource.
public synchronized Class<?>
loadClass(String
The binary name of the class
name
,
boolean
If true then resolve the class
resolve
)

Overrides java.lang.ClassLoader.loadClass.

Loads the class with the specified binary name.
private byte[]

Returns:

null if class not found or byte[] of class otherwise
readClass
(String className)

public String

Returns:

String with debug info: urls and classes used
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.net.URLClassLoader:
addURLclosedefinePackagefindClassfindResourcefindResourcesgetPermissionsgetURLsnewInstancenewInstance

Field Detail

dirsback to summary
pack-priv List<File> dirs

seek classes in dirs first

urlsForDebugStringback to summary
private URL[] urlsForDebugString

save URL[] only for toString

Constructor Detail

UtilClassLoaderback to summary
public UtilClassLoader(URL[] urls, File[] dirs)

Method Detail

getClassDataback to summary
private byte[] getClassData(File f)
getResourceback to summary
public URL getResource(String name)

Overrides java.lang.ClassLoader.getResource.

Doc from java.lang.ClassLoader.getResource.

Finds the resource with the given name. A resource is some data (images, audio, text, etc) that can be accessed by class code in a way that is independent of the location of the code.

The name of a resource is a '/'-separated path name that identifies the resource.

Resources in named modules are subject to the encapsulation rules specified by Module.getResourceAsStream. Additionally, and except for the special case where the resource has a name ending with ".class", this method will only find resources in packages of named modules when the package is opened unconditionally (even if the caller of this method is in the same module as the resource).

Parameters
name:String

The resource name

Returns:URL

URL object for reading the resource; null if the resource could not be found, a URL could not be constructed to locate the resource, the resource is in a package that is not opened unconditionally, or access to the resource is denied by the security manager.

getResourceAsStreamback to summary
public InputStream getResourceAsStream(String name)

Overrides java.net.URLClassLoader.getResourceAsStream.

Doc from java.net.URLClassLoader.getResourceAsStream.

Returns an input stream for reading the specified resource. If this loader is closed, then any resources opened by this method will be closed.

The search order is described in the documentation for getResource(String).

Parameters
name:String

The resource name

Returns:InputStream

An input stream for reading the resource, or null if the resource could not be found

loadClassback to summary
public synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException

Overrides java.lang.ClassLoader.loadClass.

Doc from java.lang.ClassLoader.loadClass.

Loads the class with the specified binary name. The default implementation of this method searches for classes in the following order:

  1. Invoke findLoadedClass(String) to check if the class has already been loaded.

  2. Invoke the loadClass method on the parent class loader. If the parent is null the class loader built into the virtual machine is used, instead.

  3. Invoke the findClass(String) method to find the class.

If the class was found using the above steps, and the resolve flag is true, this method will then invoke the resolveClass(Class) method on the resulting Class object.

Subclasses of ClassLoader are encouraged to override findClass(String), rather than this method.

Unless overridden, this method synchronizes on the result of getClassLoadingLock method during the entire class loading process.

Parameters
name:String

The binary name of the class

resolve:boolean

If true then resolve the class

Returns:Class<?>

The resulting Class object

Exceptions
ClassNotFoundException:
If the class could not be found
readClassback to summary
private byte[] readClass(String className) throws ClassNotFoundException
Returns:byte[]

null if class not found or byte[] of class otherwise

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

String with debug info: urls and classes used