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

BasicStroke.createStrokedShape(Shape): NPE is not specified

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 17
    • 5.0
    • client-libs
    • None
    • 2d
    • b09
    • generic
    • generic

      Method createStrokedShape(Shape) for java.awt.BasicStroke class throws NullPointerException when passed a null object reference for a input parameter. Such behavior is not specified either in the member spec or in the package/class description.

      ---------
      import java.awt.*;
      import java.awt.geom.Line2D;

      public class Test1 {

          //width
          static float widths[] = {
              -1f, 0f, 1f, 5f
          };
          static boolean widthOK[] = {
              false, true, true, true
          };
          static boolean widthCovered[] = {
              false, false, false, false
          };
          // cap
          static int caps[] = {
              BasicStroke.CAP_BUTT, BasicStroke.CAP_ROUND, BasicStroke.CAP_SQUARE
          };
          static String capStr[] = {
              "CAP_BUTT", "CAP_ROUND", "CAP_SQUARE"
          };
          // join
          static int joins[] = {
              BasicStroke.JOIN_BEVEL, BasicStroke.JOIN_MITER, BasicStroke.JOIN_ROUND
          };
          static String joinStr[] = {
              "JOIN_BEVEL", "JOIN_MITER", "JOIN_ROUND"
          };
          // miterLimit
          static int miters[] = {
              0, 1, 5
          };
          // dash
          static float dashes[][] = {
               {
                  -1, 0
              }, {
                  0, 0
              }, {
                  1, 2
              }
          };
          static boolean dashesOK[] = {
              false, false, true
          };
          static boolean dashCovered[] = {
              false, false, false
          };
          // dashPhase
          static int dashPhases[] = {
              -1, 0, 5
          };
          static boolean dashPhaseOK[] = {
              false, false, true
          };
          static boolean dashPhaseCovered[] = {
              false, false, false
          };

          static void initCoveredArrays() {
              int i;
              for(i = 0;i < widthCovered.length;i++)
                  widthCovered[i] = false;
              for(i = 0;i < dashCovered.length;i++)
                  dashCovered[i] = false;
              for(i = 0;i < dashPhaseCovered.length;i++)
                  dashPhaseCovered[i] = false;
          }


          public static void main(String[] args) {

              // test case ...
              initCoveredArrays();
              BasicStroke bs = new BasicStroke();
              try {
                  Shape s = bs.createStrokedShape(null);
                  System.out.println("result: false");
              }
              catch(NullPointerException ne) {
                  System.out.println("result (npe): true");
              }
          }
      }

      ###@###.### 2004-12-21 15:25:05 GMT

            psadhukhan Prasanta Sadhukhan
            ydanilev Yury Danilevich (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: