Arrays.parallelPrefix may fail to throw NPE for null op

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P2
    • 8
    • Affects Version/s: 8
    • Component/s: core-libs
    • Environment:

      Windows 7x64, JDK8 b107 x64

    • b107
    • 8
    • b112
    • x86
    • windows_7
    • Verified

      Following code executes without NPE being thrown:

      import java.util.Arrays;

      public class Test {
          public static void main(String[] args) {
              Arrays.parallelPrefix(new double[0], null);
              Arrays.parallelPrefix(new int[0], null);
              Arrays.parallelPrefix(new long[0], null);
              Arrays.parallelPrefix(new Object[0], null);

              Arrays.parallelPrefix(new double[0], 0, 0, null);
              Arrays.parallelPrefix(new int[0], 0, 0, null);
              Arrays.parallelPrefix(new long[0], 0, 0, null);
              Arrays.parallelPrefix(new Object[0], 0, 0, null);
          }
      }


      However according to spec NPE should be thrown - all the methods contain following:

      * @throws NullPointerException if the specified array or function is null

      It's understandable that why this happens but anyway behavior should correspond to spec.

      The minimized test is attached.

        1. Test.java
          0.5 kB
          Georgiy Rakov

            Assignee:
            Mike Duigou
            Reporter:
            Georgiy Rakov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: