sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 01/02: Deprecate a method which is not used in practice and cause compatibility problem with JDK 14.
Date Tue, 21 Apr 2020 23:09:41 GMT
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit c277c9c0114f1f0df329f8a1d07876e0e3c2b978
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Tue Apr 21 18:47:41 2020 +0200

    Deprecate a method which is not used in practice and cause compatibility problem with
JDK 14.
---
 .../main/java/org/apache/sis/util/Characters.java  | 12 +++++++---
 .../java/org/apache/sis/util/CharactersTest.java   | 27 +---------------------
 2 files changed, 10 insertions(+), 29 deletions(-)

diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/Characters.java b/core/sis-utility/src/main/java/org/apache/sis/util/Characters.java
index b515a06..ab72105 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/Characters.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/Characters.java
@@ -17,6 +17,7 @@
 package org.apache.sis.util;
 
 import org.opengis.metadata.citation.Citation;  // For javadoc.
+import org.apache.sis.internal.util.Numerics;
 import org.apache.sis.internal.util.Strings;
 import org.apache.sis.util.resources.Errors;
 
@@ -28,7 +29,7 @@ import org.apache.sis.util.resources.Errors;
  * symbols. For those symbols, constants are declared in this class.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 1.0
+ * @version 1.1
  * @since   0.3
  * @module
  */
@@ -321,7 +322,7 @@ public final class Characters extends Static {
      * left are {@linkplain #LETTERS_AND_DIGITS letters and digits}.
      *
      * @author  Martin Desruisseaux (Geomatys)
-     * @version 0.3
+     * @version 1.1
      *
      * @see java.lang.Character.Subset
      * @see Character#getType(int)
@@ -413,9 +414,14 @@ public final class Characters extends Static {
          * @return {@code true} if this subset contains the characters of the given type.
          *
          * @see Character#getType(int)
+         *
+         * @deprecated to be removed because not used (only {@link #contains(int)} is used
in practice)
+         *             and consistency with {@link #contains(int)} is not guaranteed between
different
+         *             Java versions.
          */
+        @Deprecated
         public final boolean containsType(final int type) {
-            return (type >= 0) && (type < Long.SIZE) && (types &
(1L << type)) != 0;
+            return (types & Numerics.bitmask(type)) != 0;
         }
 
         /**
diff --git a/core/sis-utility/src/test/java/org/apache/sis/util/CharactersTest.java b/core/sis-utility/src/test/java/org/apache/sis/util/CharactersTest.java
index 1fd93fe..0ceb510 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/util/CharactersTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/util/CharactersTest.java
@@ -28,7 +28,7 @@ import static org.apache.sis.util.Characters.*;
  * Tests the {@link Characters} utility methods.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.6
+ * @version 1.1
  * @since   0.3
  * @module
  */
@@ -161,29 +161,4 @@ public final strictfp class CharactersTest extends TestCase {
         assertTrue (filter.contains(' '));
         assertFalse(filter.contains('A'));
     }
-
-    /**
-     * Scans the full {@code char} range in order to check for
-     * {@link org.apache.sis.util.Characters.Filter} consistency.
-     */
-    @Test
-    public void scanCharacterRange() {
-        for (int c=Character.MIN_VALUE; c<=Character.MAX_VALUE; c++) {
-            final int type = Character.getType(c);
-predefined: for (int i=0; ; i++) {
-                final Characters.Filter filter;
-                switch (i) {
-                    case 0:  filter = Filter.UNICODE_IDENTIFIER; break;
-                    case 1:  filter = Filter.LETTERS_AND_DIGITS; break;
-                    default: break predefined;
-                }
-                final boolean cc = filter.contains(c);
-                final boolean ct = filter.containsType(type);
-                if (cc != ct) {
-                    fail(filter + ".contains('" + (char) c + "') == " + cc + " but "
-                            + filter + ".containsType(" + type + ") == " + ct);
-                }
-            }
-        }
-    }
 }


Mime
View raw message