-
Bug
-
Resolution: Fixed
-
P4
-
8u20
-
b50
-
x86
-
windows_8
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8084467 | emb-9 | Paul Sandoz | P4 | Resolved | Fixed | team |
FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
The signature of OptionalInt.orElseThrow is
<X extends Throwable> int orElseThrow(Supplier<X> exceptionSupplier) throws X;
Similarly, the signature of OptionalDouble.orElseThrow is
<X extends Throwable> double orElseThrow(Supplier<X> exceptionSupplier) throws X;
and the signature of OptionalLong.orElseThrow is
<X extends Throwable> long orElseThrow(Supplier<X> exceptionSupplier) throws X;
The signature of Optional<T>.orElseThrow, however, is
public<X extends Throwable> int orElseThrow(Supplier<? extends X> exceptionSupplier) throws X;
I believe that Supplier<? extends X> is redundant, in which case it should be only Supplier<X>, as in OptionalInt, OptionalDouble, and OptionalLong.
If there is a reason for Supplier<? extends X> in Optional<T>, then the Supplier for OptionalInt, OptionalDouble, and OptionalLong should also be a Supplier<? extends X>
REPRODUCIBILITY :
This bug can be reproduced always.
A DESCRIPTION OF THE PROBLEM :
The signature of OptionalInt.orElseThrow is
<X extends Throwable> int orElseThrow(Supplier<X> exceptionSupplier) throws X;
Similarly, the signature of OptionalDouble.orElseThrow is
<X extends Throwable> double orElseThrow(Supplier<X> exceptionSupplier) throws X;
and the signature of OptionalLong.orElseThrow is
<X extends Throwable> long orElseThrow(Supplier<X> exceptionSupplier) throws X;
The signature of Optional<T>.orElseThrow, however, is
public<X extends Throwable> int orElseThrow(Supplier<? extends X> exceptionSupplier) throws X;
I believe that Supplier<? extends X> is redundant, in which case it should be only Supplier<X>, as in OptionalInt, OptionalDouble, and OptionalLong.
If there is a reason for Supplier<? extends X> in Optional<T>, then the Supplier for OptionalInt, OptionalDouble, and OptionalLong should also be a Supplier<? extends X>
REPRODUCIBILITY :
This bug can be reproduced always.
- backported by
-
JDK-8084467 orElseThrow has different signatures for OptionalPrimitive and Optional<T>
-
- Resolved
-
- relates to
-
JDK-8077565 Generated JavaDoc for Optional.orElseThrow() is not correct
-
- Open
-