Class SafeServiceLoader


  • public class SafeServiceLoader
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.util.List<T> load​(java.lang.Class<T> serviceClass, java.lang.ClassLoader classLoader)
      Delegates to ServiceLoader.load(Class, ClassLoader) and then eagerly iterates over returned Iterable, ignoring any potential UnsupportedClassVersionError.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SafeServiceLoader

        public SafeServiceLoader()
    • Method Detail

      • load

        public static <T> java.util.List<T> load​(java.lang.Class<T> serviceClass,
                                                 java.lang.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.