private static Set lookupSpiImplementations()

in maven-surefire-common/src/main/java/org/apache/maven/surefire/providerapi/ServiceLoader.java [86:124]


    private static Set<String> lookupSpiImplementations(final Enumeration<URL> urlEnumeration) throws IOException {
        final Set<String> names = new HashSet<>();
        nextUrl:
        while (urlEnumeration.hasMoreElements()) {
            final URL url = urlEnumeration.nextElement();
            try (BufferedReader reader = getReader(url)) {
                for (String line; (line = reader.readLine()) != null; ) {
                    int ci = line.indexOf('#');
                    if (ci >= 0) {
                        line = line.substring(0, ci);
                    }
                    line = line.trim();
                    int n = line.length();
                    if (n == 0) {
                        continue; // next line
                    }

                    if (line.indexOf(' ') >= 0 || line.indexOf('\t') >= 0) {
                        continue nextUrl; // next url
                    }
                    char cp = line.charAt(0); // should use codePointAt but this was JDK1.3
                    if (!isJavaIdentifierStart(cp)) {
                        continue nextUrl; // next url
                    }
                    for (int i = 1; i < n; i++) {
                        cp = line.charAt(i); // should use codePointAt but this was JDK1.3
                        if (!isJavaIdentifierPart(cp) && cp != '.') {
                            continue nextUrl; // next url
                        }
                    }
                    if (!names.contains(line)) {
                        names.add(line);
                    }
                }
            }
        }

        return names;
    }