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

test/sun/misc/Version/Version.java misparses version string


    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 7
    • Fix Version/s: 7
    • Component/s: other-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
    • CPU:
    • OS:


      The test test/sun/misc/Version/Version.java misparses the version string
      and may report a false failure or die with an exception.

      This test expects to get a version string of the following form:


      It picks off the initial parts of the string, leaving [-<identifier>]-bxx.
      It then splits this into substrings delimited by '-'. Next, it runs through
      each substring, and if that substring begins with 'b' it assumes that it has
      reached the 'bxx' portion of the version string (the build number) and so
      passes the remainder of that substring to Integer.valueOf() in order to get
      the build number as an integer.

      Unfortunately, if the <identifier> contains the string '-b' this will end up
      causing the test to parse that portion of the string as the build number, with
      erroneous results.

      The <identifier> is set automatically by the makefiles but it can be set to
      different values in various circumstances. For example, one can set it explicitly
      by building using the following command:

          make USER_RELEASE_SUFFIX=...

      The JPRT system sets this variable based on the repository name or working directory
      from which it's called, which is a source of an essentially arbitrary string ending
      up in the JDK version string.

      A couple examples of failures are given below.

      If the JDK is built with "make USER_RELEASE_SUFFIX=jdk-b1234567" (for example, a
      developer's build to test bug 1234567), the java.runtime.version property will be
      "1.7.0-internal-jdk-b1234567-b00", and running the Version.java test results in:

          java.lang.RuntimeException: Unmatched version: 1.7.0-b1234567 vs 1.7.0-b0
      at Version.main(Version.java:53)

      If the JDK is built with "make USER_RELEASE_SUFFIX=jdk-blenkinsop" (for example,
      by a developer named Blenkinsop), the java.runtime.version property will be
      "1.7.0-internal-jdk-blenkinsop-b00", and running the Version.java test results in:

          java.lang.NumberFormatException: For input string: "lenkinsop"
      at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
      at java.lang.Integer.parseInt(Integer.java:492)
      at java.lang.Integer.valueOf(Integer.java:582)
      at Version.newVersionInfo(Version.java:155)
      at Version.main(Version.java:44)




            • Assignee:
              smarks Stuart Marks
              smarks Stuart Marks
            • Votes:
              0 Vote for this issue
              0 Start watching this issue


              • Created: