Class SafeServiceLoader

java.lang.Object
io.opentelemetry.javaagent.tooling.SafeServiceLoader

public final class SafeServiceLoader extends Object
  • Method Details

    • load

      public static <T> List<T> load(Class<T> serviceClass, ClassLoader classLoader)
      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.sdk.autoconfigure.spi.Ordered> List<T> loadOrdered(Class<T> serviceClass, ClassLoader classLoader)
      Same as load(Class, ClassLoader), but also orders the returned implementations by comparing their Ordered.order().