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

swing.text.Utilities.getRow[Start|End]() throw unexpected NPE

XMLWordPrintable

    • kestrel
    • x86, sparc
    • solaris_2.6, windows_nt



      Name: asC58863 Date: 06/17/99


      Two swing symmetric methods: Utilities.getRowStart() and
      Utilities.getRowEnd() throw unexpected NullPointerException.

      Here is the example demonstrating the bug:
      ------------------ Test.java -----------------
      import javax.swing.text.BadLocationException;
      import javax.swing.text.JTextComponent;
      import javax.swing.text.Utilities;
      import javax.swing.JTextArea;

      class Test {

          public static void main(String[] argv) {
              JTextComponent comp = new JTextArea( "Document text");

              try {
                  Utilities.getRowStart( comp, 2);
                  System.out.println("getRowStart: NPE has not been thrown");
              } catch(BadLocationException ble) {
                  System.out.println("getRowStart: Exception "+ble);
              } catch(NullPointerException npe) {
                  System.out.println("getRowStart: Unexpected NPE has been thrown ");
                  npe.printStackTrace();
              }

              try {
                  Utilities.getRowEnd( comp, 2);
                  System.out.println("getRowEnd: NPE has not been thrown");
              } catch(BadLocationException ble) {
                  System.out.println("getRowEnd: Exception "+ble);
              } catch(NullPointerException npe) {
                  System.out.println("getRowEnd: Unexpected NPE has been thrown ");
                  npe.printStackTrace();
              }
              System.exit(0);
          }
      }
      ----------------- output -----------------------------
      java full version "JDK-1.3-F"
      getRowStart: Unexpected NPE has been thrown
      java.lang.NullPointerException
              at javax.swing.text.Utilities.getRowStart(Utilities.java, Compiled Code)
              at Test.main(Test.java, Compiled Code)
      getRowEnd: Unexpected NPE has been thrown
      java.lang.NullPointerException
              at javax.swing.text.Utilities.getRowEnd(Utilities.java, Compiled Code)
              at Test.main(Test.java, Compiled Code)
      ------------------------------------------------------

      ======================================================================

            tprinzing Tim Prinzing
            anssunw Ans Ans (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: