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

JLayer.remove((Component)null) should behave consistently in (not) throwing NPE

    Details

    • Subcomponent:
    • Resolved In Build:
      b74
    • CPU:
      generic
    • OS:
      generic

      Description

      Method JLayer.remove((Component) null) throws NPE (see CR#6875173)
      but if glassPane is set to null and view is not null then NPE isn't thrown:

      import javax.swing.*;
      import java.awt.*;

      public class NPE {
          public static void main(String[] args) {
              JLayer<Component> layer = new JLayer<Component>(new Component(){});
              // comment the following line to get NPE
              layer.setGlassPane(null);
              // NPE might or might not be thrown
              layer.remove((Component)null);
          }
      }

      Behavior should be unified.
      The following JCK test verifies NPE throwing:
      api/javax_swing/JLayer/index.html#General[remove_nullComponent_01]
      api/javax_swing/JLayer/index.html#General[remove_nullComponent_02]
      api/javax_swing/JLayer/index.html#General[remove_nullComponent_03]

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                alexp Alexander Potochkin (Inactive)
                Reporter:
                dbessono Dmitry Bessonov
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: