Ignore:
Timestamp:
2019-02-11T22:52:05+01:00 (5 years ago)
Author:
Don-vip
Message:

replace reflections library (unmaintained) by classgraph.

This allows us to update Guava to current version (27.0.1) with its only dependency (failureaccess 1.0.1).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/TestUtils.java

    r14528 r14782  
    3030import java.util.concurrent.ExecutionException;
    3131import java.util.concurrent.ThreadPoolExecutor;
     32import java.util.function.Function;
    3233import java.util.stream.Collectors;
    3334import java.util.stream.Stream;
     
    5556import org.openstreetmap.josm.tools.Utils;
    5657import org.openstreetmap.josm.tools.WikiReader;
    57 import org.reflections.Reflections;
    5858
    5959import com.github.tomakehurst.wiremock.WireMockServer;
     
    6262
    6363import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     64import io.github.classgraph.ClassGraph;
     65import io.github.classgraph.ClassInfoList;
     66import io.github.classgraph.ScanResult;
    6467import mockit.integration.TestRunnerDecorator;
    6568
     
    571574     */
    572575    public static <T> Set<Class<? extends T>> getJosmSubtypes(Class<T> superClass) {
    573         return new Reflections("org.openstreetmap.josm").getSubTypesOf(superClass);
     576        try (ScanResult scan = new ClassGraph().whitelistPackages("org.openstreetmap.josm").ignoreClassVisibility().scan()) {
     577            Function<String, ClassInfoList> lambda = superClass.isInterface() ? scan::getClassesImplementing : scan::getSubclasses;
     578            return lambda.apply(superClass.getName())
     579                    .asMap().values().stream().map(x -> x.loadClass(superClass)).collect(Collectors.toSet());
     580        }
    574581    }
    575582
Note: See TracChangeset for help on using the changeset viewer.