ServiceLoader.iterator().hasNext()/.next() may throw a LinkageError

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: P3
    • tbd
    • Affects Version/s: 6, 9, 10, 11
    • Component/s: core-libs
    • None

      Based on JDK-8130493.

      When using a ServiceLoader to load unnamed module classes, and if loading of that class fails with a LinkageError, the LinkageError is thrown out of the ServiceLoader's Iterator's hasNext() method, which seems to be against the javadoc/specification:

      (From the ServiceLoader's top level javadoc:)

      {quote}
       * <p> When using the service loader's {@code iterator}, the {@link
       * Iterator#hasNext() hasNext} and {@link Iterator#next() next} methods will
       * fail with {@link ServiceConfigurationError} if an error occurs locating,
       * loading or instantiating a service provider. When processing the service
      {quote}

      A testcase is attached.

            Assignee:
            Alan Bateman
            Reporter:
            Jan Lahoda
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: