8161236: Runtime.Version.{compareTo, equals}IgnoreOpt should be renamed
authoriris
Thu, 21 Jul 2016 07:42:05 -0700
changeset 39766 745f165bedee
parent 39765 c1aee33ef0c0
child 39767 797c32a7d4e2
8161236: Runtime.Version.{compareTo, equals}IgnoreOpt should be renamed Reviewed-by: alanb, rfield, ksrini
jdk/src/java.base/share/classes/java/lang/Runtime.java
jdk/test/java/lang/Runtime/Version/Basic.java
--- a/jdk/src/java.base/share/classes/java/lang/Runtime.java	Thu Jul 21 13:02:35 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/Runtime.java	Thu Jul 21 07:42:05 2016 -0700
@@ -945,7 +945,7 @@
     }
 
     /**
-     * A representation of a version string for an implemenation of the
+     * A representation of a version string for an implementation of the
      * Java SE Platform.  A version string contains a version number
      * optionally followed by pre-release and build information.
      *
@@ -1058,10 +1058,10 @@
      * <p> When comparing two version strings, the value of {@code $OPT}, if
      * present, may or may not be significant depending on the chosen
      * comparison method.  The comparison methods {@link #compareTo(Version)
-     * compareTo()} and {@link #compareToIgnoreOpt(Version)
-     * compareToIgnoreOpt()} should be used consistently with the
+     * compareTo()} and {@link #compareToIgnoreOptional(Version)
+     * compareToIgnoreOptional()} should be used consistently with the
      * corresponding methods {@link #equals(Object) equals()} and {@link
-     * #equalsIgnoreOpt(Object) equalsIgnoreOpt()}.  </p>
+     * #equalsIgnoreOptional(Object) equalsIgnoreOptional()}.  </p>
      *
      * <p> A <em>short version string</em>, {@code $SVSTR}, often useful in
      * less formal contexts, is a version number optionally followed by a
@@ -1249,7 +1249,7 @@
          * @throws  NullPointerException
          *          If the given object is {@code null}
          */
-        public int compareToIgnoreOpt(Version ob) {
+        public int compareToIgnoreOptional(Version ob) {
             return compare(ob, true);
         }
 
@@ -1270,7 +1270,7 @@
                 return ret;
 
             if (!ignoreOpt)
-                return compareOpt(ob);
+                return compareOptional(ob);
 
             return 0;
         }
@@ -1325,7 +1325,7 @@
             return 0;
         }
 
-        private int compareOpt(Version ob) {
+        private int compareOptional(Version ob) {
             Optional<String> oOpt = ob.optional();
             if (!optional.isPresent()) {
                 if (oOpt.isPresent())
@@ -1384,7 +1384,7 @@
          */
         @Override
         public boolean equals(Object ob) {
-            boolean ret = equalsIgnoreOpt(ob);
+            boolean ret = equalsIgnoreOptional(ob);
             if (!ret)
                 return false;
 
@@ -1407,7 +1407,7 @@
          *          ignoring the optinal build information
          *
          */
-        public boolean equalsIgnoreOpt(Object ob) {
+        public boolean equalsIgnoreOptional(Object ob) {
             if (this == ob)
                 return true;
             if (!(ob instanceof Version))
--- a/jdk/test/java/lang/Runtime/Version/Basic.java	Thu Jul 21 13:02:35 2016 -0700
+++ b/jdk/test/java/lang/Runtime/Version/Basic.java	Thu Jul 21 07:42:05 2016 -0700
@@ -24,7 +24,7 @@
 /*
  * @test
  * @summary Unit test for java.lang.Runtime.Version.
- * @bug 8072379 8144062
+ * @bug 8072379 8144062 8161236
  */
 
 import java.lang.reflect.InvocationTargetException;
@@ -55,7 +55,7 @@
     public static void main(String ... args) {
 
         //// Tests for parse(), major(), minor(), security(), pre(),
-        //// build(), opt(), version(), toString()
+        //// build(), optional(), version(), toString()
         //   v                          M     m sec pre bld opt
 
         // $VNUM
@@ -119,7 +119,8 @@
         //// Test for Runtime.version()
         testVersion();
 
-        //// Test for equals{IgnoreOpt}?(), hashCode(), compareTo{IgnoreOpt}?()
+        //// Test for equals{IgnoreOptional}?(), hashCode(),
+        //// compareTo{IgnoreOptional}?()
         // compare: after "<" == -1, equal == 0, before ">" == 1
         //      v0            v1                  eq     eqNO  cmp  cmpNO
         testEHC("9",          "9",                true,  true,   0,    0);
@@ -293,9 +294,9 @@
     }
 
     private static void testEqualsNO(Version v0, Version v1, boolean eq) {
-        if ((eq && !v0.equalsIgnoreOpt(v1))
-            || (!eq && v0.equalsIgnoreOpt(v1))) {
-            fail("equalsIgnoreOpt() " + Boolean.toString(eq),
+        if ((eq && !v0.equalsIgnoreOptional(v1))
+            || (!eq && v0.equalsIgnoreOptional(v1))) {
+            fail("equalsIgnoreOptional() " + Boolean.toString(eq),
                  v0.toString(), v1.toString());
         } else {
             pass();
@@ -328,12 +329,12 @@
     private static void testCompareNO(Version v0, Version v1, int compare)
     {
         try {
-            Method m = VERSION.getMethod("compareToIgnoreOpt", VERSION);
+            Method m = VERSION.getMethod("compareToIgnoreOptional", VERSION);
             int cmp = (int) m.invoke(v0, v1);
             checkCompare(v0, v1, compare, cmp);
         } catch (IllegalAccessException | InvocationTargetException |
                  NoSuchMethodException ex) {
-            fail(String.format("compareToIgnoreOpt() invocation: %s",
+            fail(String.format("compareToIgnoreOptional() invocation: %s",
                                ex.getClass()),
                  null);
         }