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

Runtime.Version.{major(),security()} return value of 0 may be ambiguous

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4
    • tbd
    • None
    • other-libs

    Description

      Version.major() and Version.security() will return 0 if those values are set to zero OR if they are unset. If a user tries to construct a String which contains trialing zeros, and then invokes Version.parse(), this will fail, even if the source of the zeros was a valid Version object. For example:

        Version v = Version.parse("9");
        Version ver = Version.parse(String.format("%d.%d.%d%n),
                                                     v.major(), v.minor(), v.security())); // IAE

      If the current method signatures returning int are retained, constants NO_MINOR_VERSION and NO_MAJOR_VERSION (both = -1) could be returned instead of 0.

      Alternatively, changing the methods' return value to Integer and returning null might be more palatable.

      If we re-consider how trialing zeros are handled, there are a number of additional options, some combination of which would address this problem or at least reduce impact.

      Attachments

        Issue Links

          Activity

            People

              iris Iris Clark
              iris Iris Clark
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: