sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 01/04: Minor simplification in array creation, and checkstyle fix.
Date Fri, 22 Jan 2021 23:43:03 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 b239be0e3dcc7b1ff24c15369a8deb57665899b3
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Fri Jan 22 22:51:40 2021 +0100

    Minor simplification in array creation, and checkstyle fix.
---
 .../java/org/apache/sis/util/collection/WeakHashSet.java    | 12 ++----------
 .../org/apache/sis/util/collection/WeakValueHashMap.java    | 13 ++-----------
 .../src/test/java/org/apache/sis/util/ClassesTest.java      |  2 +-
 3 files changed, 5 insertions(+), 22 deletions(-)

diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java
b/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java
index 83e6566..fec31f2 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java
@@ -24,7 +24,6 @@ import java.lang.reflect.Array;
 import org.apache.sis.util.Debug;
 import org.apache.sis.util.ArraysExt;
 import org.apache.sis.util.Utilities;
-import org.apache.sis.util.Workaround;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.NullArgumentException;
 
@@ -136,19 +135,12 @@ public class WeakHashSet<E> extends AbstractSet<E> implements
CheckedContainer<E
      *
      * @param  type  the type of the element to be included in this set.
      */
+    @SuppressWarnings({"rawtypes", "unchecked"})    // Generic array creation.
     public WeakHashSet(final Class<E> type) {
         elementType            = type;
         mayContainArrays       = type.isArray() || type.equals(Object.class);
         lastTimeNormalCapacity = System.nanoTime();
-        /*
-         * Workaround for the "generic array creation" compiler error.
-         * Otherwise we would use the commented-out line instead.
-         */
-        @SuppressWarnings("unchecked")
-        @Workaround(library="JDK", version="1.7")
-        final Entry[] table = (Entry[]) Array.newInstance(Entry.class, MIN_CAPACITY);
-//      table = new Entry[size];
-        this.table = table;
+        table = new WeakHashSet.Entry[MIN_CAPACITY];
     }
 
     /**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java
b/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java
index dbd511c..47cf758 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java
@@ -23,12 +23,10 @@ import java.util.AbstractSet;
 import java.util.Iterator;
 import java.util.Objects;
 import java.util.Arrays;
-import java.lang.reflect.Array;
 import java.lang.ref.WeakReference;
 import org.apache.sis.util.Debug;
 import org.apache.sis.util.ArraysExt;
 import org.apache.sis.util.Utilities;
-import org.apache.sis.util.Workaround;
 import org.apache.sis.util.NullArgumentException;
 import org.apache.sis.util.resources.Errors;
 
@@ -253,20 +251,13 @@ public class WeakValueHashMap<K,V> extends AbstractMap<K,V>
{
      *
      * @since 0.4
      */
+    @SuppressWarnings({"rawtypes", "unchecked"})    // Generic array creation.
     public WeakValueHashMap(final Class<K> keyType, final boolean identity) {
         this.keyType   = keyType;
         comparisonMode = identity ? IDENTITY :
                 (keyType.isArray() || keyType.equals(Object.class)) ? DEEP_EQUALS : EQUALS;
         lastTimeNormalCapacity = System.nanoTime();
-        /*
-         * Workaround for the "generic array creation" compiler error.
-         * Otherwise we would use the commented-out line instead.
-         */
-        @SuppressWarnings("unchecked")
-        @Workaround(library="JDK", version="1.7")
-        final Entry[] table = (Entry[]) Array.newInstance(Entry.class, MIN_CAPACITY);
-//      table = new Entry[size];
-        this.table = table;
+        table = new WeakValueHashMap.Entry[MIN_CAPACITY];
     }
 
     /**
diff --git a/core/sis-utility/src/test/java/org/apache/sis/util/ClassesTest.java b/core/sis-utility/src/test/java/org/apache/sis/util/ClassesTest.java
index 7eb8316..7d608db 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/util/ClassesTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/util/ClassesTest.java
@@ -113,7 +113,7 @@ public final strictfp class ClassesTest extends TestCase {
      * The intent is to verify that explicitly declared interfaces are listed
      * before parent interfaces in {@link #testGetAllInterfaces()}.
      */
-    private static abstract class MixedImpl implements GeographicCRS, EllipsoidalCS {
+    private abstract static class MixedImpl implements GeographicCRS, EllipsoidalCS {
     }
 
     /**


Mime
View raw message