sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1822268 [4/7] - in /sis/trunk: ./ application/sis-console/src/main/java/org/apache/sis/console/ application/sis-javafx/ core/sis-build-helper/ core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/ core/sis-build-helper/src/ma...
Date Fri, 26 Jan 2018 10:48:29 GMT
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/PackedVector.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/PackedVector.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/PackedVector.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/PackedVector.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -20,9 +20,6 @@ import org.apache.sis.util.Numbers;
 import org.apache.sis.util.collection.IntegerList;
 import org.apache.sis.util.resources.Errors;
 
-// Branch-dependent imports
-import org.apache.sis.internal.jdk8.JDK8;
-
 
 /**
  * A vector of integer values backed by an {@link IntegerList}.
@@ -74,7 +71,7 @@ final class PackedVector extends ArrayVe
         final int length = source.size();
         data = new IntegerList(length, delta, true);
         for (int i=0; i<length; i++) {
-            data.setInt(i, JDK8.toIntExact((source.longValue(i) - offset) / increment));
+            data.setInt(i, Math.toIntExact((source.longValue(i) - offset) / increment));
         }
     }
 

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Plane.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Plane.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Plane.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Plane.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -29,9 +29,6 @@ import static java.lang.Math.abs;
 import static java.lang.Math.sqrt;
 import static java.lang.Math.ulp;
 
-// Branch-dependent imports
-import org.apache.sis.internal.jdk8.JDK8;
-
 
 /**
  * Equation of a plane in a three-dimensional space (<var>x</var>,<var>y</var>,<var>z</var>).
@@ -322,7 +319,7 @@ public class Plane implements Cloneable,
         ArgumentChecks.ensureStrictlyPositive("nx", nx);
         ArgumentChecks.ensureStrictlyPositive("ny", ny);
         ArgumentChecks.ensureNonNull("z", z);
-        final int length = JDK8.multiplyExact(nx, ny);
+        final int length = Math.multiplyExact(nx, ny);
         if (z.size() != length) {
             throw new IllegalArgumentException(Errors.format(Errors.Keys.UnexpectedArrayLength_2, length, z.size()));
         }

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Statistics.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Statistics.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Statistics.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Statistics.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -28,8 +28,8 @@ import static java.lang.Double.isNaN;
 import static java.lang.Double.doubleToLongBits;
 
 // Branch-dependent imports
-import org.apache.sis.internal.jdk8.LongConsumer;
-import org.apache.sis.internal.jdk8.DoubleConsumer;
+import java.util.function.LongConsumer;
+import java.util.function.DoubleConsumer;
 
 
 /**

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Vector.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Vector.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Vector.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Vector.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -20,6 +20,7 @@ import java.io.Serializable;
 import java.util.Arrays;
 import java.util.AbstractList;
 import java.util.RandomAccess;
+import java.util.function.IntSupplier;
 import org.apache.sis.measure.NumberRange;
 import org.apache.sis.util.Numbers;
 import org.apache.sis.util.ArgumentChecks;
@@ -27,8 +28,6 @@ import org.apache.sis.util.logging.Loggi
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.internal.system.Loggers;
 import org.apache.sis.internal.util.Numerics;
-import org.apache.sis.internal.jdk8.IntSupplier;
-import org.apache.sis.internal.jdk8.JDK8;
 
 import static org.apache.sis.util.ArgumentChecks.ensureValidIndex;
 
@@ -109,7 +108,7 @@ public abstract class Vector extends Abs
      *
      * <div class="section">Unsigned integers</div>
      * Java has no primitive support for unsigned integers. But some file formats use unsigned integers,
-     * which can be simulated in Java by the use of bit masks or methods like {@code Integer.toUnsignedLong(int)}.
+     * which can be simulated in Java by the use of bit masks or methods like {@link Integer#toUnsignedLong(int)}.
      * This {@code Vector} class applies automatically those masks (unless otherwise noticed in method Javadoc)
      * if the {@code isUnsigned} argument is {@code true}.
      * That argument applies only to {@code byte[]}, {@code short[]}, {@code int[]} or {@code long[]} arrays
@@ -468,7 +467,7 @@ public abstract class Vector extends Abs
     final long subtract(final long a, final long b) {
         final long inc = a - b;
         // The sign of the difference shall be the same than the sign of Long.compare(…).
-        if ((((isUnsigned() ? JDK8.compareUnsigned(a, b) : Long.compare(a, b)) ^ inc) & Long.MIN_VALUE) != 0) {
+        if ((((isUnsigned() ? Long.compareUnsigned(a, b) : Long.compare(a, b)) ^ inc) & Long.MIN_VALUE) != 0) {
             throw new ArithmeticException();
         }
         return inc;
@@ -722,11 +721,7 @@ public abstract class Vector extends Abs
         /** Delegates to the enclosing vector */
         @Override NumberRange<?> range(final IntSupplier indices, final int n) {
             if (indices != null) {
-                return Vector.this.range(new IntSupplier() {
-                    @Override public int getAsInt() {
-                        return toBacking(indices.getAsInt());
-                    }
-                }, n);
+                return Vector.this.range(() -> toBacking(indices.getAsInt()), n);
             }
             IntSupplier supplier = null;
             if (first != 0 || step != 1) {
@@ -901,11 +896,7 @@ public abstract class Vector extends Abs
         /** Delegates to the enclosing vector. */
         @Override NumberRange<?> range(final IntSupplier supplier, final int n) {
             if (supplier != null) {
-                return Vector.this.range(new IntSupplier() {
-                    @Override public int getAsInt() {
-                        return indices[supplier.getAsInt()];
-                    }
-                }, n);
+                return Vector.this.range(() -> indices[supplier.getAsInt()], n);
             } else {
                 return Vector.this.range(new IntSupplier() {
                     private int index;

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -40,9 +40,6 @@ import static org.apache.sis.math.MathFu
 import static org.apache.sis.math.MathFunctions.isNegative;
 import static org.apache.sis.math.DecimalFunctions.fractionDigitsForDelta;
 
-// Branch-dependent imports
-import org.apache.sis.internal.jdk8.JDK8;
-
 
 /**
  * Parses and formats angles according a specified pattern. The pattern is a string
@@ -971,7 +968,7 @@ public class AngleFormat extends Format
     public StringBuffer format(final double angle, StringBuffer toAppendTo, final FieldPosition pos) {
         final int offset = toAppendTo.length();
         final int fieldPos = getField(pos);
-        if (!JDK8.isFinite(angle)) {
+        if (!Double.isFinite(angle)) {
             toAppendTo = numberFormat().format(angle, toAppendTo, dummyFieldPosition());
             if (fieldPos >= DEGREES_FIELD && fieldPos <= SECONDS_FIELD) {
                 pos.setBeginIndex(offset);
@@ -1113,7 +1110,7 @@ public class AngleFormat extends Format
                 }
                 final Number userObject;
                 if (hasMore) {
-                    userObject = JDK8.toIntExact(Math.round(value));
+                    userObject = Math.toIntExact(Math.round(value));
                 } else {
                     /*
                      * Use Float instead of Double because we don't want to give a false impression of accuracy

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Scalar.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Scalar.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Scalar.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Scalar.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -289,8 +289,7 @@ abstract class Scalar<Q extends Quantity
      */
     @Override
     public final int hashCode() {
-        final long bits = Double.doubleToLongBits(value);
-        return ((int) (bits ^ (bits >>> 32))) ^ unit.hashCode();
+        return Double.hashCode(value) ^ unit.hashCode();
     }
 
     /**

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/SystemUnit.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/SystemUnit.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/SystemUnit.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/SystemUnit.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -104,14 +104,13 @@ final class SystemUnit<Q extends Quantit
      * Returns a unit of the given dimension with default name and symbol.
      * This method is invoked for creating the result of arithmetic operations.
      */
-    @SuppressWarnings({"unchecked","rawtypes"})
     private SystemUnit<?> create(final UnitDimension dim) {
         if (dim == dimension) {
             return this;
         }
         SystemUnit<?> result = Units.get(dim);
         if (result == null) {
-            result = new SystemUnit(null, dim, null, (byte) 0, (short) 0, null);
+            result = new SystemUnit<>(null, dim, null, (byte) 0, (short) 0, null);
         }
         return result;
     }

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/UnitDimension.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/UnitDimension.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/UnitDimension.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/UnitDimension.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -30,10 +30,6 @@ import org.apache.sis.util.UnsupportedIm
 import org.apache.sis.internal.converter.FractionConverter;
 import org.apache.sis.internal.util.CollectionsExt;
 
-// Branch-dependent imports
-import org.apache.sis.internal.jdk8.JDK8;
-import org.apache.sis.internal.jdk8.BiFunction;
-
 
 /**
  * Dimension (length, mass, time, <i>etc.</i>) of a unit of measurement.
@@ -71,7 +67,7 @@ final class UnitDimension implements Dim
     /**
      * Pseudo-dimension for dimensionless units.
      */
-    static final UnitDimension NONE = new UnitDimension(Collections.<UnitDimension,Fraction>emptyMap());
+    static final UnitDimension NONE = new UnitDimension(Collections.emptyMap());
     // No need to store in UnitRegistry since UnitDimension performs special checks for dimensionless instances.
 
     /**
@@ -137,11 +133,7 @@ final class UnitDimension implements Dim
          */
         UnitDimension dim = (UnitDimension) UnitRegistry.get(components);
         if (dim == null) {
-            JDK8.replaceAll(components, new BiFunction<UnitDimension,Fraction,Fraction>() {
-                @Override public Fraction apply(UnitDimension c, Fraction power) {
-                    return power.unique();
-                }
-            });
+            components.replaceAll((c, power) -> power.unique());
             components = CollectionsExt.unmodifiableOrCopy(components);
             dim = new UnitDimension(components);
             if (!Units.initialized) {
@@ -252,11 +244,9 @@ final class UnitDimension implements Dim
                 p = p.negate();
             }
             if (dim instanceof UnitDimension) {
-                JDK8.merge(product, (UnitDimension) dim, p, new BiFunction<Fraction,Fraction,Fraction>() {
-                    @Override public Fraction apply(Fraction sum, Fraction toAdd) {
-                        sum = sum.add(toAdd);
-                        return (sum.numerator != 0) ? sum : null;
-                    }
+                product.merge((UnitDimension) dim, p, (sum, toAdd) -> {
+                    sum = sum.add(toAdd);
+                    return (sum.numerator != 0) ? sum : null;
                 });
             } else if (p.numerator != 0) {
                 throw new UnsupportedImplementationException(Errors.format(Errors.Keys.UnsupportedImplementation_1, dim.getClass()));
@@ -273,11 +263,7 @@ final class UnitDimension implements Dim
      */
     private UnitDimension pow(final Fraction n) {
         final Map<UnitDimension,Fraction> product = new LinkedHashMap<>(components);
-        JDK8.replaceAll(product, new BiFunction<UnitDimension,Fraction,Fraction>() {
-            @Override public Fraction apply(UnitDimension dim, Fraction power) {
-                return power.multiply(n);
-            }
-        });
+        product.replaceAll((dim, power) -> power.multiply(n));
         return create(product);
     }
 

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/UnitServices.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/UnitServices.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/UnitServices.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/UnitServices.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -117,7 +117,7 @@ public class UnitServices extends Servic
      */
     @Override
     public Collection<SystemOfUnits> getAvailableSystemsOfUnits() {
-        return UnmodifiableArrayList.<SystemOfUnits>wrap(systems);
+        return UnmodifiableArrayList.wrap(systems);
     }
 
     /**

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -1090,19 +1090,17 @@ public final class Units extends Static
         final UnitDimension dimensionless = UnitDimension.NONE;
         /*
          * Base, derived or alternate units that we need to reuse more than once in this static initializer.
-         * Note: JDK8 branch uses much more compact method references instead than following inner classes.
          */
-        ScalarFactory<Dimensionless> dimensionlessFactory =            new ScalarFactory<Dimensionless>() {@Override public Dimensionless create(double value, Unit<Dimensionless> unit) {return new Scalar.Dimensionless(value, unit);}};
-        final SystemUnit<Length>        m   = add(Length.class,        new ScalarFactory<Length>       () {@Override public Length        create(double value, Unit<Length>        unit) {return new Scalar.Length       (value, unit);}}, length,        "m",   (byte) (SI | PREFIXABLE), Constants.EPSG_METRE);
-        final SystemUnit<Area>          m2  = add(Area.class,          new ScalarFactory<Area>         () {@Override public Area          create(double value, Unit<Area>          unit) {return new Scalar.Area         (value, unit);}}, area,          "m²",  (byte) (SI | PREFIXABLE), (short) 0);
-        final SystemUnit<Volume>        m3  = add(Volume.class,        new ScalarFactory<Volume>       () {@Override public Volume        create(double value, Unit<Volume>        unit) {return new Scalar.Volume       (value, unit);}}, length.pow(3), "m³",  (byte) (SI | PREFIXABLE), (short) 0);
-        final SystemUnit<Time>          s   = add(Time.class,          new ScalarFactory<Time>         () {@Override public Time          create(double value, Unit<Time>          unit) {return new Scalar.Time         (value, unit);}}, time,          "s",   (byte) (SI | PREFIXABLE), (short) 1040);
-        final SystemUnit<Temperature>   K   = add(Temperature.class,   new ScalarFactory<Temperature>  () {@Override public Temperature   create(double value, Unit<Temperature>   unit) {return new Scalar.Temperature  (value, unit);}}, temperature,   "K",   (byte) (SI | PREFIXABLE), (short) 0);
-        final SystemUnit<Speed>         mps = add(Speed.class,         new ScalarFactory<Speed>        () {@Override public Speed         create(double value, Unit<Speed>         unit) {return new Scalar.Speed        (value, unit);}}, speed,         "m∕s", (byte) (SI | PREFIXABLE), (short) 1026);
-        final SystemUnit<Pressure>      Pa  = add(Pressure.class,      new ScalarFactory<Pressure>     () {@Override public Pressure      create(double value, Unit<Pressure>      unit) {return new Scalar.Pressure     (value, unit);}}, pressure,      "Pa",  (byte) (SI | PREFIXABLE), (short) 0);
-        final SystemUnit<Angle>         rad = add(Angle.class,         new ScalarFactory<Angle>        () {@Override public Angle         create(double value, Unit<Angle>         unit) {return new Scalar.Angle        (value, unit);}}, dimensionless, "rad", (byte) (SI | PREFIXABLE), (short) 9101);
-        final SystemUnit<Mass>          kg  = add(Mass.class,          new ScalarFactory<Mass>         () {@Override public Mass          create(double value, Unit<Mass>          unit) {return new Scalar.Mass         (value, unit);}}, mass,          "kg",          SI,               (short) 0);
-        final SystemUnit<Dimensionless> one = add(Dimensionless.class, dimensionlessFactory, dimensionless, "", UnitRegistry.SI, (short) 9201);
+        final SystemUnit<Length>        m   = add(Length.class,        Scalar.Length::new,        length,        "m",   (byte) (SI | PREFIXABLE), Constants.EPSG_METRE);
+        final SystemUnit<Area>          m2  = add(Area.class,          Scalar.Area::new,          area,          "m²",  (byte) (SI | PREFIXABLE), (short) 0);
+        final SystemUnit<Volume>        m3  = add(Volume.class,        Scalar.Volume::new,        length.pow(3), "m³",  (byte) (SI | PREFIXABLE), (short) 0);
+        final SystemUnit<Time>          s   = add(Time.class,          Scalar.Time::new,          time,          "s",   (byte) (SI | PREFIXABLE), (short) 1040);
+        final SystemUnit<Temperature>   K   = add(Temperature.class,   Scalar.Temperature::new,   temperature,   "K",   (byte) (SI | PREFIXABLE), (short) 0);
+        final SystemUnit<Speed>         mps = add(Speed.class,         Scalar.Speed::new,         speed,         "m∕s", (byte) (SI | PREFIXABLE), (short) 1026);
+        final SystemUnit<Pressure>      Pa  = add(Pressure.class,      Scalar.Pressure::new,      pressure,      "Pa",  (byte) (SI | PREFIXABLE), (short) 0);
+        final SystemUnit<Angle>         rad = add(Angle.class,         Scalar.Angle::new,         dimensionless, "rad", (byte) (SI | PREFIXABLE), (short) 9101);
+        final SystemUnit<Dimensionless> one = add(Dimensionless.class, Scalar.Dimensionless::new, dimensionless, "",            SI,               (short) 9201);
+        final SystemUnit<Mass>          kg  = add(Mass.class,          Scalar.Mass::new,          mass,          "kg",          SI,               (short) 0);
         /*
          * All SI prefix to be used below, with additional converters to be used more than once.
          */
@@ -1197,13 +1195,11 @@ public final class Units extends Static
         /*
          * Force, energy, electricity, magnetism and other units.
          * Frequency must be defined after angular velocities.
-         *
-         * Note: JDK8 branch uses method references instead than inner classes.
          */
-        HERTZ      = add(Frequency.class, new ScalarFactory<Frequency>() {@Override public Frequency create(double value, Unit<Frequency> unit) {return new Scalar.Frequency(value, unit);}}, frequency, "Hz", (byte) (SI | PREFIXABLE), (short) 0);
-        NEWTON     = add(Force.class,     new ScalarFactory<Force>    () {@Override public Force     create(double value, Unit<Force>     unit) {return new Scalar.Force    (value, unit);}}, force,     "N",  (byte) (SI | PREFIXABLE), (short) 0);
-        JOULE      = add(Energy.class,    new ScalarFactory<Energy>   () {@Override public Energy    create(double value, Unit<Energy>    unit) {return new Scalar.Energy   (value, unit);}}, energy,    "J",  (byte) (SI | PREFIXABLE), (short) 0);
-        WATT       = add(Power.class,     new ScalarFactory<Power>    () {@Override public Power     create(double value, Unit<Power>     unit) {return new Scalar.Power    (value, unit);}}, power,     "W",  (byte) (SI | PREFIXABLE), (short) 0);
+        HERTZ      = add(Frequency.class,           Scalar.Frequency::new, frequency,                    "Hz",  (byte) (SI | PREFIXABLE), (short) 0);
+        NEWTON     = add(Force.class,               Scalar.Force::new,     force,                        "N",   (byte) (SI | PREFIXABLE), (short) 0);
+        JOULE      = add(Energy.class,              Scalar.Energy::new,    energy,                       "J",   (byte) (SI | PREFIXABLE), (short) 0);
+        WATT       = add(Power.class,               Scalar.Power::new,     power,                        "W",   (byte) (SI | PREFIXABLE), (short) 0);
         AMPERE     = add(ElectricCurrent.class,     null,                  current,                      "A",   (byte) (SI | PREFIXABLE), (short) 0);
         COULOMB    = add(ElectricCharge.class,      null,                  charge,                       "C",   (byte) (SI | PREFIXABLE), (short) 0);
         VOLT       = add(ElectricPotential.class,   null,                  potential,                    "V",   (byte) (SI | PREFIXABLE), (short) 0);
@@ -1220,13 +1216,12 @@ public final class Units extends Static
         STERADIAN  = add(SolidAngle.class,          null,                  dimensionless,                "sr",  (byte) (SI | PREFIXABLE), (short) 0);
         /*
          * All Unit<Dimensionless>.
-         * Note: JDK8 branch uses method references instead than inner classes.
          */
-        PERCENT = add(one, centi,                                               "%",     OTHER, (short) 0);
-        PPM     = add(one, micro,                                               "ppm",   OTHER, (short) 9202);
-        PSU     = add(Salinity.class,      null,                 dimensionless, "psu",   OTHER, (short) 0);
-        SIGMA   = add(Dimensionless.class, dimensionlessFactory, dimensionless, "sigma", OTHER, (short) 0);
-        PIXEL   = add(Dimensionless.class, dimensionlessFactory, dimensionless, "px",    OTHER, (short) 0);
+        PERCENT = add(one, centi,                                                    "%",     OTHER, (short) 0);
+        PPM     = add(one, micro,                                                    "ppm",   OTHER, (short) 9202);
+        PSU     = add(Salinity.class,      null,                      dimensionless, "psu",   OTHER, (short) 0);
+        SIGMA   = add(Dimensionless.class, Scalar.Dimensionless::new, dimensionless, "sigma", OTHER, (short) 0);
+        PIXEL   = add(Dimensionless.class, Scalar.Dimensionless::new, dimensionless, "px",    OTHER, (short) 0);
         UNITY   = UnitRegistry.init(one);  // Must be last in order to take precedence over all other units associated to UnitDimension.NONE.
 
         UnitRegistry.alias(UNITY,       Short.valueOf((short) 9203));

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/ArgumentChecks.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/ArgumentChecks.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/ArgumentChecks.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/ArgumentChecks.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -407,9 +407,8 @@ public final class ArgumentChecks extend
      * @throws IllegalArgumentException if the given value is NaN or infinite.
      */
     public static void ensureFinite(final String name, final float value) {
-        final boolean isNaN;
-        if ((isNaN = Float.isNaN(value)) == true || Float.isInfinite(value)) {
-            throw new IllegalArgumentException(Errors.format(isNaN ?
+        if (!Float.isFinite(value)) {
+            throw new IllegalArgumentException(Errors.format(Float.isNaN(value) ?
                     Errors.Keys.NotANumber_1 : Errors.Keys.InfiniteArgumentValue_1, name));
         }
     }
@@ -424,9 +423,8 @@ public final class ArgumentChecks extend
      * @throws IllegalArgumentException if the given value is NaN or infinite.
      */
     public static void ensureFinite(final String name, final double value) {
-        final boolean isNaN;
-        if ((isNaN = Double.isNaN(value)) == true || Double.isInfinite(value)) {
-            throw new IllegalArgumentException(Errors.format(isNaN ?
+        if (!Double.isFinite(value)) {
+            throw new IllegalArgumentException(Errors.format(Double.isNaN(value) ?
                     Errors.Keys.NotANumber_1 : Errors.Keys.InfiniteArgumentValue_1, name));
         }
     }

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Classes.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Classes.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Classes.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Classes.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -405,7 +405,7 @@ next:       for (final Class<?> candidat
      *         at least one non-null element.
      */
     public static Class<?> findSpecializedClass(final Iterable<?> objects) {
-        final Set<Class<?>> types = (Set<Class<?>>) getClasses(objects);
+        final Set<Class<?>> types = getClasses(objects);
         types.remove(null);
         /*
          * Removes every classes in the types collection which are assignable from an other
@@ -457,7 +457,7 @@ next:       for (final Class<?> candidat
      *         given collection does not contain at least one non-null element.
      */
     public static Class<?> findCommonClass(final Iterable<?> objects) {
-        final Set<Class<?>> types = (Set<Class<?>>) getClasses(objects);
+        final Set<Class<?>> types = getClasses(objects);
         types.remove(null);
         return common(types);
     }

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -27,7 +27,7 @@ import org.apache.sis.util.resources.Voc
 import org.apache.sis.util.collection.BackingStoreException;
 
 // Branch-dependent imports
-import org.apache.sis.internal.jdk8.UncheckedIOException;
+import java.io.UncheckedIOException;
 
 
 /**

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Numbers.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Numbers.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Numbers.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Numbers.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -22,6 +22,7 @@ import java.util.List;
 import java.util.Queue;
 import java.util.Set;
 import java.util.SortedSet;
+import java.util.NavigableSet;
 import java.util.Collections;
 import java.lang.reflect.Array;
 import java.math.BigDecimal;
@@ -730,10 +731,11 @@ public final class Numbers extends Stati
                 return (T) mapping.nullValue;
             }
         } else if (type != null && type != Object.class) {
-            if (type == Map      .class) return (T) Collections.EMPTY_MAP;
-            if (type == List     .class) return (T) Collections.EMPTY_LIST;
-            if (type == Queue    .class) return (T) CollectionsExt.emptyQueue();
-            if (type == SortedSet.class) return (T) CollectionsExt.emptySortedSet();
+            if (type == Map         .class) return (T) Collections.EMPTY_MAP;
+            if (type == List        .class) return (T) Collections.EMPTY_LIST;
+            if (type == Queue       .class) return (T) CollectionsExt.emptyQueue();
+            if (type == SortedSet   .class) return (T) Collections.emptySortedSet();
+            if (type == NavigableSet.class) return (T) Collections.emptyNavigableSet();
             if (type.isAssignableFrom(Set.class)) {
                 return (T) Collections.EMPTY_SET;
             }

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/ObjectConverter.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/ObjectConverter.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/ObjectConverter.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/ObjectConverter.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -20,7 +20,7 @@ import java.util.Set;
 import org.apache.sis.math.FunctionProperty;
 
 // Branch-dependent imports
-import org.apache.sis.internal.jdk8.Function;
+import java.util.function.Function;
 
 
 /**

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -36,7 +36,9 @@ import org.apache.sis.internal.system.De
 import org.apache.sis.internal.system.ReferenceQueueConsumer;
 
 // Branch-dependent imports
-import org.apache.sis.internal.jdk8.Supplier;
+import java.util.function.Supplier;
+import java.util.function.Function;
+import java.util.function.BiFunction;
 
 
 /**
@@ -51,18 +53,14 @@ import org.apache.sis.internal.jdk8.Supp
  *   <li>Retain oldest values by soft or weak references instead of strong references.</li>
  * </ul>
  *
- * This class can be used by invoking
+ * The easiest way to use this class is to invoke {@link #computeIfAbsent computeIfAbsent(…)}
  * or {@link #getOrCreate getOrCreate(…)} with lambda functions as below:
  *
  * {@preformat java
  *     private final Cache<String,MyObject> cache = new Cache<String,MyObject>();
  *
  *     public MyObject getMyObject(String key) {
- *         try {
- *             return cache.getOrCreate(key, (k) -> createMyObject(k));
- *         } catch (Exception e) {
- *             // Decide here what to rethrow.
- *         }
+ *         return cache.computeIfAbsent(key, (k) -> createMyObject(k));
  *     }
  * }
  *
@@ -331,6 +329,55 @@ public class Cache<K,V> extends Abstract
     }
 
     /**
+     * Returns the value for the given key if it exists, or computes it otherwise.
+     * If a value already exists in the cache, then it is returned immediately.
+     * Otherwise the {@code creator.apply(Object)} method is invoked and its result
+     * is saved in this cache for future reuse.
+     *
+     * <div class="note"><b>Example:</b>
+     * below is the same code than {@link #getOrCreate(Object, Callable)} example,
+     * but without the need for any checked exception handling:
+     *
+     * {@preformat java
+     *     private final Cache<String,MyObject> cache = new Cache<String,MyObject>();
+     *
+     *     public MyObject getMyObject(final String key) {
+     *         return cache.computeIfAbsent(key, (k) -> createMyObject(k));
+     *     }
+     * }
+     * </div>
+     *
+     * This method is similar to {@link #getOrCreate(Object, Callable)}, but without checked exceptions.
+     *
+     * @param  key      the key for which to get the cached or created value.
+     * @param  creator  a method for creating a value, to be invoked only if no value are cached for the given key.
+     * @return the value already mapped to the key, or the newly computed value.
+     *
+     * @since 1.0
+     *
+     * @see #peek(Object)
+     * @see #containsKey(Object)
+     * @see #getOrCreate(Object, Callable)
+     * @see #computeIfPresent(Object, BiFunction)
+     */
+    @Override
+    public V computeIfAbsent(final K key, final Function<? super K, ? extends V> creator) {
+        V value = peek(key);
+        if (value == null) {
+            final Handler<V> handler = lock(key);
+            try {
+                value = handler.peek();
+                if (value == null) {
+                    value = creator.apply(key);
+                }
+            } finally {
+                handler.putAndUnlock(value);
+            }
+        }
+        return value;
+    }
+
+    /**
      * Returns {@code true} if the given value is an instance of one of the reserved types
      * used internally by this class.
      */
@@ -502,6 +549,137 @@ public class Cache<K,V> extends Abstract
     }
 
     /**
+     * Iterates over all entries in the cache and replaces their value with the one provided by the given function.
+     * If the function throws an exception, the iteration is stopped and the exception is propagated. If any value
+     * is under computation in other threads, then the iteration will block on that entry until its computation is
+     * completed.
+     *
+     * @param  remapping  the function computing new values from the old ones.
+     *
+     * @since 1.0
+     */
+    @Override
+    public void replaceAll(final BiFunction<? super K, ? super V, ? extends V> remapping) {
+        final ReplaceAdapter adapter = new ReplaceAdapter(remapping);
+        map.replaceAll(adapter);
+        Deferred.notifyChanges(this, adapter.changes);
+    }
+
+    /**
+     * Replaces the value mapped to the given key by a new value computed from the old value.
+     * If a value for the given key is under computation in another thread, then this method
+     * blocks until that computation is completed. This is equivalent to the work performed
+     * by {@link #replaceAll replaceAll(…)} but on a single entry.
+     *
+     * @param  key        key of the value to replace.
+     * @param  remapping  the function computing new values from the old ones.
+     * @return the new value associated with the given key.
+     *
+     * @see #computeIfAbsent(Object, Function)
+     *
+     * @since 1.0
+     */
+    @Override
+    public V computeIfPresent(final K key, final BiFunction<? super K, ? super V, ? extends V> remapping) {
+        final ReplaceAdapter adapter = new ReplaceAdapter(remapping);
+        final Object value = map.computeIfPresent(key, adapter);
+        Deferred.notifyChanges(this, adapter.changes);
+        return valueOf(value);
+    }
+
+    /**
+     * Replaces the value mapped to the given key by a new value computed from the old value.
+     * If there is no value for the given key, then the "old value" is taken as {@code null}.
+     * If a value for the given key is under computation in another thread, then this method
+     * blocks until that computation is completed. This method is equivalent to
+     * {@link #computeIfPresent computeIfPresent(…)} except that a new value will be computed
+     * even if no value existed for the key before this method call.
+     *
+     * @param  key        key of the value to replace.
+     * @param  remapping  the function computing new values from the old ones, or from a {@code null} value.
+     * @return the new value associated with the given key.
+     *
+     * @see #computeIfAbsent(Object, Function)
+     *
+     * @since 1.0
+     */
+    @Override
+    public V compute(final K key, final BiFunction<? super K, ? super V, ? extends V> remapping) {
+        final ReplaceAdapter adapter = new ReplaceAdapter(remapping);
+        final Object value = map.compute(key, adapter);
+        Deferred.notifyChanges(this, adapter.changes);
+        return valueOf(value);
+    }
+
+    /**
+     * Maps the given value to the given key if no mapping existed before this method call,
+     * or computes a new value otherwise. If a value for the given key is under computation
+     * in another thread, then this method blocks until that computation is completed.
+     *
+     * @param  key        key of the value to replace.
+     * @param  value      the value to associate with the given key if no value already exists, or {@code null}.
+     * @param  remapping  the function computing a new value by merging the exiting value
+     *                    with the {@code value} argument given to this method.
+     * @return the new value associated with the given key.
+     *
+     * @since 1.0
+     */
+    @Override
+    public V merge(final K key, final V value, final BiFunction<? super V, ? super V, ? extends V> remapping) {
+        ensureValidType(value);
+
+        /** Similar to {@link Cache.ReplaceAdapter}, but adapted to the merge case. */
+        final class Adapter implements BiFunction<Object,Object,Object> {
+            /** Forwards {@link Cache#map} calls to the user-provided function. */
+            @Override public Object apply(final Object oldValue, final Object givenValue) {
+                final V toReplace = valueOf(oldValue);
+                final V newValue = remapping.apply(toReplace, valueOf(givenValue));
+                ensureValidType(newValue);
+                if (newValue != toReplace) {
+                    changes = new Deferred<>(key, newValue, changes);
+                }
+                return newValue;
+            }
+
+            /** The new values for which to send notifications. */
+            Deferred<K,V> changes;
+        }
+        final Adapter adapter = new Adapter();
+        final Object newValue = map.merge(key, value, adapter);
+        Deferred.notifyChanges(this, adapter.changes);
+        return valueOf(newValue);
+    }
+
+    /**
+     * A callback for {@link Cache#map} which forwards the calls to the {@code remapping} function provided by user.
+     * Before to forward the calls, {@code ReplaceAdapter} verifies if the value is under computation. If yes, then
+     * this adapter block until the value is available for forwarding it to the user.
+     */
+    private final class ReplaceAdapter implements BiFunction<K,Object,Object> {
+        /** The new values for which to send notifications. */
+        private Deferred<K,V> changes;
+
+        /** The user-providing function. */
+        private final BiFunction<? super K, ? super V, ? extends V> remapping;
+
+        /** Creates a new adapter for the given user-provided function. */
+        ReplaceAdapter(final BiFunction<? super K, ? super V, ? extends V> remapping) {
+            this.remapping = remapping;
+        }
+
+        /** Forwards {@link Cache#map} calls to the user-provided function. */
+        @Override public Object apply(final K key, final Object oldValue) {
+            final V toReplace = valueOf(oldValue);
+            final V newValue = remapping.apply(key, toReplace);
+            ensureValidType(newValue);
+            if (newValue != toReplace) {
+                changes = new Deferred<>(key, newValue, changes);
+            }
+            return newValue;
+        }
+    }
+
+    /**
      * Key-value pairs of new entries created during {@link Cache.ReplaceAdapter} execution, as a chained list.
      * Calls to {@link Cache#notifyChange(Object, Object)} for those entries need to be deferred until operation
      * on {@link Cache#map} completed because {@link Cache#adjustReferences(Object, Object)} needs the new values

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/CacheEntries.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/CacheEntries.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/CacheEntries.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/CacheEntries.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -151,13 +151,9 @@ final class CacheEntries<K,V> extends Ab
             throw new NoSuchElementException();
         }
 
-        /**
-         * Unsupported operation, because the wrapped iterator is not after the proper element
-         * (it is after the next one).
+        /*
+         * remove() is an unsupported operation because the wrapped iterator is not after the proper element
+         * (it is after the next one). So we inherit the default implementation from Iterator.
          */
-        @Override
-        public void remove() {
-            throw new UnsupportedOperationException();
-        }
     }
 }

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/FrequencySortedSet.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/FrequencySortedSet.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/FrequencySortedSet.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/FrequencySortedSet.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -152,11 +152,7 @@ public class FrequencySortedSet<E> exten
             ArgumentChecks.ensurePositive("occurrence", occurrence);
             sorted = null;
             occurrence ^= order;
-            final Integer old = count.put(element, occurrence);
-            if (old == null) {
-                return true;
-            }
-            count.put(element, old + occurrence - order);
+            return count.merge(element, occurrence, (old, n) -> Math.addExact(old, n) - order) == occurrence;
         }
         return false;
     }
@@ -572,11 +568,8 @@ public class FrequencySortedSet<E> exten
      * The comparator used for sorting map entries.
      * Must be consistent with {@link #compare(Object, Object)} implementation.
      */
-    private static final Comparator<Map.Entry<?,Integer>> COMPARATOR = new Comparator<Map.Entry<?,Integer>>() {
-        @Override public int compare(Map.Entry<?,Integer> o1, Map.Entry<?,Integer> o2) {
-            return o1.getValue().compareTo(o2.getValue());
-        }
-    };
+    private static final Comparator<Map.Entry<?,Integer>> COMPARATOR =
+            (Map.Entry<?,Integer> o1, Map.Entry<?,Integer> o2) -> o1.getValue().compareTo(o2.getValue());
 
     /**
      * Returns the comparator used to order the elements in this set.

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/IntegerList.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/IntegerList.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/IntegerList.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/IntegerList.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -20,12 +20,21 @@ import java.util.Arrays;
 import java.util.AbstractList;
 import java.util.RandomAccess;
 import java.util.NoSuchElementException;
+import java.util.ConcurrentModificationException;
 import java.io.IOException;
 import java.io.Serializable;
 import java.io.ObjectOutputStream;
 import org.apache.sis.util.ArraysExt;
 import org.apache.sis.util.ArgumentChecks;
 
+// Branch-dependent imports
+import java.util.Spliterator;
+import java.util.PrimitiveIterator;
+import java.util.function.Consumer;
+import java.util.function.IntConsumer;
+import java.util.stream.IntStream;
+import java.util.stream.StreamSupport;
+
 
 /**
  * A list of unsigned integer values. This class packs the values in the minimal amount of bits
@@ -435,6 +444,218 @@ public class IntegerList extends Abstrac
     }
 
     /**
+     * Returns an iterator over the elements in this list in increasing index order.
+     * The iterator is <cite>fail-fast</cite> and supports the remove operation.
+     *
+     * @return iterator over the integer values in this list.
+     *
+     * @since 0.8-jdk8
+     */
+    @Override
+    public PrimitiveIterator.OfInt iterator() {
+        return new PrimitiveSpliterator();
+    }
+
+    /**
+     * Returns an spliterator over the elements in this list in increasing index order.
+     * The iterator is <cite>fail-fast</cite>.
+     *
+     * @return spliterator over the integer values in this list.
+     *
+     * @since 0.8-jdk8
+     */
+    @Override
+    public Spliterator.OfInt spliterator() {
+        return new PrimitiveSpliterator();
+    }
+
+    /**
+     * Returns a stream of integers with this {@code IntegerList} as its source.
+     * This method is similar to {@link #stream()}, but does not box the values.
+     * The returned stream is <cite>fail-fast</cite>, meaning that any modification to the list
+     * while using the stream will cause a {@link ConcurrentModificationException} to be thrown.
+     *
+     * <p>The default implementation creates a parallel or sequential stream from {@link #spliterator()}.</p>
+     *
+     * @param parallel  {@code true} for a parallel stream, or {@code false} for a sequential stream.
+     * @return a stream of values in this list as primitive types.
+     *
+     * @since 0.8-jdk8
+     */
+    public IntStream stream(boolean parallel) {
+        return StreamSupport.intStream(spliterator(), parallel);
+    }
+
+    /**
+     * Same as {@link #spliterator()}, but without value boxing.
+     * This spliterator provides a fail-fast way to traverse list content, which means
+     * that any alteration to the list content causes a failure of the advance operation
+     * with a {@link ConcurrentModificationException}.
+     *
+     * <p>This implementation opportunistically provides an iterator implementation on
+     * integer values too, but only one of the {@code Iterator} or {@code Spliterator}
+     * API should be used on a given instance.</p>
+     */
+    private final class PrimitiveSpliterator implements Spliterator.OfInt, PrimitiveIterator.OfInt {
+        /**
+         * Index after the last element returned by this spliterator. This is initially {@link IntegerList#size},
+         * but may be set to a smaller value by call to {@link #trySplit()}.
+         */
+        private int stopAt;
+
+        /**
+         * Index of the next element to be returned.
+         */
+        private int nextIndex;
+
+        /**
+         * The {@link IntegerList#modCount} value as iterator construction time.
+         * Used for detecting modification in the backing list during traversal.
+         */
+        private int expectedModCount;
+
+        /**
+         * Index of the last elements removed by a {@link #remove()} operation.
+         * This is used for checking that {@code remove()} is not invoked twice
+         * before the next advance.
+         */
+        private int lastRemove;
+
+        /**
+         * Creates a new iterator for the whole content of the backing list.
+         */
+        PrimitiveSpliterator() {
+            expectedModCount = modCount;
+            stopAt           = size;
+        }
+
+        /**
+         * Creates the prefix spliterator in a call to {@link #trySplit()}.
+         *
+         * @param  suffix   the spliterator which will continue iteration after this spliterator.
+         * @param  startAt  index of the first element to be returned by this prefix spliterator.
+         */
+        private PrimitiveSpliterator(final PrimitiveSpliterator suffix, final int startAt) {
+            expectedModCount = suffix.expectedModCount;
+            stopAt           = suffix.nextIndex;
+            nextIndex        = startAt;
+        }
+
+        /**
+         * Declares that this split iterator does not return null elements, that all elements are
+         * traversed in a fixed order (which is increasing index values) and that {@link #size()}
+         * represents an exact count of elements.
+         */
+        @Override
+        public int characteristics() {
+            return NONNULL | ORDERED | SIZED | SUBSIZED;
+        }
+
+        /**
+         * Returns the exact number of values to be encountered by a {@code forEachRemaining(…)} traversal.
+         */
+        @Override
+        public long estimateSize() {
+            return stopAt - nextIndex;
+        }
+
+        /**
+         * @todo for now, we keep it simple and forbid parallelism. In the future,
+         *       we could use an approach as the one in java standard array lists.
+         */
+        @Override
+        public Spliterator.OfInt trySplit() {
+            final int startAt = nextIndex;
+            final int halfSize = (stopAt - startAt) >>> 1;
+            if (halfSize > 1) {
+                nextIndex += halfSize;
+                return new PrimitiveSpliterator(this, startAt);
+            }
+            return null;
+        }
+
+        /**
+         * Returns {@code true} if there is one more value to return. This method
+         * also ensures that no alteration has happened on the backing list since
+         * the spliterator creation.
+         */
+        @Override
+        public boolean hasNext() {
+            if (modCount == expectedModCount) {
+                return nextIndex < stopAt;
+            } else {
+                throw new ConcurrentModificationException();
+            }
+        }
+
+        /**
+         * Returns the next integer values in iterator order.
+         */
+        @Override
+        public int nextInt() {
+            if (hasNext()) {
+                return getUnchecked(nextIndex++);
+            } else {
+                throw new NoSuchElementException();
+            }
+        }
+
+        /**
+         * If a remaining element exists, performs the given action on it and returns {@code true}.
+         * Otherwise returns {@code false}.
+         */
+        @Override
+        public boolean tryAdvance(IntConsumer action) {
+            final boolean canAdvance = hasNext();
+            if (canAdvance) {
+                action.accept(getUnchecked(nextIndex++));
+            }
+            return canAdvance;
+        }
+
+        /**
+         * Performs the given action on all remaining elements. This implementation
+         * is shared by both {@code Iterator} and {@code Spliterator} interfaces.
+         */
+        @Override
+        public void forEachRemaining(final IntConsumer action) {
+            while (hasNext()) {
+                action.accept(getUnchecked(nextIndex++));
+            }
+        }
+
+        /**
+         * Performs the given action on all remaining elements. This implementation
+         * is shared by both {@code Iterator} and {@code Spliterator} interfaces.
+         */
+        @Override
+        public void forEachRemaining(final Consumer<? super Integer> action) {
+            if (action instanceof IntConsumer) {
+                forEachRemaining((IntConsumer) action);
+            } else while (hasNext()) {
+                action.accept(getUnchecked(nextIndex++));
+            }
+        }
+
+        /**
+         * Removes the last element returned by {@link #nextInt()}.
+         */
+        @Override
+        public void remove() {
+            if (nextIndex < lastRemove || nextIndex > stopAt) {
+                throw new IllegalStateException();
+            }
+            if (modCount != expectedModCount) {
+                throw new ConcurrentModificationException();
+            }
+            expectedModCount = ++modCount;
+            removeRange(nextIndex - 1, nextIndex);
+            lastRemove = --nextIndex;
+            stopAt--;
+        }
+    }
+
+    /**
      * Invokes {@link #trimToSize()} before serialization in order to make the stream more compact.
      *
      * @param  out  the output stream where to serialize this list.

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTables.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTables.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTables.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTables.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -214,7 +214,7 @@ public final class TreeTables extends St
             }
         }
         filtered = ArraysExt.resize(filtered, count);
-        return replaceCharSequences(table.getRoot(), filtered, locale, new HashMap<String,String>());
+        return replaceCharSequences(table.getRoot(), filtered, locale, new HashMap<>());
     }
 
     /**

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -464,6 +464,7 @@ public class WeakValueHashMap<K,V> exten
      *
      * @since 0.7
      */
+    @Override
     public V putIfAbsent(final K key, final V value) throws NullArgumentException {
         if (key == null || value == null) {
             throw new NullArgumentException(Errors.format(key == null

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecord.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecord.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecord.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecord.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -246,12 +246,6 @@ public class DefaultRecord implements Re
             }
             throw new NoSuchElementException();
         }
-
-        /** Unsupported operation. */
-        @Override
-        public void remove() {
-            throw new UnsupportedOperationException();
-        }
     }
 
     /**

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -41,9 +41,6 @@ import org.apache.sis.util.resources.Err
 import org.apache.sis.util.collection.BackingStoreException;
 import org.apache.sis.internal.system.Loggers;
 
-// Branch-dependent imports
-import org.apache.sis.internal.jdk8.JDK8;
-
 
 /**
  * Static methods working on GeoAPI types and {@link CodeList} values.
@@ -545,7 +542,7 @@ public final class Types extends Static
                 throw new BackingStoreException(e);
             }
             typeForNames = new HashMap<>(props);
-            JDK8.putIfAbsent(typeForNames, "MI_SensorTypeCode", "org.apache.sis.internal.metadata.SensorType");
+            typeForNames.putIfAbsent("MI_SensorTypeCode", "org.apache.sis.internal.metadata.SensorType");
         }
         final Object value = typeForNames.get(identifier);
         if (value == null || value instanceof Class<?>) {

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/LoggerAdapter.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/LoggerAdapter.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/LoggerAdapter.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/LoggerAdapter.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -571,6 +571,7 @@ public abstract class LoggerAdapter exte
      *
      * @since 0.5
      */
+    @Override
     public void logrb(final Level level, final String sourceClass, final String sourceMethod,
                       final ResourceBundle bundle, final String message, final Object... params)
     {
@@ -591,6 +592,7 @@ public abstract class LoggerAdapter exte
      *
      * @since 0.5
      */
+    @Override
     public void logrb(final Level level, final String sourceClass, final String sourceMethod,
                       final ResourceBundle bundle, final String message, final Throwable thrown)
     {

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -147,16 +147,14 @@ public class MonolineFormatter extends F
     /**
      * A comparator for logging level. This comparator sorts finest levels first and severe levels last.
      */
-    private static final Comparator<Level> COMPARATOR = new Comparator<Level>() {
-        @Override public int compare(final Level l1, final Level l2) {
-            // We can't just return (i1 - i2) because some levels are
-            // Integer.MIN_VALUE or Integer.MAX_VALUE, which cause overflow.
-            final int i1 = l1.intValue();
-            final int i2 = l2.intValue();
-            if (i1 < i2) return -1;
-            if (i1 > i2) return +1;
-            return 0;
-        }
+    private static final Comparator<Level> COMPARATOR = (final Level l1, final Level l2) -> {
+        // We can't just return (i1 - i2) because some levels are
+        // Integer.MIN_VALUE or Integer.MAX_VALUE, which cause overflow.
+        final int i1 = l1.intValue();
+        final int i2 = l2.intValue();
+        if (i1 < i2) return -1;
+        if (i1 > i2) return +1;
+        return 0;
     };
 
     /**

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -366,7 +366,7 @@ public class WarningListeners<S> impleme
         synchronized (this) {
             current = listeners;
         }
-        return (current != null) ? UnmodifiableArrayList.wrap(current) : Collections.<WarningListener<? super S>>emptyList();
+        return (current != null) ? UnmodifiableArrayList.wrap(current) : Collections.emptyList();
     }
 
     /**

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/KeyConstants.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/KeyConstants.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/KeyConstants.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/KeyConstants.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -81,7 +81,7 @@ public class KeyConstants {
                 names = new String[fields.length];
                 for (final Field field : fields) {
                     if (Modifier.isStatic(field.getModifiers()) && field.getType() == Short.TYPE) {
-                        final int index = (((Short) field.get(null)) & 0xFFFF) - IndexedResourceBundle.FIRST;
+                        final int index = Short.toUnsignedInt((Short) field.get(null)) - IndexedResourceBundle.FIRST;
                         if (index >= length) {
                             length = index + 1;
                             if (length > names.length) {
@@ -106,7 +106,7 @@ public class KeyConstants {
      * our {@link IndexedResourceBundle#handleGetObject(String)} implementation.
      */
     final String getKeyName(final short index) {
-        final int i = (index & 0xFFFF) - IndexedResourceBundle.FIRST;
+        final int i = Short.toUnsignedInt(index) - IndexedResourceBundle.FIRST;
         final String[] keys = getKeyNames();
         if (i >= 0 && i < keys.length) {
             final String key = keys[i];

Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/CollectionsExtTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/CollectionsExtTest.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/CollectionsExtTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/CollectionsExtTest.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -37,7 +37,7 @@ import org.junit.Test;
 import static org.apache.sis.test.Assert.*;
 
 // Branch-dependent imports
-import org.apache.sis.internal.jdk8.Predicate;
+import java.util.function.Predicate;
 
 
 /**
@@ -158,11 +158,7 @@ public final strictfp class CollectionsE
      */
     @Test
     public void testFilter() {
-        final Iterator<Integer> it = CollectionsExt.filter(Arrays.asList(2, 5, 7, 4, 8).iterator(), new Predicate<Integer>() {
-            @Override public boolean test(Integer n) {
-                return (n & 1) == 0;
-            }
-        });
+        final Iterator<Integer> it = CollectionsExt.filter(Arrays.asList(2, 5, 7, 4, 8).iterator(), (Integer n) -> (n & 1) == 0);
         assertTrue  (   it.hasNext());
         assertEquals(2, it.next().intValue());
         assertEquals(4, it.next().intValue());

Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/StandardDateFormatTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/StandardDateFormatTest.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/StandardDateFormatTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/StandardDateFormatTest.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -19,13 +19,17 @@ package org.apache.sis.internal.util;
 import java.util.Date;
 import java.util.concurrent.TimeUnit;
 import java.text.ParseException;
-import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
 import static org.apache.sis.test.TestUtilities.date;
 import static org.junit.Assert.*;
 
+// Branch-dependent imports
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+
 
 /**
  * Tests the {@link StandardDateFormat} class.
@@ -48,42 +52,6 @@ public final strictfp class StandardDate
     }
 
     /**
-     * Verifies the condition documented in {@link StandardDateFormat#SHORT_PATTERN} javadoc.
-     */
-    @Test
-    public void testDatePatterns() {
-        assertTrue(StandardDateFormat.PATTERN.startsWith(StandardDateFormat.SHORT_PATTERN));
-    }
-
-    /**
-     * Tests {@link StandardDateFormat#dateToISO(CharSequence, int, boolean)} method.
-     */
-    @Test
-    public void testDateToISO() {
-        assertEquals("2009-01-01T06:00:00.000+01:00", StandardDateFormat.dateToISO("2009-01-01T06:00:00+01:00", 0, false));
-        assertEquals("2005-09-22T04:30:15.432Z",      StandardDateFormat.dateToISO("2005-09-22T04:30:15.4321Z", 0, false));
-        assertEquals("2005-09-22T04:30:15.432Z",      StandardDateFormat.dateToISO("2005-09-22T04:30:15.432Z",  0, false));
-        assertEquals("2005-09-22T04:30:15.000Z",      StandardDateFormat.dateToISO("2005-09-22T04:30:15Z",      0, false));
-        assertEquals("2005-09-22T04:30:15.000Z",      StandardDateFormat.dateToISO("2005-09-22T04:30:15",       0, false));
-        assertEquals("2005-09-22T04:30:00.000Z",      StandardDateFormat.dateToISO("2005-09-22T04:30",          0, false));
-        assertEquals("2005-09-22T04:00:00.000Z",      StandardDateFormat.dateToISO("2005-09-22T04",             0, false));
-        assertEquals("2005-09-22T00:00:00.000Z",      StandardDateFormat.dateToISO("2005-09-22",                0, false));
-        assertEquals("2005-09-22T00:00:00.000Z",      StandardDateFormat.dateToISO("2005-9-22",                 0, false));
-
-        String text = "2016-06-27T16:48:12Z";
-        String modified = StandardDateFormat.dateToISO(text, 0, false);
-        assertEquals("2016-06-27T16:48:12.000Z", modified);
-        assertEquals("An index before", 18, StandardDateFormat.adjustIndex(text, modified, 0, 18));
-        assertEquals("An index after",  19, StandardDateFormat.adjustIndex(text, modified, 0, 23));
-
-        text = "2016-06-27T16:48:12.48Z";
-        modified = StandardDateFormat.dateToISO(text, 0, false);
-        assertEquals("2016-06-27T16:48:12.480Z", modified);
-        assertEquals("An index before", 18, StandardDateFormat.adjustIndex(text, modified, 0, 18));
-        assertEquals("An index after",  22, StandardDateFormat.adjustIndex(text, modified, 0, 23));
-    }
-
-    /**
      * Tests parsing a date.
      * Since the implementation is completely different in JDK8 branch than in previous branch,
      * a key purpose of this test is to ensure that the parsing is consistent between the branches.
@@ -91,7 +59,6 @@ public final strictfp class StandardDate
      * @throws ParseException if an error occurred while parsing the date.
      */
     @Test
-    @DependsOnMethod("testDateToISO")
     public void testParse() throws ParseException {
         final long day = 1466985600000L;
         final StandardDateFormat f = new StandardDateFormat();
@@ -111,6 +78,22 @@ public final strictfp class StandardDate
     }
 
     /**
+     * Tests parsing a temporal object.
+     *
+     * @since 0.8
+     */
+    @Test
+    public void testParseBest() {
+        final long day = 1466985600000L;
+        assertEquals(Instant.ofEpochMilli(day + ((16*60 + 48)*60     )*1000),      StandardDateFormat.parseBest("2016-06-27T16:48Z"));
+        assertEquals(Instant.ofEpochMilli(day + ((16*60 + 48)*60 + 12)*1000),      StandardDateFormat.parseBest("2016-06-27T16:48:12Z"));
+        assertEquals(Instant.ofEpochMilli(day + (( 3*60 +  2)*60 +  1)*1000 + 90), StandardDateFormat.parseBest("2016-06-27T03:02:01.09Z"));
+        assertEquals(LocalDateTime.of(2016, 6, 27, 16, 48, 12),                    StandardDateFormat.parseBest("2016-06-27T16:48:12"));
+        assertEquals(LocalDateTime.of(2016, 6, 27, 16, 48),                        StandardDateFormat.parseBest("2016-06-27T16:48"));
+        assertEquals(LocalDate.of(2016, 6, 27),                                    StandardDateFormat.parseBest("2016-06-27"));
+    }
+
+    /**
      * Tests formatting and parsing a negative year.
      * This test uses the Julian epoch (January 1st, 4713 BC at 12:00 UTC in proleptic Julian calendar;
      * equivalent to November 24, 4714 BC when expressed in the proleptic Gregorian calendar instead).
@@ -121,7 +104,7 @@ public final strictfp class StandardDate
     @Test
     public void testNegativeYear() throws ParseException {
         final Date julian = new Date(-210866760000000L);            // Same epoch than CommonCRS.Temporal.JULIAN.
-        final String expected = "-4713-11-24T12:00:00.000Z";        // Proleptic Gregorian calendar, astronomical year.
+        final String expected = "-4713-11-24T12:00:00.000";         // Proleptic Gregorian calendar, astronomical year.
         final StandardDateFormat f = new StandardDateFormat();
         assertEquals(expected, f.format(julian));
         assertEquals(julian, f.parse(expected));

Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -27,9 +27,6 @@ import static org.apache.sis.math.MathFu
 import static org.apache.sis.util.ArraysExt.isSorted;
 import static org.apache.sis.internal.util.Numerics.SIGNIFICAND_SIZE;
 
-// Related to JDK8
-import org.apache.sis.internal.jdk8.JDK8;
-
 
 /**
  * Tests the {@link MathFunctions} static methods.
@@ -131,7 +128,7 @@ public final strictfp class MathFunction
         for (int i=0; i<=SIGNIFICAND_SIZE; i++) {
             assertEquals(MIN_EXPONENT - i, getExponent(MIN_NORMAL / (1L << i)));
         }
-        assertEquals(MIN_EXPONENT - 1,                    getExponent(JDK8.nextDown(MIN_NORMAL)));
+        assertEquals(MIN_EXPONENT - 1,                    getExponent(StrictMath.nextDown(MIN_NORMAL)));
         assertEquals(MIN_EXPONENT - SIGNIFICAND_SIZE,     getExponent(MIN_VALUE));
         assertEquals(MIN_EXPONENT - SIGNIFICAND_SIZE - 1, getExponent(0));
         /*

Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -19,10 +19,13 @@ package org.apache.sis.test;
 import java.util.Set;
 import java.util.Map;
 import java.util.Objects;
+import java.util.Iterator;
 import java.util.Collection;
 import java.util.Enumeration;
 import java.util.LinkedHashSet;
 import java.util.LinkedHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ConcurrentHashMap;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
@@ -37,6 +40,10 @@ import org.apache.sis.util.ComparisonMod
 import org.apache.sis.util.Exceptions;
 import org.apache.sis.util.Classes;
 
+// Branch-dependent imports
+import java.util.stream.Stream;
+import java.util.function.Consumer;
+
 
 /**
  * Assertion methods used by the SIS project in addition of the JUnit and GeoAPI assertions.
@@ -171,6 +178,77 @@ public strictfp class Assert extends Geo
     }
 
     /**
+     * Verifies that the given stream produces the same values than the given iterator, in same order.
+     * This method assumes that the given stream is sequential.
+     *
+     * @param  <E>       the type of values to test.
+     * @param  expected  the expected values.
+     * @param  actual    the stream to compare with the expected values.
+     *
+     * @since 0.8
+     */
+    public static <E> void assertSequentialStreamEquals(final Iterator<E> expected, final Stream<E> actual) {
+        actual.forEach(new Consumer<E>() {
+            private int count;
+
+            @Override
+            public void accept(final Object value) {
+                if (!expected.hasNext()) {
+                    fail("Expected " + count + " elements, but the stream contains more.");
+                }
+                final Object ex = expected.next();
+                if (!Objects.equals(ex, value)) {
+                    fail("Expected " + ex + " at index " + count + " but got " + value);
+                }
+                count++;
+            }
+        });
+        assertFalse("Unexpected end of stream.", expected.hasNext());
+    }
+
+    /**
+     * Verifies that the given stream produces the same values than the given iterator, in any order.
+     * This method is designed for use with parallel streams, but works with sequential streams too.
+     *
+     * @param  <E>       the type of values to test.
+     * @param  expected  the expected values.
+     * @param  actual    the stream to compare with the expected values.
+     *
+     * @since 0.8
+     */
+    public static <E> void assertParallelStreamEquals(final Iterator<E> expected, final Stream<E> actual) {
+        final Integer ONE = 1;          // For doing autoboxing only once.
+        final ConcurrentMap<E,Integer> count = new ConcurrentHashMap<>();
+        while (expected.hasNext()) {
+            count.merge(expected.next(), ONE, (old, one) -> old + 1);
+        }
+        /*
+         * Following may be parallelized in an arbitrary amount of threads.
+         */
+        actual.forEach((value) -> {
+            if (count.computeIfPresent(value, (key, old) -> old - 1) == null) {
+                fail("Stream returned unexpected value: " + value);
+            }
+        });
+        /*
+         * Back to sequential order, verify that all elements have been traversed
+         * by the stream and no more.
+         */
+        for (final Map.Entry<E,Integer> entry : count.entrySet()) {
+            int n = entry.getValue();
+            if (n != 0) {
+                final String message;
+                if (n < 0) {
+                    message = "Stream returned too many occurrences of %s%n%d extraneous were found.";
+                } else {
+                    message = "Stream did not returned all expected occurrences of %s%n%d are missing.";
+                }
+                fail(String.format(message, entry.getKey(), StrictMath.abs(n)));
+            }
+        }
+    }
+
+    /**
      * Asserts that the given set contains the same elements, ignoring order.
      * In case of failure, this method lists the missing or unexpected elements.
      *
@@ -181,7 +259,7 @@ public strictfp class Assert extends Geo
      */
     public static void assertSetEquals(final Collection<?> expected, final Collection<?> actual) {
         if (expected != null && actual != null && !expected.isEmpty()) {
-            final Set<Object> r = new LinkedHashSet<Object>(expected);
+            final Set<Object> r = new LinkedHashSet<>(expected);
             assertTrue("The two sets are disjoint.",                 r.removeAll(actual));
             assertTrue("The set is missing elements: " + r,          r.isEmpty());
             assertTrue("The set unexpectedly became empty.",         r.addAll(actual));
@@ -202,7 +280,7 @@ public strictfp class Assert extends Geo
      */
     public static void assertMapEquals(final Map<?,?> expected, final Map<?,?> actual) {
         if (expected != null && actual != null && !expected.isEmpty()) {
-            final Map<Object,Object> r = new LinkedHashMap<Object,Object>(expected);
+            final Map<Object,Object> r = new LinkedHashMap<>(expected);
             for (final Map.Entry<?,?> entry : actual.entrySet()) {
                 final Object key = entry.getKey();
                 if (!r.containsKey(key)) {

Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -20,7 +20,6 @@ import java.util.Set;
 import java.util.List;
 import java.util.HashSet;
 import java.util.Arrays;
-import java.util.Comparator;
 import java.io.PrintWriter;
 
 import org.junit.Test;
@@ -252,12 +251,7 @@ public final class TestRunner extends Bl
         for (final FrameworkMethod method : children) {
             sorter.apply(method);
         }
-        Arrays.sort(children, new Comparator<FrameworkMethod>() {
-            @Override
-            public int compare(FrameworkMethod o1, FrameworkMethod o2) {
-                return sorter.compare(describeChild(o1), describeChild(o2));
-            }
-        });
+        Arrays.sort(children, (FrameworkMethod o1, FrameworkMethod o2) -> sorter.compare(describeChild(o1), describeChild(o2)));
         sortDependantTestsLast(children);
         filteredChildren = children;
     }

Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/mock/MetadataMock.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/mock/MetadataMock.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/mock/MetadataMock.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/mock/MetadataMock.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -69,7 +69,7 @@ public final strictfp class MetadataMock
      */
     @Override
     public Collection<Locale> getLanguages() {
-        return (language != null) ? Collections.<Locale>singleton(language) : Collections.<Locale>emptySet();
+        return (language != null) ? Collections.singleton(language) : Collections.emptySet();
     }
 
     /**

Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -131,8 +131,6 @@ import org.junit.BeforeClass;
     org.apache.sis.util.collection.TreeTableFormatTest.class,
     org.apache.sis.util.collection.RangeSetTest.class,
     org.apache.sis.internal.util.StandardDateFormatTest.class,
-    org.apache.sis.internal.jdk8.OffsetDateTimeTest.class,
-    org.apache.sis.internal.jdk8.OffsetTimeTest.class,
 
     // Converters.
     org.apache.sis.internal.converter.AngleConverterTest.class,

Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java [UTF-8] Fri Jan 26 10:48:27 2018
@@ -19,7 +19,6 @@ package org.apache.sis.util.collection;
 import java.util.Map;
 import java.util.HashMap;
 import java.util.AbstractMap.SimpleEntry;
-import java.util.concurrent.Callable;
 import java.util.concurrent.atomic.AtomicReference;
 import java.io.IOException;
 import java.io.PrintWriter;
@@ -59,8 +58,7 @@ public final strictfp class CacheTest ex
      */
     @Test
     public void testStrongReferences() {
-        WeakValueHashMapTest.testStrongReferences(
-                new Cache<Integer,Integer>(WeakValueHashMapTest.SAMPLE_SIZE, 0, false));
+        WeakValueHashMapTest.testStrongReferences(new Cache<>(WeakValueHashMapTest.SAMPLE_SIZE, 0, false));
     }
 
     /**
@@ -74,8 +72,7 @@ public final strictfp class CacheTest ex
     @Test
     @DependsOnMethod("testStrongReferences")
     public void testWeakReferences() throws InterruptedException {
-        WeakValueHashMapTest.testWeakReferences(
-                new Cache<Integer,Integer>(WeakValueHashMapTest.SAMPLE_SIZE, 0, false));
+        WeakValueHashMapTest.testWeakReferences(new Cache<>(WeakValueHashMapTest.SAMPLE_SIZE, 0, false));
     }
 
     /**
@@ -238,11 +235,7 @@ public final strictfp class CacheTest ex
                     final Integer expected = new Integer(i * i);        // We really want new instance.
                     final Integer value;
                     try {
-                        value = cache.getOrCreate(key, new Callable<Integer>() {
-                            @Override public Integer call() {
-                                return expected;
-                            }
-                        });
+                        value = cache.getOrCreate(key, () -> expected);
                         assertEquals(expected, value);
                     } catch (Throwable e) {
                         if (!failures.compareAndSet(null, e)) {



Mime
View raw message