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

(loom) j.io.PrintWriter(Writer, boolean) constructor doesn't throw NPE

    XMLWordPrintable

    Details

      Description

      === java.io =====
      Unless otherwise noted, passing a null argument to a constructor or method in any class or interface in this package will cause a NullPointerException to be thrown.
      ========

      Code sample

        new java.io.PrintWriter((java.io.Writer)null, false);

      doesn't produce NPE with the JDK-loom implementation.

      The change in behavior is likely caused by https://github.com/openjdk/loom/commit/20d1240b2e4e233549fd057149b6cec7bc2cc14a#diff-59afb0eab27ce903c9507c69b41a224dd3d121797d32ad4bd5d832d66d72d139L115

      While JDK-mainline generates:

      Exception in thread "main" java.lang.NullPointerException
      at java.base/java.io.Writer.<init>(Writer.java:174)
      at java.base/java.io.PrintWriter.<init>(PrintWriter.java:112)
      at Test.main(Test.java:3)

        Attachments

          Activity

            People

            Assignee:
            alanb Alan Bateman
            Reporter:
            dbessono Dmitry Bessonov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: