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

Some AWT's methods should specify throwing NPE for null arg value

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b120
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description

      Methods java.awt.Container.add(...) specify

      "Throws: NullPointerException - if comp is null"

      while java.awt.Container.remove(...) doesn't. In fact it throws NPE for null arg:

      public class TestNPE {
          public static void main(String[] args) {
              new java.awt.Container().remove((java.awt.Component) null);
          }
      }

      Exception in thread "main" java.lang.NullPointerException
      at java.awt.Container.remove(Container.java:1228)
      at temp.TestNPE.main(TestNPE.java:5)
      ...

      This behavior should be documented.

        Attachments

          Activity

            People

            Assignee:
            dcherepanov Dmitry Cherepanov
            Reporter:
            dbessono Dmitry Bessonov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: