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

(sl) ServiceLoader.load(null) doesn't throw NPE

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 8
    • 7u4
    • core-libs
    • None
    • b61
    • generic
    • generic

      Java SE 7 Spec (http://docs.oracle.com/javase/7/docs/api/), java.util.ServiceLoader<S> section says:
      "Unless otherwise specified, passing a null argument to any method in this class will cause a NullPointerException to be thrown."

      According to the Spec, the statement ServiceLoader.load(null) should throw an NPE.
      But actually it throws nothing, as can be checked by the following simple test:

      public class Test {
        public static void main(String[] args) {
          try {
              java.util.ServiceLoader.load(null);
              System.out.println("Failed: NPE is not thrown");
          } catch (NullPointerException e) {
              System.out.println("OK");
          }
        }
      }

            psandoz Paul Sandoz
            smashars Sergey Masharsky (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: