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

Nimbus L&F: AbstractRegionPainter.decodeRadialGradient(...) should specify IAE thrown for neg radius

    Details

      Description

      Method javax.swing.plaf.nimbus.AbstractRegionPainter.decodeRadialGradient(...) throws unspecified IllegalArgumentException for negative radius values. It should be specified.

      Please see the following code sample:
      ------------------------------------------------------------------------------------
      import javax.swing.*;
      import java.awt.*;
      import static java.awt.Color.*;
      public class Test {
          public static void main(String[] args) {
              class MyARP extends javax.swing.plaf.nimbus.AbstractRegionPainter {
                  protected PaintContext getPaintContext() { return null; }
                  protected void doPaint(Graphics2D g, JComponent c,
                                         int width, int height,
                                         Object[] extendedCacheKeys) { }
                  void callWithNegRadius() {
                      float radius = -1.f;
                      decodeRadialGradient(0.1f, 0.5f, radius,
                              new float[]{.1f, 0.2f}, new Color[]{BLACK, BLUE});
                  }
              }
              new MyARP().callWithNegRadius();
          }
      }
      ------------------------------------------------------------------------------------
      Execution will lead to:

      Exception in thread "main" java.lang.IllegalArgumentException: Radius must be greater than zero
      at java.awt.RadialGradientPaint.<init>(RadialGradientPaint.java:451)
      at java.awt.RadialGradientPaint.<init>(RadialGradientPaint.java:387)
      at java.awt.RadialGradientPaint.<init>(RadialGradientPaint.java:344)
      at java.awt.RadialGradientPaint.<init>(RadialGradientPaint.java:176)
      at javax.swing.plaf.nimbus.AbstractRegionPainter.decodeRadialGradient(AbstractRegionPainter.java:393)
      at Test$1MyARP.callWithNegRadius(Test.java:15)
      at Test.main(Test.java:19)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                peterz Peter Zhelezniakov (Inactive)
                Reporter:
                dbessono Dmitry Bessonov
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: