Class ClassLoaderUtils

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static java.lang.management.ClassLoadingMXBean classLoadingMXBean  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      protected static java.lang.Class<?> doLoadClass​(java.lang.ClassLoader classLoader, java.lang.String className)  
      static java.util.Set<java.net.URL> findAllClassPathURLs​(java.lang.ClassLoader classLoader)  
      static java.lang.Class<?> findLoadedClass​(java.lang.ClassLoader classLoader, java.lang.String className)
      Find Loaded Class under specified inheritable ClassLoader
      static java.util.Set<java.lang.Class<?>> findLoadedClasses​(java.lang.ClassLoader classLoader, java.lang.Iterable<java.lang.String> classNames)
      Find Loaded Class under specified inheritable ClassLoader and class names
      static java.util.Set<java.lang.Class<?>> findLoadedClasses​(java.lang.ClassLoader classLoader, java.lang.String... classNames)
      Find Loaded Class under specified inheritable ClassLoader and class names
      static java.util.Set<java.lang.Class<?>> findLoadedClassesInClassPath​(java.lang.ClassLoader classLoader)
      Find loaded classes Set in class path
      static java.util.Set<java.lang.Class<?>> findLoadedClassesInClassPath​(java.lang.ClassLoader classLoader, java.lang.String classPath)
      Find loaded classes Set in class path
      static java.util.Set<java.lang.Class<?>> findLoadedClassesInClassPaths​(java.lang.ClassLoader classLoader, java.util.Set<java.lang.String> classPaths)
      Find loaded classes Set in class paths Set
      static java.net.URLClassLoader findURLClassLoader​(java.lang.ClassLoader classLoader)  
      static java.util.Set<java.lang.Class<?>> getAllLoadedClasses​(java.lang.ClassLoader classLoader)
      Get all loaded classes Set under specified inheritable ClassLoader
      static java.util.Map<java.lang.ClassLoader,​java.util.Set<java.lang.Class<?>>> getAllLoadedClassesMap​(java.lang.ClassLoader classLoader)
      Get all loaded classes Map under specified inheritable ClassLoader , ClassLoader as key , its loaded classes Set as value.
      static java.lang.ClassLoader getCallerClassLoader()
      Return the ClassLoader from the caller class
      static java.lang.ClassLoader getClassLoader​(java.lang.Class<?> loadedClass)
      Get the ClassLoader from the loaded class if present.
      static java.net.URL getClassResource​(java.lang.Class<?> type)
      Get the Class resource URL under specified Class
      static java.net.URL getClassResource​(java.lang.ClassLoader classLoader, java.lang.Class<?> type)
      Get the Class resource URL under specified Class
      static java.net.URL getClassResource​(java.lang.ClassLoader classLoader, java.lang.String className)
      Get the Class resource URL under specified Class name
      static java.lang.ClassLoader getDefaultClassLoader()
      Get the default the ClassLoader to use.
      static java.util.Set<java.lang.ClassLoader> getInheritableClassLoaders​(java.lang.ClassLoader classLoader)
      Get all Inheritable ClassLoaders Set (including ClassLoader argument)
      static int getLoadedClassCount()
      Returns the number of classes that are currently loaded in the Java virtual machine.
      static java.util.Set<java.lang.Class<?>> getLoadedClasses​(java.lang.ClassLoader classLoader)
      Get loaded classes Set under specified ClassLoader( not all inheritable ClassLoaders)
      static java.net.URL getResource​(java.lang.ClassLoader classLoader, ClassLoaderUtils.ResourceType resourceType, java.lang.String resourceName)
      Get the resource URL under specified resource name and type
      static java.net.URL getResource​(java.lang.ClassLoader classLoader, java.lang.String resourceName)
      Get the resource URL under specified resource name
      static java.net.URL getResource​(java.lang.String resourceName)
      Get the resource URL under specified resource name
      static java.lang.String getResourceAsString​(java.lang.ClassLoader classLoader, java.lang.String resourceName)
      Get the content of the specified resource as a String.
      static java.lang.String getResourceAsString​(java.lang.String resourceName)
      Get the content of the specified resource as a String.
      static java.util.Set<java.net.URL> getResources​(java.lang.ClassLoader classLoader, ClassLoaderUtils.ResourceType resourceType, java.lang.String resourceName)
      Get the resource URLs Set under specified resource name and type
      static java.util.Set<java.net.URL> getResources​(java.lang.ClassLoader classLoader, java.lang.String resourceName)
      Get the resource URLs list under specified resource name
      static long getTotalLoadedClassCount()
      Returns the total number of classes that have been loaded since the Java virtual machine has started execution.
      static long getUnloadedClassCount()
      Returns the total number of classes unloaded since the Java virtual machine has started execution.
      static boolean isLoadedClass​(java.lang.ClassLoader classLoader, java.lang.Class<?> type)
      Check specified Class is loaded on specified inheritable ClassLoader
      static boolean isLoadedClass​(java.lang.ClassLoader classLoader, java.lang.String className)
      Check specified class name is loaded on specified inheritable ClassLoader
      static boolean isPresent​(java.lang.String className)
      Test the specified class name is present in the default ClassLoader
      static boolean isPresent​(java.lang.String className, java.lang.ClassLoader classLoader)
      Test the specified class name is present in the ClassLoader
      static boolean isVerbose()
      Tests if the verbose output for the class loading system is enabled.
      static java.lang.Class<?> loadClass​(java.lang.ClassLoader classLoader, java.lang.String className)
      Loaded specified class name under ClassLoader
      static java.lang.Class<?> loadClass​(java.lang.ClassLoader classLoader, java.lang.String className, boolean cached)
      Loaded specified class name under ClassLoader
      static java.net.URLClassLoader newURLClassLoader​(java.lang.Iterable<java.net.URL> urls)
      Create a new instance of URLClassLoader
      static java.net.URLClassLoader newURLClassLoader​(java.lang.Iterable<java.net.URL> urls, java.lang.ClassLoader classLoader)
      Create a new instance of URLClassLoader
      static java.net.URLClassLoader newURLClassLoader​(java.net.URL[] urls)
      Create a new instance of URLClassLoader
      static java.net.URLClassLoader newURLClassLoader​(java.net.URL[] urls, boolean initializedLoaders)
      Create a new instance of URLClassLoader
      static java.net.URLClassLoader newURLClassLoader​(java.net.URL[] urls, java.lang.ClassLoader parent)
      Create a new instance of URLClassLoader
      static java.net.URLClassLoader newURLClassLoader​(java.net.URL[] urls, java.lang.ClassLoader parent, boolean initializedLoaders)
      Create a new instance of URLClassLoader
      static boolean removeClassPathURL​(java.lang.ClassLoader classLoader, java.net.URL url)  
      static java.lang.Class<?> resolveClass​(java.lang.String className)
      Resolve the Class by the specified name in the default ClassLoader
      static java.lang.Class<?> resolveClass​(java.lang.String className, java.lang.ClassLoader classLoader)
      Resolve the Class by the specified name and ClassLoader
      static java.lang.Class<?> resolveClass​(java.lang.String className, java.lang.ClassLoader classLoader, boolean cached)
      Resolve the Class by the specified name and ClassLoader
      static java.net.URLClassLoader resolveURLClassLoader​(java.lang.ClassLoader classLoader)
      Try to find the instance of URLClassLoader from the specified ClassLoader, if it can't be found, it will try to find all the URL of class-paths from the specified ClassLoader, and then new a instance of URLClassLoader upon those urls.
      static void setVerbose​(boolean value)
      Enables or disables the verbose output for the class loading system.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • classLoadingMXBean

        protected static final java.lang.management.ClassLoadingMXBean classLoadingMXBean
    • Method Detail

      • getLoadedClassCount

        public static int getLoadedClassCount()
        Returns the number of classes that are currently loaded in the Java virtual machine.
        Returns:
        the number of currently loaded classes.
      • getUnloadedClassCount

        public static long getUnloadedClassCount()
        Returns the total number of classes unloaded since the Java virtual machine has started execution.
        Returns:
        the total number of unloaded classes.
      • getTotalLoadedClassCount

        public static long getTotalLoadedClassCount()
        Returns the total number of classes that have been loaded since the Java virtual machine has started execution.
        Returns:
        the total number of classes loaded.
      • isVerbose

        public static boolean isVerbose()
        Tests if the verbose output for the class loading system is enabled.
        Returns:
        true if the verbose output for the class loading system is enabled; false otherwise.
      • setVerbose

        public static void setVerbose​(boolean value)
        Enables or disables the verbose output for the class loading system. The verbose output information and the output stream to which the verbose information is emitted are implementation dependent. Typically, a Java virtual machine implementation prints a message each time a class file is loaded.

        This method can be called by multiple threads concurrently. Each invocation of this method enables or disables the verbose output globally.

        Parameters:
        value - true to enable the verbose output; false to disable.
        Throws:
        java.lang.SecurityException - if a security manager exists and the caller does not have ManagementPermission("control").
      • getDefaultClassLoader

        @Nullable
        public static java.lang.ClassLoader getDefaultClassLoader()
        Get the default the ClassLoader to use.
        Returns:
        the ClassLoader (only null if even the system ClassLoader isn't accessible)
        See Also:
        Thread.getContextClassLoader(), Class.getClassLoader(), ClassLoader.getSystemClassLoader(), ReflectionUtils.getCallerClass()
      • getClassLoader

        @Nullable
        public static java.lang.ClassLoader getClassLoader​(@Nullable
                                                           java.lang.Class<?> loadedClass)
        Get the ClassLoader from the loaded class if present.
        Parameters:
        loadedClass - the optional class was loaded by some ClassLoader
        Returns:
        the ClassLoader (only null if even the system ClassLoader isn't accessible)
        See Also:
        getDefaultClassLoader()
      • getCallerClassLoader

        @Nullable
        public static java.lang.ClassLoader getCallerClassLoader()
        Return the ClassLoader from the caller class
        Returns:
        the ClassLoader (only null if the caller class was absent
        See Also:
        ReflectionUtils.getCallerClass()
      • findLoadedClasses

        public static java.util.Set<java.lang.Class<?>> findLoadedClasses​(@Nullable
                                                                          java.lang.ClassLoader classLoader,
                                                                          java.lang.String... classNames)
        Find Loaded Class under specified inheritable ClassLoader and class names
        Parameters:
        classLoader - ClassLoader
        classNames - class names
        Returns:
        Class if loaded, or null
      • findLoadedClasses

        public static java.util.Set<java.lang.Class<?>> findLoadedClasses​(@Nullable
                                                                          java.lang.ClassLoader classLoader,
                                                                          java.lang.Iterable<java.lang.String> classNames)
        Find Loaded Class under specified inheritable ClassLoader and class names
        Parameters:
        classLoader - ClassLoader
        classNames - class names set
        Returns:
        Class if loaded, or null
      • isLoadedClass

        public static boolean isLoadedClass​(@Nullable
                                            java.lang.ClassLoader classLoader,
                                            java.lang.Class<?> type)
        Check specified Class is loaded on specified inheritable ClassLoader
        Parameters:
        classLoader - ClassLoader
        type - Class
        Returns:
        If Loaded , return true , or false
      • isLoadedClass

        public static boolean isLoadedClass​(@Nullable
                                            java.lang.ClassLoader classLoader,
                                            java.lang.String className)
        Check specified class name is loaded on specified inheritable ClassLoader
        Parameters:
        classLoader - ClassLoader
        className - class name
        Returns:
        If Loaded , return true , or false
      • findLoadedClass

        public static java.lang.Class<?> findLoadedClass​(@Nullable
                                                         java.lang.ClassLoader classLoader,
                                                         java.lang.String className)
        Find Loaded Class under specified inheritable ClassLoader
        Parameters:
        classLoader - ClassLoader
        className - class name
        Returns:
        Class if loaded , or null
      • loadClass

        @Nullable
        public static java.lang.Class<?> loadClass​(@Nullable
                                                   java.lang.ClassLoader classLoader,
                                                   @Nullable
                                                   java.lang.String className)
        Loaded specified class name under ClassLoader
        Parameters:
        classLoader - ClassLoader
        className - the name of Class
        Returns:
        Class if can be loaded
      • loadClass

        public static java.lang.Class<?> loadClass​(@Nullable
                                                   java.lang.ClassLoader classLoader,
                                                   @Nullable
                                                   java.lang.String className,
                                                   boolean cached)
        Loaded specified class name under ClassLoader
        Parameters:
        classLoader - ClassLoader
        className - the name of Class
        cached - the resolved class is required to be cached or not
        Returns:
        Class if can be loaded
      • doLoadClass

        protected static java.lang.Class<?> doLoadClass​(java.lang.ClassLoader classLoader,
                                                        java.lang.String className)
      • getResources

        public static java.util.Set<java.net.URL> getResources​(@Nullable
                                                               java.lang.ClassLoader classLoader,
                                                               ClassLoaderUtils.ResourceType resourceType,
                                                               java.lang.String resourceName)
                                                        throws java.lang.NullPointerException,
                                                               java.io.IOException
        Get the resource URLs Set under specified resource name and type
        Parameters:
        classLoader - ClassLoader
        resourceType - ClassLoaderUtils.ResourceType Enum
        resourceName - resource name ,e.g :
        • Resource Name :"/com/abc/def.log"
        • Class Name : "java.lang.String"
        Returns:
        the resource URL under specified resource name and type
        Throws:
        java.lang.NullPointerException - If any argument is null
        java.io.IOException
      • getResources

        public static java.util.Set<java.net.URL> getResources​(@Nullable
                                                               java.lang.ClassLoader classLoader,
                                                               java.lang.String resourceName)
                                                        throws java.lang.NullPointerException,
                                                               java.io.IOException
        Get the resource URLs list under specified resource name
        Parameters:
        classLoader - ClassLoader
        resourceName - resource name ,e.g :
        • Resource Name :"/com/abc/def.log"
        • Class Name : "java.lang.String"
        Returns:
        the resource URL under specified resource name and type
        Throws:
        java.lang.NullPointerException - If any argument is null
        java.io.IOException
      • getResource

        public static java.net.URL getResource​(java.lang.String resourceName)
                                        throws java.lang.NullPointerException
        Get the resource URL under specified resource name
        Parameters:
        resourceName - resource name ,e.g :
        • Resource Name :"/com/abc/def.log"
        • Class Name : "java.lang.String"
        Returns:
        the resource URL under specified resource name and type
        Throws:
        java.lang.NullPointerException - If any argument is null
      • getResource

        public static java.net.URL getResource​(@Nullable
                                               java.lang.ClassLoader classLoader,
                                               java.lang.String resourceName)
                                        throws java.lang.NullPointerException
        Get the resource URL under specified resource name
        Parameters:
        classLoader - ClassLoader
        resourceName - resource name ,e.g :
        • Resource Name :"/com/abc/def.log"
        • Class Name : "java.lang.String"
        Returns:
        the resource URL under specified resource name and type
        Throws:
        java.lang.NullPointerException - If any argument is null
      • getResource

        public static java.net.URL getResource​(@Nullable
                                               java.lang.ClassLoader classLoader,
                                               ClassLoaderUtils.ResourceType resourceType,
                                               java.lang.String resourceName)
                                        throws java.lang.NullPointerException
        Get the resource URL under specified resource name and type
        Parameters:
        classLoader - ClassLoader
        resourceType - ClassLoaderUtils.ResourceType Enum
        resourceName - resource name ,e.g :
        • Resource Name :"/com/abc/def.log"
        • Class Name : "java.lang.String"
        Returns:
        the resource URL under specified resource name and type
        Throws:
        java.lang.NullPointerException - If any argument is null
      • getResourceAsString

        public static java.lang.String getResourceAsString​(java.lang.String resourceName)
                                                    throws java.lang.NullPointerException,
                                                           java.io.IOException
        Get the content of the specified resource as a String.
        Parameters:
        resourceName - the name of the resource to load
        Returns:
        the content of the resource as a String
        Throws:
        java.lang.NullPointerException - if the resourceName is null
        java.io.IOException - if an I/O error occurs while reading the resource
      • getResourceAsString

        public static java.lang.String getResourceAsString​(@Nullable
                                                           java.lang.ClassLoader classLoader,
                                                           java.lang.String resourceName)
                                                    throws java.lang.NullPointerException,
                                                           java.io.IOException
        Get the content of the specified resource as a String.
        Parameters:
        classLoader - the ClassLoader to use for loading the resource, may be null
        resourceName - the name of the resource to load
        Returns:
        the content of the resource as a String
        Throws:
        java.lang.NullPointerException - if the resourceName is null
        java.io.IOException - if an I/O error occurs while reading the resource
      • getClassResource

        public static java.net.URL getClassResource​(@Nullable
                                                    java.lang.ClassLoader classLoader,
                                                    java.lang.String className)
        Get the Class resource URL under specified Class name
        Parameters:
        classLoader - ClassLoader
        className - class name
        Returns:
        the resource URL under specified resource name and type
        Throws:
        java.lang.NullPointerException - If any argument is null
      • getClassResource

        public static java.net.URL getClassResource​(java.lang.Class<?> type)
        Get the Class resource URL under specified Class
        Parameters:
        type - type
        Returns:
        the resource URL under specified resource name and type
        Throws:
        java.lang.NullPointerException - If any argument is null
      • getClassResource

        public static java.net.URL getClassResource​(@Nullable
                                                    java.lang.ClassLoader classLoader,
                                                    java.lang.Class<?> type)
        Get the Class resource URL under specified Class
        Parameters:
        classLoader - ClassLoader
        type - type
        Returns:
        the resource URL under specified resource name and type
        Throws:
        java.lang.NullPointerException - If any argument is null
      • getInheritableClassLoaders

        @Nonnull
        public static java.util.Set<java.lang.ClassLoader> getInheritableClassLoaders​(@Nullable
                                                                                      java.lang.ClassLoader classLoader)
                                                                               throws java.lang.NullPointerException
        Get all Inheritable ClassLoaders Set (including ClassLoader argument)
        Parameters:
        classLoader - ClassLoader
        Returns:
        Read-only Set
        Throws:
        java.lang.NullPointerException - If classLoader argument is null
      • getAllLoadedClassesMap

        @Nonnull
        public static java.util.Map<java.lang.ClassLoader,​java.util.Set<java.lang.Class<?>>> getAllLoadedClassesMap​(@Nullable
                                                                                                                          java.lang.ClassLoader classLoader)
                                                                                                                   throws java.lang.UnsupportedOperationException
        Get all loaded classes Map under specified inheritable ClassLoader , ClassLoader as key , its loaded classes Set as value.
        Parameters:
        classLoader - ClassLoader
        Returns:
        Read-only Map
        Throws:
        java.lang.UnsupportedOperationException
        java.lang.NullPointerException - If classLoader argument is null
      • getAllLoadedClasses

        @Nonnull
        public static java.util.Set<java.lang.Class<?>> getAllLoadedClasses​(@Nullable
                                                                            java.lang.ClassLoader classLoader)
                                                                     throws java.lang.UnsupportedOperationException
        Get all loaded classes Set under specified inheritable ClassLoader
        Parameters:
        classLoader - ClassLoader
        Returns:
        Read-only Set
        Throws:
        java.lang.UnsupportedOperationException - If JVM does not support
        java.lang.NullPointerException - If classLoader argument is null
      • getLoadedClasses

        @Nonnull
        public static java.util.Set<java.lang.Class<?>> getLoadedClasses​(@Nullable
                                                                         java.lang.ClassLoader classLoader)
                                                                  throws java.lang.UnsupportedOperationException
        Get loaded classes Set under specified ClassLoader( not all inheritable ClassLoaders)
        Parameters:
        classLoader - ClassLoader
        Returns:
        Read-only Set
        Throws:
        java.lang.UnsupportedOperationException - If JVM does not support
        java.lang.NullPointerException - If classLoader argument is null
        See Also:
        getAllLoadedClasses(ClassLoader)
      • findLoadedClassesInClassPath

        public static java.util.Set<java.lang.Class<?>> findLoadedClassesInClassPath​(@Nullable
                                                                                     java.lang.ClassLoader classLoader)
                                                                              throws java.lang.UnsupportedOperationException
        Find loaded classes Set in class path
        Parameters:
        classLoader - ClassLoader
        Returns:
        Read-only Set
        Throws:
        java.lang.UnsupportedOperationException - If JVM does not support
      • findLoadedClassesInClassPaths

        public static java.util.Set<java.lang.Class<?>> findLoadedClassesInClassPaths​(@Nullable
                                                                                      java.lang.ClassLoader classLoader,
                                                                                      java.util.Set<java.lang.String> classPaths)
                                                                               throws java.lang.UnsupportedOperationException
        Find loaded classes Set in class paths Set
        Parameters:
        classLoader - ClassLoader
        classPaths - the class paths for the Set of JarFile or classes directory
        Returns:
        Read-only Set
        Throws:
        java.lang.UnsupportedOperationException - If JVM does not support
        See Also:
        findLoadedClass(ClassLoader, String)
      • findLoadedClassesInClassPath

        public static java.util.Set<java.lang.Class<?>> findLoadedClassesInClassPath​(@Nullable
                                                                                     java.lang.ClassLoader classLoader,
                                                                                     java.lang.String classPath)
                                                                              throws java.lang.UnsupportedOperationException
        Find loaded classes Set in class path
        Parameters:
        classLoader - ClassLoader
        classPath - the class path for one JarFile or classes directory
        Returns:
        Read-only Set
        Throws:
        java.lang.UnsupportedOperationException - If JVM does not support
        See Also:
        findLoadedClass(ClassLoader, String)
      • isPresent

        public static boolean isPresent​(@Nullable
                                        java.lang.String className)
        Test the specified class name is present in the default ClassLoader
        Parameters:
        className - the name of Class
        Returns:
        If found, return true
      • isPresent

        public static boolean isPresent​(@Nullable
                                        java.lang.String className,
                                        @Nullable
                                        java.lang.ClassLoader classLoader)
        Test the specified class name is present in the ClassLoader
        Parameters:
        className - the name of Class
        classLoader - ClassLoader
        Returns:
        If found, return true
      • resolveClass

        public static java.lang.Class<?> resolveClass​(@Nullable
                                                      java.lang.String className)
        Resolve the Class by the specified name in the default ClassLoader
        Parameters:
        className - the name of Class
        Returns:
        If can't be resolved , return null
      • resolveClass

        public static java.lang.Class<?> resolveClass​(@Nullable
                                                      java.lang.String className,
                                                      @Nullable
                                                      java.lang.ClassLoader classLoader)
        Resolve the Class by the specified name and ClassLoader
        Parameters:
        className - the name of Class
        classLoader - ClassLoader
        Returns:
        If can't be resolved , return null
      • resolveClass

        public static java.lang.Class<?> resolveClass​(@Nullable
                                                      java.lang.String className,
                                                      @Nullable
                                                      java.lang.ClassLoader classLoader,
                                                      boolean cached)
        Resolve the Class by the specified name and ClassLoader
        Parameters:
        className - the name of Class
        classLoader - ClassLoader
        cached - the resolved class is required to be cached or not
        Returns:
        If can't be resolved , return null
      • findAllClassPathURLs

        public static java.util.Set<java.net.URL> findAllClassPathURLs​(@Nullable
                                                                       java.lang.ClassLoader classLoader)
      • removeClassPathURL

        public static boolean removeClassPathURL​(@Nullable
                                                 java.lang.ClassLoader classLoader,
                                                 java.net.URL url)
      • findURLClassLoader

        @Nullable
        public static java.net.URLClassLoader findURLClassLoader​(@Nullable
                                                                 java.lang.ClassLoader classLoader)
      • newURLClassLoader

        @Nonnull
        public static java.net.URLClassLoader newURLClassLoader​(@Nonnull
                                                                java.lang.Iterable<java.net.URL> urls)
        Create a new instance of URLClassLoader
        Parameters:
        urls - the urls
        Returns:
        non-null URLClassLoader
        Throws:
        java.lang.IllegalArgumentException - if the urls is null or contains null element
      • newURLClassLoader

        @Nonnull
        public static java.net.URLClassLoader newURLClassLoader​(@Nonnull
                                                                java.lang.Iterable<java.net.URL> urls,
                                                                @Nullable
                                                                java.lang.ClassLoader classLoader)
        Create a new instance of URLClassLoader
        Parameters:
        urls - the urls
        Returns:
        non-null URLClassLoader
        Throws:
        java.lang.IllegalArgumentException - if the urls is null or contains null element
      • newURLClassLoader

        @Nonnull
        public static java.net.URLClassLoader newURLClassLoader​(@Nonnull
                                                                java.net.URL[] urls)
        Create a new instance of URLClassLoader
        Parameters:
        urls - the urls
        Returns:
        non-null URLClassLoader
        Throws:
        java.lang.IllegalArgumentException - if the urls is null or contains null element
      • newURLClassLoader

        @Nonnull
        public static java.net.URLClassLoader newURLClassLoader​(@Nonnull
                                                                java.net.URL[] urls,
                                                                boolean initializedLoaders)
        Create a new instance of URLClassLoader
        Parameters:
        urls - the urls
        initializedLoaders - the loaders of URLClassPath will be initialized or not
        Returns:
        non-null URLClassLoader
        Throws:
        java.lang.IllegalArgumentException - if the urls is null or contains null element
      • newURLClassLoader

        @Nonnull
        public static java.net.URLClassLoader newURLClassLoader​(@Nonnull
                                                                java.net.URL[] urls,
                                                                @Nullable
                                                                java.lang.ClassLoader parent)
                                                         throws java.lang.IllegalArgumentException
        Create a new instance of URLClassLoader
        Parameters:
        urls - the urls
        parent - the ClassLoader as parent
        Returns:
        non-null URLClassLoader
        Throws:
        java.lang.IllegalArgumentException - if the urls is null or contains null element
      • newURLClassLoader

        @Nonnull
        public static java.net.URLClassLoader newURLClassLoader​(@Nonnull
                                                                java.net.URL[] urls,
                                                                @Nullable
                                                                java.lang.ClassLoader parent,
                                                                boolean initializedLoaders)
                                                         throws java.lang.IllegalArgumentException
        Create a new instance of URLClassLoader
        Parameters:
        urls - the urls
        parent - the ClassLoader as parent
        initializedLoaders - the loaders of URLClassPath will be initialized or not
        Returns:
        non-null URLClassLoader
        Throws:
        java.lang.IllegalArgumentException - if the urls is null or contains null element
      • resolveURLClassLoader

        @Nonnull
        public static java.net.URLClassLoader resolveURLClassLoader​(@Nullable
                                                                    java.lang.ClassLoader classLoader)
        Try to find the instance of URLClassLoader from the specified ClassLoader, if it can't be found, it will try to find all the URL of class-paths from the specified ClassLoader, and then new a instance of URLClassLoader upon those urls.
        Parameters:
        classLoader - ClassLoader
        Returns:
        non-null URLClassLoader