-
Bug
-
Resolution: Fixed
-
P2
-
8-repo-lambda
The spec for OptionalDouble.hashCode() says:
* Returns the hash code value of the present value, if any, or 0 (zero) if
* no value is present.
However it doesn't happen with JDK8b82-lambda:
--------------------------------------------------
import java.util.OptionalDouble;
import java.util.OptionalInt;
import java.util.OptionalLong;
public class EmptyOptionalDoubleHashCode {
public static void main(String[] args) {
System.out.println("OptionalInt.empty().hashCode() = " + OptionalInt.empty().hashCode());
System.out.println("OptionalLong.empty().hashCode() = " + OptionalLong.empty().hashCode());
System.out.println("OptionalDouble.empty().hashCode() = " + OptionalDouble.empty().hashCode());
}
}
--------------------------------------------------
The output is:
OptionalInt.empty().hashCode() = 0
OptionalLong.empty().hashCode() = 0
OptionalDouble.empty().hashCode() = 2146959360
The following JCK test fails due to this issue:
api/java_util/OptionalDouble/index.html#General[hashCodeEmptyZeroValue]
* Returns the hash code value of the present value, if any, or 0 (zero) if
* no value is present.
However it doesn't happen with JDK8b82-lambda:
--------------------------------------------------
import java.util.OptionalDouble;
import java.util.OptionalInt;
import java.util.OptionalLong;
public class EmptyOptionalDoubleHashCode {
public static void main(String[] args) {
System.out.println("OptionalInt.empty().hashCode() = " + OptionalInt.empty().hashCode());
System.out.println("OptionalLong.empty().hashCode() = " + OptionalLong.empty().hashCode());
System.out.println("OptionalDouble.empty().hashCode() = " + OptionalDouble.empty().hashCode());
}
}
--------------------------------------------------
The output is:
OptionalInt.empty().hashCode() = 0
OptionalLong.empty().hashCode() = 0
OptionalDouble.empty().hashCode() = 2146959360
The following JCK test fails due to this issue:
api/java_util/OptionalDouble/index.html#General[hashCodeEmptyZeroValue]
- relates to
-
JDK-8001642 Optional<T> class
- Closed