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

Arrays.parallelPrefix may fail to throw NPE for null op

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2
    • 8
    • 8
    • core-libs
    • Windows 7x64, JDK8 b107 x64

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

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: