We couldn't load all Actvitity tabs. Refresh the page to try again.
If the problem persists, contact your Jira admin.
Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6770648

javax.swing.text.Highlighter.addHighlight() doesn't throw BadLocationException when expected

      Spec for javax.swing.text.addHighlight(int, int, HighlightPainter) says:
      "@exception BadLocationException for an invalid range specification"

      Exception is not always throw when expected.

      Platform: Windows, Solaris
      JCK: runtime 7 b03
      JDK: 6, 7

      The following test fails:
      api/javax_swing/text/Highlighter/index.html#Highlighter[Highlighter002]


      Please see code extract from the test:
      -----
      import javax.swing.*;
      import javax.swing.text.BadLocationException;
      import javax.swing.text.Highlighter;
      import javax.swing.text.JTextComponent;
      import java.awt.*;

      public class H002 {

          private static void runTest() {
              JFrame jFrame = new JFrame();
              JTextArea textArea = new JTextArea("Tested string");
              jFrame.getContentPane().add(textArea);
              jFrame.setVisible(true);
              Highlighter highlighter = textArea.getHighlighter();
              Highlighter.HighlightPainter myPainter = new Highlighter.HighlightPainter() {
                  public void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent c) {}
              };

              int negativeTestedData[][] = {{50, 0}, {-1, 1}, {-5, -4},
                                            {Integer.MAX_VALUE, Integer.MIN_VALUE},
                                            {Integer.MIN_VALUE, Integer.MAX_VALUE},
                                            {Integer.MIN_VALUE, Integer.MIN_VALUE}};
              String errorMessage4Negative = "";
              for (int i = 0; i < negativeTestedData.length; i++) {
                  try {
                      highlighter.addHighlight(negativeTestedData[i][0], negativeTestedData[i][1], myPainter);
                  } catch (BadLocationException e) {
                      continue;
                  }
                  errorMessage4Negative += "(" + negativeTestedData[i][0] + ", " + negativeTestedData[i][1] + ") ";
              }

              System.out.println("Method addHighlight() does not throw BadLocationException for \n" + errorMessage4Negative + ".");
              jFrame.dispose();
          }

          public static void main(String[] args) throws Exception {
              SwingUtilities.invokeLater(new Runnable() {
                  public void run() {
                      runTest();
                  }
              });
          }
      }
      -----

          Loading...
          Uploaded image for project: 'JDK'
          1. JDK
          2. JDK-6770648

          javax.swing.text.Highlighter.addHighlight() doesn't throw BadLocationException when expected

              Spec for javax.swing.text.addHighlight(int, int, HighlightPainter) says:
              "@exception BadLocationException for an invalid range specification"

              Exception is not always throw when expected.

              Platform: Windows, Solaris
              JCK: runtime 7 b03
              JDK: 6, 7

              The following test fails:
              api/javax_swing/text/Highlighter/index.html#Highlighter[Highlighter002]


              Please see code extract from the test:
              -----
              import javax.swing.*;
              import javax.swing.text.BadLocationException;
              import javax.swing.text.Highlighter;
              import javax.swing.text.JTextComponent;
              import java.awt.*;

              public class H002 {

                  private static void runTest() {
                      JFrame jFrame = new JFrame();
                      JTextArea textArea = new JTextArea("Tested string");
                      jFrame.getContentPane().add(textArea);
                      jFrame.setVisible(true);
                      Highlighter highlighter = textArea.getHighlighter();
                      Highlighter.HighlightPainter myPainter = new Highlighter.HighlightPainter() {
                          public void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent c) {}
                      };

                      int negativeTestedData[][] = {{50, 0}, {-1, 1}, {-5, -4},
                                                    {Integer.MAX_VALUE, Integer.MIN_VALUE},
                                                    {Integer.MIN_VALUE, Integer.MAX_VALUE},
                                                    {Integer.MIN_VALUE, Integer.MIN_VALUE}};
                      String errorMessage4Negative = "";
                      for (int i = 0; i < negativeTestedData.length; i++) {
                          try {
                              highlighter.addHighlight(negativeTestedData[i][0], negativeTestedData[i][1], myPainter);
                          } catch (BadLocationException e) {
                              continue;
                          }
                          errorMessage4Negative += "(" + negativeTestedData[i][0] + ", " + negativeTestedData[i][1] + ") ";
                      }

                      System.out.println("Method addHighlight() does not throw BadLocationException for \n" + errorMessage4Negative + ".");
                      jFrame.dispose();
                  }

                  public static void main(String[] args) throws Exception {
                      SwingUtilities.invokeLater(new Runnable() {
                          public void run() {
                              runTest();
                          }
                      });
                  }
              }
              -----

                    gsm Sergey Groznyh (Inactive)
                    dbessono Dmitry Bessonov
                    Votes:
                    0 Vote for this issue
                    Watchers:
                    0 Start watching this issue

                      Created:
                      Updated:
                      Resolved:
                      Imported:
                      Indexed:

                        gsm Sergey Groznyh (Inactive)
                        dbessono Dmitry Bessonov
                        Votes:
                        0 Vote for this issue
                        Watchers:
                        0 Start watching this issue

                          Created:
                          Updated:
                          Resolved:
                          Imported:
                          Indexed: