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

Long l_hex = Long.decode("#ffffffffffffffffL"); //fails

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.4.2
    • core-libs
    • x86
    • windows_nt



      Name: rmT116609 Date: 04/27/2004


      FULL PRODUCT VERSION :
      java version "1.4.2_04"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
      Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)

      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Windows NT, Windows XP

      A DESCRIPTION OF THE PROBLEM :
      Long l_hex = Long.decode("#ffffffffffffffffL"); //fails with java.lang.NumberFormatException: For input string: "ffffffffffffffffl"

      Long l_hex = Long.decode("#ffffffff"); //Works...
      (the run-time doesn't comply with :

      http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#48282

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run the test case.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      //java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#48282
      ACTUAL -
      E:\www\sup1-egs\lang\Long\decode>java Main1
      java.lang.NumberFormatException: For input string: "ffffffffffffffffl"
              at java.lang.NumberFormatException.forInputString(NumberFormatException.
      java:48)
              at java.lang.Long.parseLong(Long.java:406)
              at java.lang.Long.valueOf(Long.java:482)
              at java.lang.Long.decode(Long.java:593)
              at Main1.main(Main1.java:8)

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.lang.NumberFormatException: For input string: "ffffffffffffffffl"
              at java.lang.NumberFormatException.forInputString(NumberFormatException.
      java:48)
              at java.lang.Long.parseLong(Long.java:406)
              at java.lang.Long.valueOf(Long.java:482)
              at java.lang.Long.decode(Long.java:593)
              at Main1.main(Main1.java:8)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      class Main1 {
          public static void main(String[] args) {
      //
              try {
                  Long l_dec = Long.decode("225");
                  Long l_oct = Long.decode("065"); // octal
                  Long l_hex1 = Long.decode("0x1f"); // hex
                  Long l_hex2 = Long.decode("#ffffffffffffffffL"); // hex
                  Long l_big = Long.decode("1234123455555");// decimal

                  System.out.println("parsed: " +
                      l_dec + "," + l_oct + "," + l_hex1 + "," + l_hex2);
              } catch (NumberFormatException e) {
                  e.printStackTrace();
              }
      //
          }
      }
      ---------- END SOURCE ----------

      (Incident Review ID: 259979)
      ======================================================================

            gafter Neal Gafter (Inactive)
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: