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

Package.isCompatibleWith(String) doesn't check for correct dotted form

XMLWordPrintable

    • mantis
    • sparc
    • solaris_2.5
    • Verified



      Name: mgC56079 Date: 04/08/99



      The javadoc for Package class and Package.isCompatibleWith method says:
       * Specification version numbers use a "Dewey Decimal"
       * syntax that consists of positive decimal integers
       * separated by periods ".", for example, "2.0" or "1.2.3.4.5.6.7".
       * This allows an extensible number to be used to
       * represent major, minor, micro, etc versions.
       * The version number must begin with a number. <p>

       <skip>

       * @exception NumberFormatException if the desired or current version
       * is not of the correct dotted form.

      However, the method doesn't throw a NumberFormatException if the dotted form is incorrect.

      -----Here is a test------------
      public class PackageTest {

          public static void main(String args[]) {
              Package p = Object.class.getPackage();
              System.out.println(p.isCompatibleWith(""));
              System.out.println(p.isCompatibleWith("0...."));
              System.out.println(p.isCompatibleWith("2.-2"));
              System.out.println("Failed");
          }

      }
      ------Sample run (JDK 1.2.2)-------------
      % java PackageTest
      true
      true
      false
      Failed

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

            iris Iris Clark
            gorsunw Gor Gor (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: