Buggy code:
public final class ServiceLoader { private static final ILogger LOGGER = Logger . getLogger ( ServiceLoader . class ) ; private static final String FILTERING_CLASS_LOADER = FilteringClassLoader . class . getCanonicalName ( ) ; private static final String IGNORED_GLASSFISH_MAGIC_CLASSLOADER = "com.sun.enterprise.v3.server.APIClassLoaderServiceImpl$APIClassLoader" ; private ServiceLoader ( ) { } public static < T > T load ( Class < T > clazz , String factoryId , ClassLoader classLoader ) throws Exception { } public static < T > Iterator < T > iterator ( final Class < T > clazz , String factoryId , ClassLoader classLoader ) throws Exception { } public static < T > Iterator < Class < T > > classIterator ( String factoryId , ClassLoader classLoader ) throws Exception { } private static Set < ServiceLoader . ServiceDefinition > getServiceDefinitions ( String factoryId , ClassLoader classLoader ) { } private static Set < ServiceLoader . URLDefinition > collectFactoryUrls ( String factoryId , ClassLoader classLoader ) { final String resourceName = "META-INF//services//" + factoryId ; try { final Enumeration < URL > configs ; if ( classLoader != null ) { configs = classLoader . getResources ( resourceName ) ; } else { configs = ClassLoader . getSystemResources ( resourceName ) ; } Set < ServiceLoader . URLDefinition > urlDefinitions = new HashSet < ServiceLoader . URLDefinition > ( ) ; while ( configs . hasMoreElements ( ) ) { URL url = configs . nextElement ( ) ; <START_BUG> final URI uri = url . toURI ( ) ; <END_BUG> ClassLoader highestClassLoader = ServiceLoader . findHighestReachableClassLoader ( url , classLoader , resourceName ) ; if ( ! ( highestClassLoader . getClass ( ) . getName ( ) . equals ( ServiceLoader . IGNORED_GLASSFISH_MAGIC_CLASSLOADER ) ) ) { urlDefinitions . add ( new ServiceLoader . URLDefinition ( uri , highestClassLoader ) ) ; } } return urlDefinitions ; } catch ( Exception e ) { ServiceLoader . LOGGER . severe ( e ) ; } return Collections . emptySet ( ) ; } private static Set < ServiceLoader . ServiceDefinition > parse ( ServiceLoader . URLDefinition urlDefinition ) { } private static ClassLoader findHighestReachableClassLoader ( URL url , ClassLoader classLoader , String resourceName ) { } static List < ClassLoader > selectClassLoaders ( ClassLoader classLoader ) { } private static final class ServiceDefinition { private final String className ; private final ClassLoader classLoader ; private ServiceDefinition ( String className , ClassLoader classLoader ) { } @ Override public boolean equals ( Object o ) { } @ Override public int hashCode ( ) { } } private static final class URLDefinition { private final URI uri ; private final ClassLoader classLoader ; private URLDefinition ( URI url , ClassLoader classLoader ) { } @ Override public boolean equals ( Object o ) { } @ Override public int hashCode ( ) { } } private static class NewInstanceIterator < T > implements Iterator < T > { final Iterator < ServiceLoader . ServiceDefinition > iterator ; private final Class < T > clazz ; public NewInstanceIterator ( Set < ServiceLoader . ServiceDefinition > serviceDefinitions , Class < T > clazz ) { } public boolean hasNext ( ) { } public T next ( ) { } public void remove ( ) { } } private static class LoadClassIterator < T > implements Iterator < Class < T > > { final Iterator < ServiceLoader . ServiceDefinition > iterator ; public LoadClassIterator ( Set < ServiceLoader . ServiceDefinition > serviceDefinitions ) { } public boolean hasNext ( ) { } public Class < T > next ( ) { } public void remove ( ) { } } }

Fix:
final URI uri = new URI ( url . toExternalForm ( ) . replace ( "<seq2seq4repair_space>" , "%20" ) ) ;