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

DOC: javax.swing.border.StrokeBorder.paintBorder() doesn't throw NPE in all specified cases

XMLWordPrintable

    • b130
    • generic
    • generic
    • Verified

      JDK: 7b118+
      Platform: Any

      Brute force testing revealed a case when NPE is not thrown
      as specified in the following method if passed Component is null

      http://download.java.net/jdk7/docs/api/javax/swing/border/StrokeBorder.html#paintBorder(java.awt.Component, java.awt.Graphics, int, int, int, int)

      Throws:
      NullPointerException - if the specified c or g are null

      ---------------------------------------------------------------------
      import java.awt.*;
      import java.awt.image.BufferedImage;

      public class StrokeBorderNPE {

          public static void main(String[] args) {

              new javax.swing.border.StrokeBorder(
                      new BasicStroke(100,
                              BasicStroke.CAP_SQUARE,
                              BasicStroke.JOIN_ROUND), Color.BLACK)
                      // @throws NullPointerException
                      // if the specified {@code c} or {@code g} are {@code null}
                      .paintBorder(
                              (Component) null,
                              new BufferedImage(
                                      1,1, BufferedImage.TYPE_INT_RGB).createGraphics(),
                              0,0,1,1);
          }
      }
      ---------------------------------------------------------------------

            malenkov Sergey Malenkov (Inactive)
            dbessono Dmitry Bessonov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: