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

BasicStroke.createStrokedShape(Shape): NPE is not specified

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 17
    • client-libs
    • None
    • 2d
    • behavioral
    • minimal
    • No behavior change - specification only so minimal risk
    • Java API
    • SE

      Summary

      Specify that java.awt.BasicStroke.createStrokedShape(Shape) will throw NullPointerException when passed a null object reference for the parameter.

      Problem

      Method createStrokedShape(Shape) of the java.awt.BasicStroke class throws NullPointerException when passed a null object reference for the parameter but it is not specified in the specification.

      Solution

      Update the specification to document that NullPointerException will be thrown for null a Shape object passed to createStrokedShape()

      Specification

      diff --git a/src/java.desktop/share/classes/java/awt/BasicStroke.java b/src/java.desktop/share/classes/java/awt/BasicStroke.java
      index e74753265e3..2c3ddde106c 100644
      --- a/src/java.desktop/share/classes/java/awt/BasicStroke.java
      +++ b/src/java.desktop/share/classes/java/awt/BasicStroke.java
      @@ -294,6 +294,7 @@ public class BasicStroke implements Stroke {
            * stroked outline of a specified {@code Shape}.
            * @param s the {@code Shape} boundary be stroked
            * @return the {@code Shape} of the stroked outline.
      +     * @throws NullPointerException if {@code s} is {@code null}
            */
           public Shape createStrokedShape(Shape s) {
               sun.java2d.pipe.RenderingEngine re =

            psadhukhan Prasanta Sadhukhan
            ydanilev Yury Danilevich (Inactive)
            Philip Race, Sergey Bylokhov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: