URLClassLoader - JRE Emulation | JRE Emulation
public class

URLClassLoader

extends SecureClassLoader
java.lang.Object
   ↳ java.lang.ClassLoader
     ↳ java.security.SecureClassLoader
       ↳ java.net.URLClassLoader

Class Overview

This class loader is responsible for loading classes and resources from a list of URLs which can refer to either directories or JAR files. Classes loaded by this URLClassLoader are granted permission to access the URLs contained in the URL search list. This version has been simplified, since iOS is prohibited from dynamically loading classes from bundles other than the main app bundle. No code was shared, just its public API.

Summary

Public Constructors
URLClassLoader(URL[] urls)
Constructs a new URLClassLoader instance.
URLClassLoader(URL[] urls, ClassLoader parent)
Constructs a new URLClassLoader instance.
URLClassLoader(URL[] searchUrls, ClassLoader parent, URLStreamHandlerFactory factory)
Constructs a new URLClassLoader instance.
Public Methods
void close()
Closes this classLoader, so it can't be used to load new classes or resources.
Enumeration<URL> findResources(String name)
Returns all known URLs which point to the specified resource.
URL[] getURLs()
Returns the search list of this URLClassLoader.
static URLClassLoader newInstance(URL[] urls)
Returns a new URLClassLoader instance for the given URLs and the system ClassLoader as its parent.
static URLClassLoader newInstance(URL[] urls, ClassLoader parentCl)
Returns a new URLClassLoader instance for the given URLs and the specified ClassLoader as its parent.
Protected Methods
void addURL(URL url)
Adds the specified URL to the search list.
Inherited Methods
[Expand]
From class java.security.SecureClassLoader
From class java.lang.ClassLoader
From class java.lang.Object

Public Constructors

public URLClassLoader (URL[] urls)

Constructs a new URLClassLoader instance. The newly created instance will have the system ClassLoader as its parent. URLs that end with "/" are assumed to be directories, otherwise they are assumed to be JAR files.

Parameters
urls the list of URLs where a specific class or file could be found.

public URLClassLoader (URL[] urls, ClassLoader parent)

Constructs a new URLClassLoader instance. The newly created instance will have the system ClassLoader as its parent. URLs that end with "/" are assumed to be directories, otherwise they are assumed to be JAR files.

Parameters
urls the list of URLs where a specific class or file could be found.
parent the class loader to assign as this loader's parent.

public URLClassLoader (URL[] searchUrls, ClassLoader parent, URLStreamHandlerFactory factory)

Constructs a new URLClassLoader instance. The newly created instance will have the specified ClassLoader as its parent and use the specified factory to create stream handlers. URLs that end with "/" are assumed to be directories, otherwise they are assumed to be JAR files.

Parameters
searchUrls the list of URLs where a specific class or file could be found.
parent the ClassLoader to assign as this loader's parent.
factory the factory that will be used to create protocol-specific stream handlers.

Public Methods

public void close ()

Closes this classLoader, so it can't be used to load new classes or resources.

Throws
IOException

public Enumeration<URL> findResources (String name)

Returns all known URLs which point to the specified resource.

Parameters
name the name of the requested resource.
Returns
  • the enumeration of URLs which point to the specified resource.
Throws
IOException if an I/O error occurs while attempting to connect.

public URL[] getURLs ()

Returns the search list of this URLClassLoader.

Returns
  • the list of all known URLs of this instance.

public static URLClassLoader newInstance (URL[] urls)

Returns a new URLClassLoader instance for the given URLs and the system ClassLoader as its parent.

Parameters
urls the list of URLs that is passed to the new URLClassLoader.
Returns
  • the created URLClassLoader instance.

public static URLClassLoader newInstance (URL[] urls, ClassLoader parentCl)

Returns a new URLClassLoader instance for the given URLs and the specified ClassLoader as its parent.

Parameters
urls the list of URLs that is passed to the new URLClassLoader.
parentCl the parent class loader that is passed to the new URLClassLoader.
Returns
  • the created URLClassLoader instance.

Protected Methods

protected void addURL (URL url)

Adds the specified URL to the search list.

Parameters
url the URL which is to add.