diff --git a/.hgtags b/.hgtags index 548c2cf4486..4aaa12e7ea4 100644 --- a/.hgtags +++ b/.hgtags @@ -328,3 +328,4 @@ c8753d0be1778944dc512ec86a459941ea1ad2c3 jdk9-b78 f61a63b7d1e52e307abc0bfc751203155d362ec4 jdk9-b83 51b2db2fa04c16d767b66113dbf08c5349ce382a jdk9-b84 8392405ab038b22e69a3728e17dbdd9e3d3a22ed jdk9-b85 +7db0663a5e968059fa7c772172187ebd60b6492d jdk9-b86 diff --git a/.hgtags-top-repo b/.hgtags-top-repo index 04f1f878eb9..5650b64d79b 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -328,3 +328,4 @@ b8afcf91331d78626a583ec1b63164468d6f4181 jdk9-b81 ce5c14d97d95084504c32b9320cb33cce4235588 jdk9-b83 1c8134475511ffe6726677e1418a89a7a45e92d6 jdk9-b84 1f345217c9bab05f192d00cf1665b3286c49ccdb jdk9-b85 +2aa1daf98d3e2ee37f20f6858c53cc37020f6937 jdk9-b86 diff --git a/corba/.hgtags b/corba/.hgtags index f10e0955e46..492bb735842 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -328,3 +328,4 @@ c20d8ebddaa6fb09cc81d3edf3d1d05f4232700a jdk9-b82 ca8a1719588424f6e04e943790c7fcb7cb0b8c8f jdk9-b83 df70bb200356fec686681f0295c50cc3ed43c3b3 jdk9-b84 3ec06af1368924469f7ce60a00324bac55eaeecc jdk9-b85 +0a3f0d25c201b40575a7c3920fce4d6f4d3ae310 jdk9-b86 diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 9dbc3fc3e5e..a19cb298ea3 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -488,3 +488,4 @@ e9e63d93bbfe2c6c23447e2c1f5cc71c98671cba jdk9-b79 3ed0df2c553a80e0e26b91a6ce08806ea17a066a jdk9-b83 184c4328444974edd6b3b490b9d0177ace7e331c jdk9-b84 03845376ea9dbf9690b6a9cfb4ed63f8cc0541c0 jdk9-b85 +1ae4191359d811a51512f17dca80ffe79837a5ff jdk9-b86 diff --git a/jaxp/.hgtags b/jaxp/.hgtags index c1c4f9154da..4dcf642142e 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -328,3 +328,4 @@ f464f9b2fb1178f6a957e5730b4b5252c6149ed9 jdk9-b80 497bc2654e11684b11de46744227883d7e760f35 jdk9-b83 91795d86744f3074d1e59b1e75d9c851c098688f jdk9-b84 1d9850c1b35c74e8b5c17970ed5d46dc0fc33f06 jdk9-b85 +88d9b1f6b73e0c46fcb5ccabe1231a30ce758a22 jdk9-b86 diff --git a/jaxws/.hgtags b/jaxws/.hgtags index 40bd6699ef4..ee6b4ae080e 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -331,3 +331,4 @@ e9940bf1c8ddaa6f1f5f1813846b080f0ccaf50b jdk9-b80 d7ee8157f4feced67924e421225c6f844079a03d jdk9-b83 51729143f8fe038f52cf55720c4c1f89267f5948 jdk9-b84 67b626ec730d2601d95ef036d06be34b37fa9ce6 jdk9-b85 +5289646179079394890a34a898a8ab70fcde0331 jdk9-b86 diff --git a/jdk/.hgtags b/jdk/.hgtags index a310e08032d..1b65224c2bb 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -328,3 +328,4 @@ b10b64263b563e21f055c881444f625ec618b826 jdk9-b82 d11f25ce3c545823f53bb978d454a4d2901abac3 jdk9-b83 757ef7f6d0042934edea3e0bf616fad2c1a22789 jdk9-b84 fe40b31c0e526d357cf5b62044fea006e43b53a5 jdk9-b85 +e8a66c0b05d786a282a7ff1d7eb4989afa30c891 jdk9-b86 diff --git a/jdk/make/launcher/Launcher-jdk.jshell.gmk b/jdk/make/launcher/Launcher-jdk.jshell.gmk new file mode 100644 index 00000000000..ca1a69d0d67 --- /dev/null +++ b/jdk/make/launcher/Launcher-jdk.jshell.gmk @@ -0,0 +1,31 @@ +# +# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +include LauncherCommon.gmk + +$(eval $(call SetupLauncher,jshell, \ + -DEXPAND_CLASSPATH_WILDCARDS \ + -DNEVER_ACT_AS_SERVER_CLASS_MACHINE \ + -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "jdk.internal.jshell.tool.JShellTool"$(COMMA) }')) diff --git a/jdk/src/java.base/share/classes/java/util/Optional.java b/jdk/src/java.base/share/classes/java/util/Optional.java index cc5c1309663..514632b5ccc 100644 --- a/jdk/src/java.base/share/classes/java/util/Optional.java +++ b/jdk/src/java.base/share/classes/java/util/Optional.java @@ -31,21 +31,22 @@ import java.util.function.Supplier; import java.util.stream.Stream; /** - * A container object which may or may not contain a non-null value. - * If a value is present, {@code isPresent()} will return {@code true} and - * {@code get()} will return the value. + * A container object which may or may not contain a non-{@code null} value. + * If a value is present, {@code isPresent()} returns {@code true} and + * {@code get()} returns the value. * *
Additional methods that depend on the presence or absence of a contained * value are provided, such as {@link #orElse(java.lang.Object) orElse()} - * (return a default value if value not present) and - * {@link #ifPresent(java.util.function.Consumer) ifPresent()} (perform an - * action if the value is present). + * (returns a default value if no value is present) and + * {@link #ifPresent(java.util.function.Consumer) ifPresent()} (performs an + * action if a value is present). * *
This is a value-based
* class; use of identity-sensitive operations (including reference equality
* ({@code ==}), identity hash code, or synchronization) on instances of
* {@code Optional} may have unpredictable results and should be avoided.
*
+ * @param If the mapping function returns a {@code null} result then this method
+ * returns an empty {@code Optional}.
+ *
+ * @apiNote
+ * This method supports post-processing on {@code Optional} values, without
* the need to explicitly check for a return status. For example, the
- * following code traverses a stream of file names, selects one that has
- * not yet been processed, and then opens that file, returning an
+ * following code traverses a stream of file names, selects one that has not
+ * yet been processed, and then opens that file, returning an
* {@code Optional This method is similar to {@link #map(Function)}, but the mapping
+ * function is one whose result is already an {@code Optional}, and if
+ * invoked, {@code flatMap} does not wrap it within an additional
* {@code Optional}.
*
- * @param The type parameter to the {@code Optional} returned by
- * @param mapper a mapping function to apply to the value, if present
- * the mapping function
+ * @param The type of value of the {@code Optional} returned by the
+ * mapping function
+ * @param mapper the mapping function to apply to a value, if present
* @return the result of applying an {@code Optional}-bearing mapping
- * function to the value of this {@code Optional}, if a value is present,
- * otherwise an empty {@code Optional}
- * @throws NullPointerException if the mapping function is null or returns
- * a null result
+ * function to the value of this {@code Optional}, if a value is
+ * present, otherwise an empty {@code Optional}
+ * @throws NullPointerException if the mapping function is {@code null} or
+ * returns a {@code null} result
*/
public Optional flatMap(Function super T, Optional> mapper) {
Objects.requireNonNull(mapper);
@@ -265,19 +274,41 @@ public final class Optional Additional methods that depend on the presence or absence of a contained
* value are provided, such as {@link #orElse(double) orElse()}
- * (return a default value if value not present) and
- * {@link #ifPresent(java.util.function.DoubleConsumer) ifPresent()} (perform an
- * action if the value is present).
+ * (returns a default value if no value is present) and
+ * {@link #ifPresent(java.util.function.DoubleConsumer) ifPresent()} (performs
+ * an action if a value is present).
*
* This is a value-based
* class; use of identity-sensitive operations (including reference equality
@@ -71,12 +71,13 @@ public final class OptionalDouble {
}
/**
- * Returns an empty {@code OptionalDouble} instance. No value is present for this
- * OptionalDouble.
+ * Returns an empty {@code OptionalDouble} instance. No value is present
+ * for this {@code OptionalDouble}.
*
- * @apiNote Though it may be tempting to do so, avoid testing if an object
- * is empty by comparing with {@code ==} against instances returned by
- * {@code Option.empty()}. There is no guarantee that it is a singleton.
+ * @apiNote
+ * Though it may be tempting to do so, avoid testing if an object is empty
+ * by comparing with {@code ==} against instances returned by
+ * {@code OptionalDouble.empty()}. There is no guarantee that it is a singleton.
* Instead, use {@link #isPresent()}.
*
* @return an empty {@code OptionalDouble}.
@@ -86,9 +87,9 @@ public final class OptionalDouble {
}
/**
- * Construct an instance with the value present.
+ * Construct an instance with the described value.
*
- * @param value the double value to be present.
+ * @param value the double value to describe.
*/
private OptionalDouble(double value) {
this.isPresent = true;
@@ -96,9 +97,9 @@ public final class OptionalDouble {
}
/**
- * Return an {@code OptionalDouble} with the specified value present.
+ * Returns an {@code OptionalDouble} describing the given value.
*
- * @param value the value to be present
+ * @param value the value to describe
* @return an {@code OptionalDouble} with the value present
*/
public static OptionalDouble of(double value) {
@@ -106,12 +107,11 @@ public final class OptionalDouble {
}
/**
- * If a value is present in this {@code OptionalDouble}, returns the value,
- * otherwise throws {@code NoSuchElementException}.
- *
- * @return the value held by this {@code OptionalDouble}
- * @throws NoSuchElementException if there is no value present
+ * If a value is present, returns the value, otherwise throws
+ * {@code NoSuchElementException}.
*
+ * @return the value described by this {@code OptionalDouble}
+ * @throws NoSuchElementException if no value is present
* @see OptionalDouble#isPresent()
*/
public double getAsDouble() {
@@ -122,21 +122,21 @@ public final class OptionalDouble {
}
/**
- * Return {@code true} if there is a value present, otherwise {@code false}.
+ * If a value is present, returns {@code true}, otherwise {@code false}.
*
- * @return {@code true} if there is a value present, otherwise {@code false}
+ * @return {@code true} if a value is present, otherwise {@code false}
*/
public boolean isPresent() {
return isPresent;
}
/**
- * If a value is present, perform the given action with the value,
- * otherwise do nothing.
+ * If a value is present, performs the given action with the value,
+ * otherwise does nothing.
*
- * @param action the action to be performed if a value is present
- * @throws NullPointerException if a value is present and {@code action} is
- * null
+ * @param action the action to be performed, if a value is present
+ * @throws NullPointerException if value is present and the given action is
+ * {@code null}
*/
public void ifPresent(DoubleConsumer action) {
if (isPresent) {
@@ -145,15 +145,16 @@ public final class OptionalDouble {
}
/**
- * If a value is present, perform the given action with the value,
- * otherwise perform the given empty-based action.
+ * If a value is present, performs the given action with the value,
+ * otherwise performs the given empty-based action.
*
- * @param action the action to be performed if a value is present
- * @param emptyAction the empty-based action to be performed if a value is
- * not present
- * @throws NullPointerException if a value is present and {@code action} is
- * null, or a value is not present and {@code emptyAction} is null.
- * @since 1.9
+ * @param action the action to be performed, if a value is present
+ * @param emptyAction the empty-based action to be performed, if no value is
+ * present
+ * @throws NullPointerException if a value is present and the given action
+ * is {@code null}, or no value is present and the given empty-based
+ * action is {@code null}.
+ * @since 9
*/
public void ifPresentOrElse(DoubleConsumer action, Runnable emptyAction) {
if (isPresent) {
@@ -164,19 +165,20 @@ public final class OptionalDouble {
}
/**
- * If a value is present return a sequential {@link DoubleStream} containing
- * only that value, otherwise return an empty {@code DoubleStream}.
- *
- * @apiNote This method can be used to transform a {@code Stream} of
- * optional doubles to a {@code DoubleStream} of present doubles:
+ * If a value is present, returns a sequential {@link DoubleStream}
+ * containing only that value, otherwise returns an empty
+ * {@code DoubleStream}.
*
+ * @apiNote
+ * This method can be used to transform a {@code Stream} of optional doubles
+ * to a {@code DoubleStream} of present doubles:
* Additional methods that depend on the presence or absence of a contained
* value are provided, such as {@link #orElse(int) orElse()}
- * (return a default value if value not present) and
- * {@link #ifPresent(java.util.function.IntConsumer) ifPresent()} (perform an
- * action if the value is present).
+ * (returns a default value if no value is present) and
+ * {@link #ifPresent(java.util.function.IntConsumer) ifPresent()} (performs an
+ * action if a value is present).
*
* This is a value-based
* class; use of identity-sensitive operations (including reference equality
@@ -71,24 +71,25 @@ public final class OptionalInt {
}
/**
- * Returns an empty {@code OptionalInt} instance. No value is present for this
- * OptionalInt.
+ * Returns an empty {@code OptionalInt} instance. No value is present for
+ * this {@code OptionalInt}.
*
- * @apiNote Though it may be tempting to do so, avoid testing if an object
- * is empty by comparing with {@code ==} against instances returned by
- * {@code Option.empty()}. There is no guarantee that it is a singleton.
+ * @apiNote
+ * Though it may be tempting to do so, avoid testing if an object is empty
+ * by comparing with {@code ==} against instances returned by
+ * {@code OptionalInt.empty()}. There is no guarantee that it is a singleton.
* Instead, use {@link #isPresent()}.
*
- * @return an empty {@code OptionalInt}
+ * @return an empty {@code OptionalInt}
*/
public static OptionalInt empty() {
return EMPTY;
}
/**
- * Construct an instance with the value present.
+ * Construct an instance with the described value.
*
- * @param value the int value to be present
+ * @param value the int value to describe
*/
private OptionalInt(int value) {
this.isPresent = true;
@@ -96,9 +97,9 @@ public final class OptionalInt {
}
/**
- * Return an {@code OptionalInt} with the specified value present.
+ * Returns an {@code OptionalInt} describing the given value.
*
- * @param value the value to be present
+ * @param value the value to describe
* @return an {@code OptionalInt} with the value present
*/
public static OptionalInt of(int value) {
@@ -106,12 +107,11 @@ public final class OptionalInt {
}
/**
- * If a value is present in this {@code OptionalInt}, returns the value,
- * otherwise throws {@code NoSuchElementException}.
- *
- * @return the value held by this {@code OptionalInt}
- * @throws NoSuchElementException if there is no value present
+ * If a value is present, returns the value, otherwise throws
+ * {@code NoSuchElementException}.
*
+ * @return the value described by this {@code OptionalInt}
+ * @throws NoSuchElementException if no value is present
* @see OptionalInt#isPresent()
*/
public int getAsInt() {
@@ -122,21 +122,21 @@ public final class OptionalInt {
}
/**
- * Return {@code true} if there is a value present, otherwise {@code false}.
+ * If a value is present, returns {@code true}, otherwise {@code false}.
*
- * @return {@code true} if there is a value present, otherwise {@code false}
+ * @return {@code true} if a value is present, otherwise {@code false}
*/
public boolean isPresent() {
return isPresent;
}
/**
- * If a value is present, perform the given action with the value,
- * otherwise do nothing.
+ * If a value is present, performs the given action with the value,
+ * otherwise does nothing.
*
- * @param action the action to be performed if a value is present
- * @throws NullPointerException if value is present and {@code action} is
- * null
+ * @param action the action to be performed, if a value is present
+ * @throws NullPointerException if value is present and the given action is
+ * {@code null}
*/
public void ifPresent(IntConsumer action) {
if (isPresent) {
@@ -145,15 +145,16 @@ public final class OptionalInt {
}
/**
- * If a value is present, perform the given action with the value,
- * otherwise perform the given empty-based action.
+ * If a value is present, performs the given action with the value,
+ * otherwise performs the given empty-based action.
*
- * @param action the action to be performed if a value is present
- * @param emptyAction the empty-based action to be performed if a value is
- * not present
- * @throws NullPointerException if a value is present and {@code action} is
- * null, or a value is not present and {@code emptyAction} is null.
- * @since 1.9
+ * @param action the action to be performed, if a value is present
+ * @param emptyAction the empty-based action to be performed, if no value is
+ * present
+ * @throws NullPointerException if a value is present and the given action
+ * is {@code null}, or no value is present and the given empty-based
+ * action is {@code null}.
+ * @since 9
*/
public void ifPresentOrElse(IntConsumer action, Runnable emptyAction) {
if (isPresent) {
@@ -164,19 +165,19 @@ public final class OptionalInt {
}
/**
- * If a value is present return a sequential {@link IntStream} containing
- * only that value, otherwise return an empty {@code IntStream}.
- *
- * @apiNote This method can be used to transform a {@code Stream} of
- * optional integers to an {@code IntStream} of present integers:
+ * If a value is present, returns a sequential {@link IntStream} containing
+ * only that value, otherwise returns an empty {@code IntStream}.
*
+ * @apiNote
+ * This method can be used to transform a {@code Stream} of optional
+ * integers to an {@code IntStream} of present integers:
* Additional methods that depend on the presence or absence of a contained
* value are provided, such as {@link #orElse(long) orElse()}
- * (return a default value if value not present) and
- * {@link #ifPresent(java.util.function.LongConsumer) ifPresent()} (perform an
- * action if the value is present).
+ * (returns a default value if no value is present) and
+ * {@link #ifPresent(java.util.function.LongConsumer) ifPresent()} (performs an
+ * action if a value is present).
*
* This is a value-based
* class; use of identity-sensitive operations (including reference equality
@@ -71,24 +71,25 @@ public final class OptionalLong {
}
/**
- * Returns an empty {@code OptionalLong} instance. No value is present for this
- * OptionalLong.
+ * Returns an empty {@code OptionalLong} instance. No value is present for
+ * this {@code OptionalLong}.
*
- * @apiNote Though it may be tempting to do so, avoid testing if an object
- * is empty by comparing with {@code ==} against instances returned by
- * {@code Option.empty()}. There is no guarantee that it is a singleton.
+ * @apiNote
+ * Though it may be tempting to do so, avoid testing if an object is empty
+ * by comparing with {@code ==} against instances returned by
+ * {@code OptionalLong.empty()}. There is no guarantee that it is a singleton.
* Instead, use {@link #isPresent()}.
*
- * @return an empty {@code OptionalLong}.
+ * @return an empty {@code OptionalLong}.
*/
public static OptionalLong empty() {
return EMPTY;
}
/**
- * Construct an instance with the value present.
+ * Construct an instance with the described value.
*
- * @param value the long value to be present
+ * @param value the long value to describe
*/
private OptionalLong(long value) {
this.isPresent = true;
@@ -96,9 +97,9 @@ public final class OptionalLong {
}
/**
- * Return an {@code OptionalLong} with the specified value present.
+ * Returns an {@code OptionalLong} describing the given value.
*
- * @param value the value to be present
+ * @param value the value to describe
* @return an {@code OptionalLong} with the value present
*/
public static OptionalLong of(long value) {
@@ -106,12 +107,11 @@ public final class OptionalLong {
}
/**
- * If a value is present in this {@code OptionalLong}, returns the value,
- * otherwise throws {@code NoSuchElementException}.
- *
- * @return the value held by this {@code OptionalLong}
- * @throws NoSuchElementException if there is no value present
+ * If a value is present, returns the value, otherwise throws
+ * {@code NoSuchElementException}.
*
+ * @return the value described by this {@code OptionalLong}
+ * @throws NoSuchElementException if no value is present
* @see OptionalLong#isPresent()
*/
public long getAsLong() {
@@ -122,21 +122,21 @@ public final class OptionalLong {
}
/**
- * Return {@code true} if there is a value present, otherwise {@code false}.
+ * If a value is present, returns {@code true}, otherwise {@code false}.
*
- * @return {@code true} if there is a value present, otherwise {@code false}
+ * @return {@code true} if a value is present, otherwise {@code false}
*/
public boolean isPresent() {
return isPresent;
}
/**
- * If a value is present, perform the given action with the value,
- * otherwise do nothing.
+ * If a value is present, performs the given action with the value,
+ * otherwise does nothing.
*
- * @param action the action to be performed if a value is present
- * @throws NullPointerException if a value is present and {@code action} is
- * null
+ * @param action the action to be performed, if a value is present
+ * @throws NullPointerException if value is present and the given action is
+ * {@code null}
*/
public void ifPresent(LongConsumer action) {
if (isPresent) {
@@ -145,15 +145,16 @@ public final class OptionalLong {
}
/**
- * If a value is present, perform the given action with the value,
- * otherwise perform the given empty-based action.
+ * If a value is present, performs the given action with the value,
+ * otherwise performs the given empty-based action.
*
- * @param action the action to be performed if a value is present
- * @param emptyAction the empty-based action to be performed if a value is
- * not present
- * @throws NullPointerException if a value is present and {@code action} is
- * null, or a value is not present and {@code emptyAction} is null.
- * @since 1.9
+ * @param action the action to be performed, if a value is present
+ * @param emptyAction the empty-based action to be performed, if no value is
+ * present
+ * @throws NullPointerException if a value is present and the given action
+ * is {@code null}, or no value is present and the given empty-based
+ * action is {@code null}.
+ * @since 9
*/
public void ifPresentOrElse(LongConsumer action, Runnable emptyAction) {
if (isPresent) {
@@ -164,19 +165,19 @@ public final class OptionalLong {
}
/**
- * If a value is present return a sequential {@link LongStream} containing
- * only that value, otherwise return an empty {@code LongStream}.
- *
- * @apiNote This method can be used to transform a {@code Stream} of
- * optional longs to a {@code LongStream} of present longs:
+ * If a value is present, returns a sequential {@link LongStream} containing
+ * only that value, otherwise returns an empty {@code LongStream}.
*
+ * @apiNote
+ * This method can be used to transform a {@code Stream} of optional longs
+ * to an {@code LongStream} of present longs:
* {@code
@@ -222,12 +229,12 @@ public final class Optional{@code
* Stream
*
* @return the optional value as a {@code Stream}
- * @since 1.9
+ * @since 9
*/
public Stream
*
{@code
* Stream
*
* @return the optional value as a {@code DoubleStream}
- * @since 1.9
+ * @since 9
*/
public DoubleStream stream() {
if (isPresent) {
@@ -187,9 +189,10 @@ public final class OptionalDouble {
}
/**
- * Return the value if present, otherwise return {@code other}.
+ * If a value is present, returns the value, otherwise returns
+ * {@code other}.
*
- * @param other the value to be returned if there is no value present
+ * @param other the value to be returned, if no value is present
* @return the value, if present, otherwise {@code other}
*/
public double orElse(double other) {
@@ -197,34 +200,35 @@ public final class OptionalDouble {
}
/**
- * Return the value if present, otherwise invoke {@code other} and return
- * the result of that invocation.
+ * If a value is present, returns the value, otherwise returns the result
+ * produced by the supplying function.
*
- * @param other a {@code DoubleSupplier} whose result is returned if no value
- * is present
- * @return the value if present otherwise the result of {@code other.getAsDouble()}
- * @throws NullPointerException if value is not present and {@code other} is
- * null
+ * @param supplier the supplying function that produces a value to be returned
+ * @return the value, if present, otherwise the result produced by the
+ * supplying function
+ * @throws NullPointerException if no value is present and the supplying
+ * function is {@code null}
*/
- public double orElseGet(DoubleSupplier other) {
- return isPresent ? value : other.getAsDouble();
+ public double orElseGet(DoubleSupplier supplier) {
+ return isPresent ? value : supplier.getAsDouble();
}
/**
- * Return the contained value, if present, otherwise throw an exception
- * to be created by the provided supplier.
+ * If a value is present, returns the value, otherwise throws an exception
+ * produced by the exception supplying function.
*
- * @apiNote A method reference to the exception constructor with an empty
- * argument list can be used as the supplier. For example,
+ * @apiNote
+ * A method reference to the exception constructor with an empty argument
+ * list can be used as the supplier. For example,
* {@code IllegalStateException::new}
*
* @param
*
*
* @param obj an object to be tested for equality
* @return {@code true} if the other object is "equal to" this object
- * otherwise {@code false}
+ * otherwise {@code false}
*/
@Override
public boolean equals(Object obj) {
@@ -264,10 +269,11 @@ public final class OptionalDouble {
}
/**
- * Returns the hash code value of the present value, if any, or 0 (zero) if
- * no value is present.
+ * Returns the hash code of the value, if present, otherwise {@code 0}
+ * (zero) if no value is present.
*
- * @return hash code value of the present value or 0 if no value is present
+ * @return hash code value of the present value or {@code 0} if no value is
+ * present
*/
@Override
public int hashCode() {
@@ -275,14 +281,13 @@ public final class OptionalDouble {
}
/**
- * {@inheritDoc}
+ * Returns a non-empty string representation of this {@code OptionalDouble}
+ * suitable for debugging. The exact presentation format is unspecified and
+ * may vary between implementations and versions.
*
- * Returns a non-empty string representation of this object suitable for
- * debugging. The exact presentation format is unspecified and may vary
- * between implementations and versions.
- *
- * @implSpec If a value is present the result must include its string
- * representation in the result. Empty and present instances must be
+ * @implSpec
+ * If a value is present the result must include its string representation
+ * in the result. Empty and present {@code OptionalDouble}s must be
* unambiguously differentiable.
*
* @return the string representation of this instance
diff --git a/jdk/src/java.base/share/classes/java/util/OptionalInt.java b/jdk/src/java.base/share/classes/java/util/OptionalInt.java
index 92a1d855be8..cc56f47e4ba 100644
--- a/jdk/src/java.base/share/classes/java/util/OptionalInt.java
+++ b/jdk/src/java.base/share/classes/java/util/OptionalInt.java
@@ -30,15 +30,15 @@ import java.util.function.Supplier;
import java.util.stream.IntStream;
/**
- * A container object which may or may not contain a {@code int} value.
- * If a value is present, {@code isPresent()} will return {@code true} and
- * {@code getAsInt()} will return the value.
+ * A container object which may or may not contain an {@code int} value. If a
+ * value is present, {@code isPresent()} returns {@code true} and
+ * {@code getAsInt()} returns the value.
*
* {@code
* Stream
*
* @return the optional value as an {@code IntStream}
- * @since 1.9
+ * @since 9
*/
public IntStream stream() {
if (isPresent) {
@@ -187,9 +188,10 @@ public final class OptionalInt {
}
/**
- * Return the value if present, otherwise return {@code other}.
+ * If a value is present, returns the value, otherwise returns
+ * {@code other}.
*
- * @param other the value to be returned if there is no value present
+ * @param other the value to be returned, if no value is present
* @return the value, if present, otherwise {@code other}
*/
public int orElse(int other) {
@@ -197,34 +199,35 @@ public final class OptionalInt {
}
/**
- * Return the value if present, otherwise invoke {@code other} and return
- * the result of that invocation.
+ * If a value is present, returns the value, otherwise returns the result
+ * produced by the supplying function.
*
- * @param other a {@code IntSupplier} whose result is returned if no value
- * is present
- * @return the value if present otherwise the result of {@code other.getAsInt()}
- * @throws NullPointerException if value is not present and {@code other} is
- * null
+ * @param supplier the supplying function that produces a value to be returned
+ * @return the value, if present, otherwise the result produced by the
+ * supplying function
+ * @throws NullPointerException if no value is present and the supplying
+ * function is {@code null}
*/
- public int orElseGet(IntSupplier other) {
- return isPresent ? value : other.getAsInt();
+ public int orElseGet(IntSupplier supplier) {
+ return isPresent ? value : supplier.getAsInt();
}
/**
- * Return the contained value, if present, otherwise throw an exception
- * to be created by the provided supplier.
+ * If a value is present, returns the value, otherwise throws an exception
+ * produced by the exception supplying function.
*
- * @apiNote A method reference to the exception constructor with an empty
- * argument list can be used as the supplier. For example,
+ * @apiNote
+ * A method reference to the exception constructor with an empty argument
+ * list can be used as the supplier. For example,
* {@code IllegalStateException::new}
*
* @param
*
{@code
* Stream
*
- * @return the optional value as a {@code LongStream}
- * @since 1.9
+ * @return the optional value as an {@code LongStream}
+ * @since 9
*/
public LongStream stream() {
if (isPresent) {
@@ -187,9 +188,10 @@ public final class OptionalLong {
}
/**
- * Return the value if present, otherwise return {@code other}.
+ * If a value is present, returns the value, otherwise returns
+ * {@code other}.
*
- * @param other the value to be returned if there is no value present
+ * @param other the value to be returned, if no value is present
* @return the value, if present, otherwise {@code other}
*/
public long orElse(long other) {
@@ -197,34 +199,35 @@ public final class OptionalLong {
}
/**
- * Return the value if present, otherwise invoke {@code other} and return
- * the result of that invocation.
+ * If a value is present, returns the value, otherwise returns the result
+ * produced by the supplying function.
*
- * @param other a {@code LongSupplier} whose result is returned if no value
- * is present
- * @return the value if present otherwise the result of {@code other.getAsLong()}
- * @throws NullPointerException if value is not present and {@code other} is
- * null
+ * @param supplier the supplying function that produces a value to be returned
+ * @return the value, if present, otherwise the result produced by the
+ * supplying function
+ * @throws NullPointerException if no value is present and the supplying
+ * function is {@code null}
*/
- public long orElseGet(LongSupplier other) {
- return isPresent ? value : other.getAsLong();
+ public long orElseGet(LongSupplier supplier) {
+ return isPresent ? value : supplier.getAsLong();
}
/**
- * Return the contained value, if present, otherwise throw an exception
- * to be created by the provided supplier.
+ * If a value is present, returns the value, otherwise throws an exception
+ * produced by the exception supplying function.
*
- * @apiNote A method reference to the exception constructor with an empty
- * argument list can be used as the supplier. For example,
+ * @apiNote
+ * A method reference to the exception constructor with an empty argument
+ * list can be used as the supplier. For example,
* {@code IllegalStateException::new}
*
* @param
*