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

The java.sql.Numeric.toString(int radix) method doesn't work with small radix

XMLWordPrintable

    • 1.1
    • sparc
    • solaris_2.5
    • Not verified



      Name: saf@russia Date: 09/09/96


      This bug was found by St.Petersburg Java SQE team (by Mikhail Gorshenev).

      The java.sql.Numeric.toString(int radix) does not work with small radix.
      It throws IndexOutOfBoundsException.

      The java.sql specification (JDBC version 1.01) says the following:
      " public String toString(int radix)
            Returns a String representation of the numeric in the given radix.
            Parameters:
                  radix - the base of the number to be returned
            Returns:
                  a String representation of the numeric in the given radix "


      Here is the minimized test demonstrating the bug:
      ----- java_sql_Numeric_toString2.java ---------------------------------------
      import java.sql.Numeric;
      class java_sql_Numeric_toString2 {
        public static void main(String argv[]) {
            System.out.println((new Numeric("10")).toString(2));
        }
      }
      ----- The output of the test: -------------------------
      java.lang.StringIndexOutOfBoundsException: String index out of range: -1
      at java.lang.String.<init>(String.java)
      at java.sql.Numeric.toString(Numeric.java:584)
      -------------------------------------------------------


      Workaround:
      None
      ======================================================================

            mhapnersunw Mark Hapner (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: