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

Document NPE for passing null insets to constructors and methods of several javax.swing.border.* classes

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 20
    • client-libs
    • None
    • behavioral
    • minimal
    • No behaviour change. Only document update.
    • Java API
    • SE

      Summary

      Specify the existing behaviour of several javax.swing.border package's classes constructors and methods that if the Insets parameter is null, a NullPointerException will be thrown.

      Problem

      Several javax.swing.border package's contructors and methods, taking Insets as parameter throw NPE if a null reference is passed for the "Insets", but this behaviour is not documented.

      Solution

      Document that several javax.swing.border package's classes constructors and methods taking Insets as a parameter will throw NPE if a null reference is passed

      Specification

      javax.swing.border.AbstractBorder

         /**
            * Reinitializes the insets parameter with this Border's current Insets.
            * @param c the component for which this border insets value applies
            * @param insets the object to be reinitialized
            * @return the <code>insets</code> object
      +     * @throws NullPointerException if the specified {@code insets}
      +     *         is {@code null}
            */
           public Insets getBorderInsets(Component c, Insets insets) {

      javax.swing.border.BevelBorder

         /**
            * Reinitialize the insets parameter with this Border's current Insets.
            * @param c the component for which this border insets value applies
            * @param insets the object to be reinitialized
      +     * @throws NullPointerException if the specified {@code insets}
      +     *         is {@code null}
            */
           public Insets getBorderInsets(Component c, Insets insets) {

      javax.swing.border.CompoundBorder

        /**
            * Reinitialize the insets parameter with this Border's current Insets.
            * @param c the component for which this border insets value applies
            * @param insets the object to be reinitialized
      +     * @throws NullPointerException if the specified {@code insets}
      +     *         is {@code null}
            */
           public Insets getBorderInsets(Component c, Insets insets) {

      javax.swing.border.EmptyBorder

         /**
            * Creates an empty border with the specified insets.
            * @param borderInsets the insets of the border
      +     * @throws NullPointerException if the specified {@code borderInsets}
      +     *         is {@code null}
            */
           @ConstructorProperties({"borderInsets"})
           public EmptyBorder(Insets borderInsets)   {
      
         /**
            * Reinitialize the insets parameter with this Border's current Insets.
            * @param c the component for which this border insets value applies
            * @param insets the object to be reinitialized
      +     * @throws NullPointerException if the specified {@code insets}
      +     *         is {@code null}
            */
           public Insets getBorderInsets(Component c, Insets insets) {

      javax.swing.border.EtchedBorder

        /**
            * Reinitialize the insets parameter with this Border's current Insets.
            *
            * @param c the component for which this border insets value applies
            * @param insets the object to be reinitialized
      +     * @throws NullPointerException if the specified {@code insets}
      +     *         is {@code null}
            */
           public Insets getBorderInsets(Component c, Insets insets) {

      javax.swing.border.LineBorder

       /*
           * Reinitialize the insets parameter with this Border's current Insets.
            *
            * @param c the component for which this border insets value applies
            * @param insets the object to be reinitialized
      +     * @throws NullPointerException if the specified {@code insets}
      +     *         is {@code null}
            */
           public Insets getBorderInsets(Component c, Insets insets) {

      javax.swing.border.MatteBorder

       /**
            * Creates a matte border with the specified insets and color.
            * @param borderInsets the insets of the border
            * @param matteColor the color rendered for the border
      +     * @throws NullPointerException if the specified {@code borderInsets}
      +     *         is {@code null}
            * @since 1.3
            */
           public MatteBorder(Insets borderInsets, Color matteColor)   {
      
          /**
            * Creates a matte border with the specified insets and tile icon.
            * @param borderInsets the insets of the border
            * @param tileIcon the icon to be used for tiling the border
      +     * @throws NullPointerException if the specified {@code borderInsets}
      +     *         is {@code null}
            * @since 1.3
            */
           public MatteBorder(Insets borderInsets, Icon tileIcon)   {
      
          /**
            * Reinitialize the insets parameter with this Border's current Insets.
            * @param c the component for which this border insets value applies
            * @param insets the object to be reinitialized
      +     * @throws NullPointerException if the specified {@code insets}
      +     *         is {@code null}
            * @since 1.3
            */
           public Insets getBorderInsets(Component c, Insets insets) {

      javax.swing.border.SoftBevelBorder

          /**
            * Reinitialize the insets parameter with this Border's current Insets.
            * @param c the component for which this border insets value applies
            * @param insets the object to be reinitialized
      +     * @throws NullPointerException if the specified {@code insets}
      +     *         is {@code null}
            */
           public Insets getBorderInsets(Component c, Insets insets)       {

      javax.swing.plaf.BorderUIResource

              /**
                * Constructs an {@code EmptyBorderUIResource}.
                * @param insets the insets of the border
      +         * @throws NullPointerException if the spcecified {@code insets}
      +         *         is {@code null}
                */
               @ConstructorProperties({"borderInsets"})
               public EmptyBorderUIResource(Insets insets) {

      javax.swing.border.TitledBorder

        /**
            * Reinitialize the insets parameter with this Border's current Insets.
            * @param c the component for which this border insets value applies
            * @param insets the object to be reinitialized
      +     * @throws NullPointerException if the specified {@code insets}
      +     *         is {@code null}
            */
           public Insets getBorderInsets(Component c, Insets insets) {

            psadhukhan Prasanta Sadhukhan
            aglasman Alexander Glasman (Inactive)
            Philip Race
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: