Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8196182

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3 P3
    • tbd
    • 6, 9, 10, 11
    • 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.

            alanb Alan Bateman
            jlahoda Jan Lahoda
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: