RFR 8238919: (doc) Broken code snippet in the java.util.stream package documentation

Jonathan Gibbons jonathan.gibbons at oracle.com
Wed Feb 12 19:52:48 UTC 2020


Mandy,

The desire to "highlight" parts of example code has made it onto the 
wishlist for a possible new `{@example}` tag for do comments.

-- Jon

On 2/12/20 11:50 AM, Mandy Chung wrote:
>
>
> On 2/12/20 11:44 AM, Roger Riggs wrote:
>> Hi Mandy,
>>
>> I considered breaking it up but none of the other examples have that 
>> kind of markup and it make the source much less easy to maintain.
>>
>> I'll keep it as is.
>>
>
> Okay with me.
>
> Mandy
>
>> Thanks, Roger
>>
>>
>> On 2/12/20 2:40 PM, Mandy Chung wrote:
>>> On 2/12/20 10:52 AM, Roger Riggs wrote:
>>>> Please review a trivial doc fix to remove html markup that should 
>>>> not be inside {@code}.
>>>> And a couple of spacing and punctuation fixes.
>>>>
>>>> diff --git 
>>>> a/src/java.base/share/classes/java/util/stream/package-info.java 
>>>> b/src/java.base/share/classes/java/util/stream/package-info.java
>>>> --- a/src/java.base/share/classes/java/util/stream/package-info.java
>>>> +++ b/src/java.base/share/classes/java/util/stream/package-info.java
>>>> @@ -43,7 +43,7 @@
>>>>   * <p>The key abstraction introduced in this package is 
>>>> <em>stream</em>.  The
>>>>   * classes {@link java.util.stream.Stream}, {@link 
>>>> java.util.stream.IntStream},
>>>>   * {@link java.util.stream.LongStream}, and {@link 
>>>> java.util.stream.DoubleStream}
>>>> - * are streams over objects and the primitive {@code int}, {@code 
>>>> long} and
>>>> + * are streams over objects and the primitive {@code int}, {@code 
>>>> long}, and
>>>>   * {@code double} types.  Streams differ from collections in 
>>>> several ways:
>>>>   *
>>>>   * <ul>
>>>> @@ -176,7 +176,7 @@
>>>>   * do:
>>>>   *
>>>>   * <pre>{@code
>>>> - *     int sumOfWeights = widgets.<b>parallelStream()</b>
>>>> + *     int sumOfWeights = widgets.parallelStream()
>>>
>>> It would be good to keep "parallelStream()" bold as the original 
>>> intent.
>>>
>>> Would breaking it into two code block work?  If not, this patch is 
>>> okay.
>>>
>>> Mandy
>>>
>>>> * .filter(b -> b.getColor() == RED)
>>>>   *                               .mapToInt(b -> b.getWeight())
>>>>   *                               .sum();
>>>> @@ -242,7 +242,7 @@
>>>>   *     String s = sl.collect(joining(" "));
>>>>   * }</pre>
>>>>   *
>>>> - * First a list is created consisting of two strings: "one"; and 
>>>> "two". Then a
>>>> + * First a list is created consisting of two strings: "one" and 
>>>> "two". Then a
>>>>   * stream is created from that list. Next the list is modified by 
>>>> adding a third
>>>>   * string: "three". Finally the elements of the stream are 
>>>> collected and joined
>>>>   * together. Since the list was modified before the terminal 
>>>> {@code collect}
>>>> @@ -344,7 +344,7 @@
>>>>   * parallelization:
>>>>   *
>>>>   * <pre>{@code
>>>> - *     List<String>results =
>>>> + *     List<String> results =
>>>>   *         stream.filter(s -> pattern.matcher(s).matches())
>>>>   *               .collect(Collectors.toList());  // No side-effects!
>>>>   * }</pre>
>>>>
>>>> Issue:
>>>> https://bugs.openjdk.java.net/browse/JDK-8238919
>>>>
>>>> Thanks, Roger
>>>>
>>>>
>>>
>>
>


More information about the core-libs-dev mailing list