Class DynamicURLClassLoader

    • Constructor Detail

      • DynamicURLClassLoader

        protected DynamicURLClassLoader​(ClassLoader parent,
                                        URL... urls)
        Constructs a new ClassPathClassLoader for the given URLs. The URLs will be searched in the order specified for classes and resources after first searching in the specified parent class loader. Any URL that ends with a '/' is assumed to refer to a directory. Otherwise, the URL is assumed to refer to a JAR file which will be downloaded and opened as needed.

        If there is a security manager, this method first calls the security manager's checkCreateClassLoader method to ensure creation of a class loader is allowed.

        Parameters:
        parent - the parent class loader for delegation
        urls - the URLs from which to load classes and resources
        Throws:
        SecurityException - if a security manager exists and its checkCreateClassLoader method doesn't allow creation of a class loader.
        See Also:
        SecurityManager.checkCreateClassLoader()
    • Method Detail

      • addURL

        public void addURL​(URL url)
        Appends the specified URL to the list of URLs to search for classes and resources.
        Overrides:
        addURL in class URLClassLoader
        Parameters:
        url - the URL to be added to the search path of URLs
      • addURLs

        public void addURLs​(URL... urls)
        Appends the specified URL to the list of URLs to search for classes and resources.
        Parameters:
        urls - the URLs to be added to the search path of URLs
      • newInstance

        @Pure
        public static DynamicURLClassLoader newInstance​(ClassLoader parent,
                                                        URL... urls)
        Creates a new instance of DynamicURLClassLoader for the specified URLs and parent class loader. If a security manager is installed, the loadClass method of the URLClassLoader returned by this method will invoke the SecurityManager.checkPackageAccess method before loading the class.
        Parameters:
        parent - the parent class loader for delegation
        urls - the URLs to search for classes and resources
        Returns:
        the resulting class loader