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

Path2D.Double, Path2D.Float and GeneralPath ctors throw exception when initialCapacity is negative

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P3
    • Resolution: Approved
    • Fix Version/s: 17
    • Component/s: client-libs
    • Labels:
      None
    • Subcomponent:
      2d
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      minimal
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      Some constructors in the Path2D.Double, Path2D.Float and GeneralPath classes throw unexpected exceptions.

      Problem

      The specification missed the NegativeArraySizeException, IllegalArgumentException and NullPointerException.

      Solution

      Update the speciifcation.

      Specification

      src/java.desktop/share/classes/java/awt/geom/GeneralPath.java
      
            * @param rule the winding rule
      +     * @throws IllegalArgumentException if {@code rule} is not either
      +     *         {@link #WIND_EVEN_ODD} or {@link #WIND_NON_ZERO}
            * @see #WIND_EVEN_ODD
            * @see #WIND_NON_ZERO
            * @since 1.2
            public GeneralPath(int rule) {
      
      
            * @param rule the winding rule
            * @param initialCapacity the estimate for the number of path segments
            *                        in the path
      +     * @throws IllegalArgumentException if {@code rule} is not either
      +     *         {@link #WIND_EVEN_ODD} or {@link #WIND_NON_ZERO}
      +     * @throws NegativeArraySizeException if {@code initialCapacity} is
      +     *         negative
            * @see #WIND_EVEN_ODD
            * @see #WIND_NON_ZERO
            * @since 1.2
            public GeneralPath(int rule, int initialCapacity) {
      
      
            * @param s the specified {@code Shape} object
      +     * @throws NullPointerException if {@code s} is {@code null}
            * @since 1.2
            */
            public GeneralPath(Shape s) {
      
      src/java.desktop/share/classes/java/awt/geom/Path2D.java
      
      
            * require the interior of the path to be defined.
            *
            * @param rule the winding rule
      +     * @throws IllegalArgumentException if {@code rule} is not either
      +     *         {@link #WIND_EVEN_ODD} or {@link #WIND_NON_ZERO}
            public Float(int rule) {
      
      
            * @param initialCapacity the estimate for the number of path segments
            *                        in the path
      +     * @throws IllegalArgumentException if {@code rule} is not either
      +     *         {@link #WIND_EVEN_ODD} or {@link #WIND_NON_ZERO}
      +     * @throws NegativeArraySizeException if {@code initialCapacity} is
      +     *         negative
            * @see #WIND_EVEN_ODD
            * @see #WIND_NON_ZERO
            * @since 1.6
            public Float(int rule, int initialCapacity) {
      
      
            * @param s the specified {@code Shape} object
      +     * @throws NullPointerException if {@code s} is {@code null}
            * @since 1.6
            */
           public Float(Shape s) {
      
      
            *
            * @param s the specified {@code Shape} object
            * @param at the specified {@code AffineTransform} object
      +     * @throws NullPointerException if {@code s} is {@code null}
            * @since 1.6
            */
           public Float(Shape s, AffineTransform at) {
      
      
            * @param rule the winding rule
      +     * @throws IllegalArgumentException if {@code rule} is not either
      +     *         {@link #WIND_EVEN_ODD} or {@link #WIND_NON_ZERO}
            * @see #WIND_EVEN_ODD
            * @see #WIND_NON_ZERO
            * @since 1.6
           public Double(int rule)
      
      
            * @param rule the winding rule
            * @param initialCapacity the estimate for the number of path segments
            *                        in the path
      +     * @throws IllegalArgumentException if {@code rule} is not either
      +     *         {@link #WIND_EVEN_ODD} or {@link #WIND_NON_ZERO}
      +     * @throws NegativeArraySizeException if {@code initialCapacity} is
      +     *         negative
            * @see #WIND_EVEN_ODD
            * @see #WIND_NON_ZERO
            * @since 1.6
            public Double(int rule, int initialCapacity) {
      
      
            * taken from the specified {@code Shape} object.
            *
            * @param s the specified {@code Shape} object
      +     * @throws NullPointerException if {@code s} is {@code null}
            * @since 1.6
            */
           public Double(Shape s) {
      
      
            * @param s the specified {@code Shape} object
            * @param at the specified {@code AffineTransform} object
      +     * @throws NullPointerException if {@code s} is {@code null}
            * @since 1.6
            */
           public Double(Shape s, AffineTransform at) {

      link for convenience https://github.com/openjdk/jdk/pull/2174/files

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              serb Sergey Bylokhov
              Reporter:
              ygaevsky Yuri Gaevsky
              Reviewed By:
              Alexander Zuev, Philip Race
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: