JEP proposed to target JDK 18: 413: Code Snippets in Java API Documentation

Cay Horstmann cay.horstmann at gmail.com
Tue Aug 24 09:49:04 UTC 2021


I thought orElseThrow was purposefully given a horrible name so that it 
would be used as a last resort, nudging programmers towards

opt.ifPresent(System.out::println);

Cheers,

Cay

On 24/08/2021 11:35, Remi Forax wrote:
> Small change unrelated to what this JEP is about, the example should use orElseThrow() and not get(),
> as said in the javadoc of Optional.get() [1].
> 
>   /**
>   * The following code shows how to use {@code Optional.isPresent}:
>   * {@snippet :
>   * if (opt.isPresent()) {
>   *     System.out.println("opt: " + opt.orElseThrow());   // <-- here
>   * }
>   * }
>   */
> 
> Rémi
> 
> [1] https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/util/Optional.html#get()
> 
> ----- Original Message -----
>> From: "mark reinhold" <mark.reinhold at oracle.com>
>> To: "jdk-dev" <jdk-dev at openjdk.java.net>
>> Sent: Mardi 24 Août 2021 00:33:38
>> Subject: JEP proposed to target JDK 18: 413: Code Snippets in Java API Documentation
> 
>> The following JEP is proposed to target JDK 18:
>>
>>   413: Code Snippets in Java API Documentation
>>        https://openjdk.java.net/jeps/413
>>
>>   Summary: Introduce an @snippet tag for JavaDoc's Standard Doclet, to
>>   simplify the inclusion of example source code in API documentation.
>>
>> Feedback on this proposal from JDK Project Committers and Reviewers [1]
>> is more than welcome, as are reasoned objections.  If no such objections
>> are raised by 23:59 UTC on Monday, 30 August, or if they’re raised and
>> then satisfactorily answered, then per the JEP 2.0 process proposal [2]
>> I’ll target this JEP to JDK 18.
>>
>> - Mark
>>
>>
>> [1] https://openjdk.java.net/census#jdk
>> [2] https://cr.openjdk.java.net/~mr/jep/jep-2.0-02.html

-- 

Cay S. Horstmann | http://horstmann.com | mailto:cay at horstmann.com


More information about the jdk-dev mailing list