Class SafeServiceLoader


  • public final class SafeServiceLoader
    extends Object
    • Method Detail

      • load

        public static <T> List<T> load​(Class<T> serviceClass)
        Delegates to ServiceLoader.load(Class, ClassLoader) and then eagerly iterates over returned Iterable, ignoring any potential UnsupportedClassVersionError.

        Those errors can happen when some classes returned by ServiceLoader were compiled for later java version than is used by currently running JVM. During normal course of business this should not happen. Please read CONTRIBUTING.md, section "Testing - Java versions" for a background info why this is Ok.

      • loadOrdered

        public static <T extends io.opentelemetry.javaagent.extension.Ordered> List<T> loadOrdered​(Class<T> serviceClass)
        Same as load(Class), but also orders the returned implementations by comparing their Ordered.order().