sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 02/02: More uses of new JDK9 methods (Math.fma, Math.multiplyFull).
Date Wed, 15 Aug 2018 13:13:37 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 46faa2458bb6acde29d11e474505bc49b9e88596
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Wed Aug 15 15:10:33 2018 +0200

    More uses of new JDK9 methods (Math.fma, Math.multiplyFull).
---
 .../referencing/gazetteer/MilitaryGridReferenceSystem.java |  2 +-
 .../org/apache/sis/referencing/datum/DatumShiftGrid.java   |  6 +++---
 .../operation/transform/LinearInterpolator1D.java          | 12 ++++++------
 .../referencing/operation/transform/LinearTransform1D.java | 14 +++++++-------
 .../operation/transform/ProjectiveTransform.java           | 10 +++++-----
 .../operation/CoordinateOperationFinderTest.java           |  4 ++--
 .../src/main/java/org/apache/sis/math/Fraction.java        | 11 ++++++-----
 .../src/main/java/org/apache/sis/math/Line.java            |  2 +-
 .../src/main/java/org/apache/sis/math/MathFunctions.java   |  4 ++--
 .../src/main/java/org/apache/sis/math/Plane.java           |  6 +++---
 .../src/main/java/org/apache/sis/math/SequenceVector.java  |  4 ++--
 .../src/main/java/org/apache/sis/math/Vector.java          |  2 +-
 .../apache/sis/internal/converter/AngleConverterTest.java  |  4 ++--
 .../src/test/java/org/apache/sis/util/NumbersTest.java     |  2 +-
 .../java/org/apache/sis/util/collection/CacheTest.java     |  3 ++-
 .../org/apache/sis/util/collection/WeakHashSetTest.java    |  2 +-
 .../apache/sis/util/collection/WeakValueHashMapTest.java   |  9 +++++----
 17 files changed, 50 insertions(+), 47 deletions(-)

diff --git a/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
b/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
index 23bb329..9e3b8d8 100644
--- a/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
+++ b/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
@@ -1140,7 +1140,7 @@ public class MilitaryGridReferenceSystem extends ReferencingByIdentifiers
{
          */
         @Override
         public long estimateSize() {
-            return (xEnd - (long) gridX) * Math.abs(yEnd - (long) yStart) / (step * (long)
step);
+            return (xEnd - (long) gridX) * Math.abs(yEnd - (long) yStart) / Math.multiplyFull(step,
step);
         }
 
         /**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java
index 6590e61..86522b6 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java
@@ -508,9 +508,9 @@ public abstract class DatumShiftGrid<C extends Quantity<C>, T
extends Quantity<T
         for (int dim = 0; dim < n; dim++) {
             double r0 = getCellValue(dim, ix, iy  );
             double r1 = getCellValue(dim, ix, iy+1);
-            r0 +=  gridX * (getCellValue(dim, ix+1, iy  ) - r0);
-            r1 +=  gridX * (getCellValue(dim, ix+1, iy+1) - r1);
-            vector[dim] = gridY * (r1 - r0) + r0;
+            r0 = Math.fma(gridX, getCellValue(dim, ix+1, iy  ) - r0, r0);
+            r1 = Math.fma(gridX, getCellValue(dim, ix+1, iy+1) - r1, r1);
+            vector[dim] = Math.fma(gridY, r1 - r0, r0);
         }
     }
 
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LinearInterpolator1D.java
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LinearInterpolator1D.java
index ae8421c..e3578fd 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LinearInterpolator1D.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LinearInterpolator1D.java
@@ -234,19 +234,19 @@ final class LinearInterpolator1D extends AbstractMathTransform1D implements
Seri
                 x -= i;
                 final double y0 = values[i  ];
                 final double y1 = values[i+1];
-                y = y0 * (1-x) + y1 * x;
+                y = Math.fma(y1, x, y0 * (1-x));
                 d = y1 - y0;
             } else {
                 // x is after the last available value.
                 final double y1 = values[n];
                 d = y1 - values[n-1];
-                y = (x - n) * d + y1;
+                y = Math.fma(x-n, d, y1);
             }
         } else {
             // x is before the first available value.
             final double y0 = values[0];
             d = values[1] - y0;
-            y = x * d + y0;
+            y = Math.fma(x, d, y0);
         }
         if (dstPts != null) {
             dstPts[dstOff] = y;
@@ -266,16 +266,16 @@ final class LinearInterpolator1D extends AbstractMathTransform1D implements
Seri
             final int n = values.length - 1;
             if (i < n) {
                 x -= i;
-                return values[i] * (1-x) + values[i+1] * x;
+                return Math.fma(values[i+1], x, values[i] * (1-x));
             } else {
                 // x is after the last available value.
                 final double y1 = values[n];
-                return (x - n) * (y1 - values[n-1]) + y1;
+                return Math.fma(x-n, y1 - values[n-1], y1);
             }
         } else {
             // x is before the first available value.
             final double y0 = values[0];
-            return x * (values[1] - y0) + y0;
+            return Math.fma(x, values[1] - y0, y0);
         }
     }
 
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LinearTransform1D.java
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LinearTransform1D.java
index f48965a..7111689 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LinearTransform1D.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LinearTransform1D.java
@@ -246,7 +246,7 @@ class LinearTransform1D extends AbstractMathTransform1D implements LinearTransfo
                             final boolean derivate)
     {
         if (dstPts != null) {
-            dstPts[dstOff] = offset + scale*srcPts[srcOff];
+            dstPts[dstOff] = Math.fma(srcPts[srcOff], scale, offset);
         }
         return derivate ? new Matrix1(scale) : null;
     }
@@ -261,13 +261,13 @@ class LinearTransform1D extends AbstractMathTransform1D implements LinearTransfo
     {
         if (srcPts != dstPts || srcOff >= dstOff) {
             while (--numPts >= 0) {
-                dstPts[dstOff++] = offset + scale * srcPts[srcOff++];
+                dstPts[dstOff++] = Math.fma(srcPts[srcOff++], scale, offset);
             }
         } else {
             srcOff += numPts;
             dstOff += numPts;
             while (--numPts >= 0) {
-                dstPts[--dstOff] = offset + scale * srcPts[--srcOff];
+                dstPts[--dstOff] = Math.fma(srcPts[--srcOff], scale, offset);
             }
         }
     }
@@ -283,13 +283,13 @@ class LinearTransform1D extends AbstractMathTransform1D implements LinearTransfo
     {
         if (srcPts != dstPts || srcOff >= dstOff) {
             while (--numPts >= 0) {
-                dstPts[dstOff++] = (float) (offset + scale * srcPts[srcOff++]);
+                dstPts[dstOff++] = (float) Math.fma(srcPts[srcOff++], scale, offset);
             }
         } else {
             srcOff += numPts;
             dstOff += numPts;
             while (--numPts >= 0) {
-                dstPts[--dstOff] = (float) (offset + scale * srcPts[--srcOff]);
+                dstPts[--dstOff] = (float) Math.fma(srcPts[--srcOff], scale, offset);
             }
         }
     }
@@ -304,7 +304,7 @@ class LinearTransform1D extends AbstractMathTransform1D implements LinearTransfo
                           final float [] dstPts, int dstOff, int numPts)
     {
         while (--numPts >= 0) {
-            dstPts[dstOff++] = (float) (offset + scale * srcPts[srcOff++]);
+            dstPts[dstOff++] = (float) Math.fma(srcPts[srcOff++], scale, offset);
         }
     }
 
@@ -317,7 +317,7 @@ class LinearTransform1D extends AbstractMathTransform1D implements LinearTransfo
                           final double[] dstPts, int dstOff, int numPts)
     {
         while (--numPts >= 0) {
-            dstPts[dstOff++] = offset + scale * srcPts[srcOff++];
+            dstPts[dstOff++] = Math.fma(srcPts[srcOff++], scale, offset);
         }
     }
 
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java
index 6a61047..f3cb278 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java
@@ -259,7 +259,7 @@ class ProjectiveTransform extends AbstractLinearTransform implements ExtendedPre
                          * getting 2D points from 3D points. In such case, the fact that
the excluded dimensions had
                          * NaN values should not force the retained dimensions to get NaN
values.
                          */
-                        sum += srcPts[srcOff + i] * e;
+                        sum = Math.fma(srcPts[srcOff + i], e, sum);
                     }
                 }
                 buffer[j] = sum;
@@ -322,8 +322,8 @@ class ProjectiveTransform extends AbstractLinearTransform implements ExtendedPre
                 double sum = elt[mix + srcDim];
                 for (int i=0; i<srcDim; i++) {
                     final double e = elt[mix++];
-                    if (e != 0) { // See comment in transform(double[], ...)
-                        sum += srcPts[srcOff + i] * e;
+                    if (e != 0) {                                   // See comment in transform(double[],
...)
+                        sum = Math.fma(srcPts[srcOff + i], e, sum);
                     }
                 }
                 buffer[j] = sum;
@@ -359,7 +359,7 @@ class ProjectiveTransform extends AbstractLinearTransform implements ExtendedPre
                 for (int i=0; i<srcDim; i++) {
                     final double e = elt[mix++];
                     if (e != 0) {                                   // See comment in transform(double[],
...)
-                        sum += srcPts[srcOff + i] * e;
+                        sum = Math.fma(srcPts[srcOff + i], e, sum);
                     }
                 }
                 buffer[j] = sum;
@@ -394,7 +394,7 @@ class ProjectiveTransform extends AbstractLinearTransform implements ExtendedPre
                 for (int i=0; i<srcDim; i++) {
                     final double e = elt[mix++];
                     if (e != 0) {                                   // See comment in transform(double[],
...)
-                        sum += srcPts[srcOff + i] * e;
+                        sum = Math.fma(srcPts[srcOff + i], e, sum);
                     }
                 }
                 buffer[j] = sum;
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java
index db1efbb..6a5b9f4 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java
@@ -559,7 +559,7 @@ public final strictfp class CoordinateOperationFinderTest extends MathTransformT
         assertInstanceOf("operation", Conversion.class, operation);
 
         transform = operation.getMathTransform();
-        tolerance = 1E-12;
+        tolerance = 1E-11;
         verifyTransform(new double[] {
             // December 31, 1899 at 12:00 UTC in seconds.
             CommonCRS.Temporal.DUBLIN_JULIAN.datum().getOrigin().getTime() / 1000
@@ -878,7 +878,7 @@ public final strictfp class CoordinateOperationFinderTest extends MathTransformT
             0, 0, 0, 1
         }), ((LinearTransform) transform).getMatrix(), 1E-12);
 
-        tolerance = 1E-12;
+        tolerance = 1E-6;
         verifyTransform(new double[] {
             -5, -8, CommonCRS.Temporal.DUBLIN_JULIAN.datum().getOrigin().getTime() / 1000
         }, new double[] {
diff --git a/core/sis-utility/src/main/java/org/apache/sis/math/Fraction.java b/core/sis-utility/src/main/java/org/apache/sis/math/Fraction.java
index e529914..2c69ab5 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/math/Fraction.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/math/Fraction.java
@@ -210,8 +210,8 @@ public final class Fraction extends Number implements Comparable<Fraction>,
Seri
      * @throws ArithmeticException if the result overflows.
      */
     public Fraction multiply(final Fraction other) {
-        return simplify(numerator   * (long) other.numerator,
-                        denominator * (long) other.denominator);
+        return simplify(Math.multiplyFull(numerator,   other.numerator),
+                        Math.multiplyFull(denominator, other.denominator));
     }
 
     /**
@@ -222,8 +222,8 @@ public final class Fraction extends Number implements Comparable<Fraction>,
Seri
      * @throws ArithmeticException if the result overflows.
      */
     public Fraction divide(final Fraction other) {
-        return simplify(numerator   * (long) other.denominator,
-                        denominator * (long) other.numerator);
+        return simplify(Math.multiplyFull(numerator,   other.denominator),
+                        Math.multiplyFull(denominator, other.numerator));
     }
 
     /**
@@ -397,7 +397,8 @@ public final class Fraction extends Number implements Comparable<Fraction>,
Seri
      */
     @Override
     public int compareTo(final Fraction other) {
-        return Long.signum(numerator * (long) other.denominator - other.numerator * (long)
denominator);
+        return Long.signum(Math.multiplyFull(numerator, other.denominator)
+                         - Math.multiplyFull(other.numerator, denominator));
     }
 
     /**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/math/Line.java b/core/sis-utility/src/main/java/org/apache/sis/math/Line.java
index 6c0fae9..05384bf 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/math/Line.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/math/Line.java
@@ -160,7 +160,7 @@ public class Line implements Cloneable, Serializable {
      * @see #x(double)
      */
     public final double y(final double x) {
-        return y0 + x*slope;
+        return Math.fma(x, slope, y0);
     }
 
     /**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java b/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
index 51c49cd..77fd400 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
@@ -326,7 +326,7 @@ public final class MathFunctions extends Static {
      * @since 0.6
      */
     public static double asinh(final double x) {
-        return Math.log(x + Math.sqrt(x*x + 1));
+        return Math.log(x + Math.sqrt(Math.fma(x,x, 1)));
     }
 
     /**
@@ -341,7 +341,7 @@ public final class MathFunctions extends Static {
      * @since 0.6
      */
     public static double acosh(final double x) {
-        return Math.log(x + Math.sqrt(x*x - 1));
+        return Math.log(x + Math.sqrt(Math.fma(x,x, -1)));
     }
 
     /**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/math/Plane.java b/core/sis-utility/src/main/java/org/apache/sis/math/Plane.java
index 1b959f0..2241753 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/math/Plane.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/math/Plane.java
@@ -167,7 +167,7 @@ public class Plane implements Cloneable, Serializable {
      * @return  the <var>x</var> value.
      */
     public final double x(final double y, final double z) {
-        return (z - (z0 + sy*y)) / sx;
+        return (z - Math.fma(y, sy, z0)) / sx;
     }
 
     /**
@@ -181,7 +181,7 @@ public class Plane implements Cloneable, Serializable {
      * @return  the <var>y</var> value.
      */
     public final double y(final double x, final double z) {
-        return (z - (z0 + sx*x)) / sy;
+        return (z - Math.fma(x, sx, z0)) / sy;
     }
 
     /**
@@ -197,7 +197,7 @@ public class Plane implements Cloneable, Serializable {
      * @see #z0()
      */
     public final double z(final double x, final double y) {
-        return z0 + sx*x + sy*y;
+        return Math.fma(x, sx, Math.fma(y, sy, z0));
     }
 
     /**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/math/SequenceVector.java b/core/sis-utility/src/main/java/org/apache/sis/math/SequenceVector.java
index 8d25e48..b022dc2 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/math/SequenceVector.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/math/SequenceVector.java
@@ -183,7 +183,7 @@ abstract class SequenceVector extends Vector implements Serializable {
         /** Computes the value at the given index. */
         @Override public double doubleValue(final int index) {
             ArgumentChecks.ensureValidIndex(length, index);
-            return first + increment*index;
+            return Math.fma(index, increment, first);
         }
 
         /** Computes the value at the given index. */
@@ -210,7 +210,7 @@ abstract class SequenceVector extends Vector implements Serializable {
         @SuppressWarnings({"unchecked","rawtypes"})
         @Override public NumberRange<?> range() {
             double min = first;
-            double max = first + increment * (length - 1);
+            double max = Math.fma(length-1, increment, first);
             if (max < min) {
                 min = max;
                 max = first;
diff --git a/core/sis-utility/src/main/java/org/apache/sis/math/Vector.java b/core/sis-utility/src/main/java/org/apache/sis/math/Vector.java
index 0bda53f..cc93fa1 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/math/Vector.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/math/Vector.java
@@ -173,7 +173,7 @@ public abstract class Vector extends AbstractList<Number> implements
RandomAcces
         Class<? extends Number> type;
         type = Numbers.widestClass(first, increment);
         type = Numbers.widestClass(type,
-               Numbers.narrowestClass(first.doubleValue() + increment.doubleValue() * (length-1)));
+               Numbers.narrowestClass(Math.fma(length-1, increment.doubleValue(), first.doubleValue())));
         return createSequence(type, first, increment, length);
     }
 
diff --git a/core/sis-utility/src/test/java/org/apache/sis/internal/converter/AngleConverterTest.java
b/core/sis-utility/src/test/java/org/apache/sis/internal/converter/AngleConverterTest.java
index 4878194..78eeabf 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/internal/converter/AngleConverterTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/internal/converter/AngleConverterTest.java
@@ -37,12 +37,12 @@ public final strictfp class AngleConverterTest extends TestCase {
      * Tests conversions to {@link Double}.
      */
     @Test
-    @SuppressWarnings("UnnecessaryBoxing")
     public void testDouble() {
         final ObjectConverter<Angle,Double> c1 = AngleConverter.INSTANCE;
         final ObjectConverter<Double,Angle> c2 = AngleConverter.Inverse.INSTANCE;
-        final Angle  v1 = new Angle (30.25);
+        @SuppressWarnings({"UnnecessaryBoxing", "deprecation"})
         final Double v2 = new Double(30.25);
+        final Angle  v1 = new Angle (30.25);
         assertEquals(v2, c1.apply(v1));
         assertEquals(v1, c2.apply(v2));
         assertSame(c2, c1.inverse());
diff --git a/core/sis-utility/src/test/java/org/apache/sis/util/NumbersTest.java b/core/sis-utility/src/test/java/org/apache/sis/util/NumbersTest.java
index 370c737..a8697e3 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/util/NumbersTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/util/NumbersTest.java
@@ -187,7 +187,7 @@ public final strictfp class NumbersTest extends TestCase {
      */
     @Test
     public void testCast() {
-        @SuppressWarnings("UnnecessaryBoxing")
+        @SuppressWarnings({"UnnecessaryBoxing", "deprecation"})
         final Integer value = new Integer(10); // Intentionally a new instance.
         assertEquals(Byte   .valueOf((byte)   10), cast(value, Byte   .class));
         assertEquals(Short  .valueOf((short)  10), cast(value, Short  .class));
diff --git a/core/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java
b/core/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java
index 7ea2c7c..295334b 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java
@@ -228,10 +228,11 @@ public final strictfp class CacheTest extends TestCase {
             /**
              * Puts random values in the map.
              */
-            @SuppressWarnings({"UnnecessaryBoxing", "CallToThreadYield", "NumberEquality"})
+            @SuppressWarnings({"CallToThreadYield", "NumberEquality"})
             @Override public void run() {
                 for (int i=0; i<count; i++) {
                     final Integer key = i;
+                    @SuppressWarnings({"UnnecessaryBoxing", "deprecation"})
                     final Integer expected = new Integer(i * i);        // We really want
new instance.
                     final Integer value;
                     try {
diff --git a/core/sis-utility/src/test/java/org/apache/sis/util/collection/WeakHashSetTest.java
b/core/sis-utility/src/test/java/org/apache/sis/util/collection/WeakHashSetTest.java
index 92132ca..68e6fb6 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/util/collection/WeakHashSetTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/util/collection/WeakHashSetTest.java
@@ -104,7 +104,7 @@ public final strictfp class WeakHashSetTest extends TestCase {
             final WeakHashSet<Integer> weakSet = new WeakHashSet<>(Integer.class);
             final HashSet<Integer> strongSet = new HashSet<>();
             for (int i=0; i<SAMPLE_SIZE; i++) {
-                @SuppressWarnings("UnnecessaryBoxing")
+                @SuppressWarnings({"UnnecessaryBoxing", "deprecation"})
                 final Integer value = new Integer(random.nextInt(SAMPLE_SIZE));         //
Really need new instances
                 if (random.nextBoolean()) {
                     /*
diff --git a/core/sis-utility/src/test/java/org/apache/sis/util/collection/WeakValueHashMapTest.java
b/core/sis-utility/src/test/java/org/apache/sis/util/collection/WeakValueHashMapTest.java
index f779ce3..38c3749 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/util/collection/WeakValueHashMapTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/util/collection/WeakValueHashMapTest.java
@@ -108,7 +108,6 @@ public final strictfp class WeakValueHashMapTest extends TestCase {
      *
      * @param weakMap The map implementation to test.
      */
-    @SuppressWarnings("UnnecessaryBoxing")
     static void testWeakReferences(final Map<Integer,Integer> weakMap) throws InterruptedException
{
         final Random random = new Random();
         for (int pass=0; pass<NUM_RETRY; pass++) {
@@ -118,8 +117,9 @@ public final strictfp class WeakValueHashMapTest extends TestCase {
                 /*
                  * We really want new instances here.
                  */
-                final Integer key   = new Integer(random.nextInt(SAMPLE_SIZE));
-                final Integer value = new Integer(random.nextInt(SAMPLE_SIZE));
+                @SuppressWarnings({"UnnecessaryBoxing", "deprecation"})
+                final Integer key   = new Integer(random.nextInt(SAMPLE_SIZE)),
+                              value = new Integer(random.nextInt(SAMPLE_SIZE));
                 if (random.nextBoolean()) {
                     /*
                      * Tests addition.
@@ -205,9 +205,10 @@ public final strictfp class WeakValueHashMapTest extends TestCase {
     @SuppressWarnings("UnnecessaryBoxing")
     public void testIdentityComparisons() {
         final WeakValueHashMap<Integer,Integer> weakMap = new WeakValueHashMap<>(Integer.class,
true);
+        @SuppressWarnings({"UnnecessaryBoxing", "deprecation"})
+        final Integer k3 = new Integer(10);                             // Really want a
new instance.
         final Integer k1 = 10;
         final Integer k2 = 20;
-        final Integer k3 = new Integer(10);         // Really want a new instance.
         final Integer v1 = 1;
         final Integer v2 = 2;
         final Integer v3 = 3;


Mime
View raw message