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

Nimbus L&F:AbstractRegionPainter.decodeX/Y() should throw (specified) IAE instead of AssertionError

    Details

      Description

      For invalid X/Y values passed to methods javax.swing.plaf.nimbus.AbstractRegionPainter.decodeX/Y() java.lang.Assertion error is thrown which is unspecified. It is assumed that IllegalArgumentException would fit better for this case.

      Please see the following code sample:
      ------------------------------------------------------------------------------------
      import javax.swing.*;
      import java.awt.*;
      import java.awt.image.BufferedImage;

      public class Test {
          public static void main(String[] args) {
              class MyARP extends javax.swing.plaf.nimbus.AbstractRegionPainter {
                  MyARP() {
                      // workaround for CR#6849331
                      paint(new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB).createGraphics(), new JButton(), 10, 10);
                  }
                  protected PaintContext getPaintContext() {
                      // workaround for CR#6849331
                      return new PaintContext(new Insets(1, 2, 3, 4), new Dimension(100, 100), true);
                  }
                  protected void doPaint(Graphics2D g, JComponent c,
                                         int width, int height,
                                         Object[] extendedCacheKeys) { }
                  void call() {
      // decodeY(
                      decodeX(
                              -1.f
                      );
                  }
              }
              new MyARP().call();
          }
      }
      ------------------------------------------------------------------------------------
      Execution will lead to:

      Exception in thread "main" java.lang.AssertionError: Invalid x
      at javax.swing.plaf.nimbus.AbstractRegionPainter.decodeX(AbstractRegionPainter.java:242)
      at Test$1MyARP.call(Test.java:21)
      at Test.main(Test.java:26)

        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: