public static URL [ ] of ( ClassLoader classLoader , Class clazz ) { if ( clazz == null ) { clazz = ClassPathURLs . class ; } if ( classLoader == null ) { classLoader = clazz . getClassLoader ( ) ; } final Set < URL > urls = new LinkedHashSet <> ( ) ; while ( classLoader != null ) { if ( classLoader instanceof URLClassLoader ) { URLClassLoader urlClassLoader = ( URLClassLoader ) classLoader ; URL [ ] allURLS = urlClassLoader . getURLs ( ) ; Collections . addAll ( urls , allURLS ) ; break ; } URL classUrl = classModuleUrl ( classLoader , clazz ) ; if ( classUrl != null ) { urls . add ( classUrl ) ; } classUrl = classModuleUrl ( classLoader , ClassPathURLs . class ) ; if ( classUrl != null ) { urls . add ( classUrl ) ; } ModuleDescriptor moduleDescriptor = clazz . getModule ( ) . getDescriptor ( ) ; if ( moduleDescriptor != null ) { moduleDescriptor . requires ( ) . forEach ( req -> { ModuleLayer . boot ( ) . findModule ( req . name ( ) ) . ifPresent ( mod -> { ClassLoader moduleClassLoader = mod . getClassLoader ( ) ; if ( moduleClassLoader != null ) { URL url = moduleClassLoader . getResource ( MANIFEST ) ; if ( url != null ) { url = fixManifestUrl ( url ) ; urls . add ( url ) ; } } } ) ; } ) ; } classLoader = classLoader . getParent ( ) ; } return urls . toArray ( new URL [ 0 ] ) ; }
Returns urls for the classloader .