JDK 9 RFR of JDK-8173609: Elements.printElements needs to support modules

joe darcy joe.darcy at oracle.com
Mon Jan 30 22:20:07 UTC 2017


Hi Jon,


On 1/30/2017 2:04 PM, Jonathan Gibbons wrote:
>
>
> On 01/29/2017 12:55 PM, joe darcy wrote:
>> Hi Remi,
>>
>>
>> On 1/29/2017 3:21 AM, Remi Forax wrote:
>>> Hi Joe,
>>> i believe that all non public methods you have added can be declared 
>>> private,
>>
>> Good point; I'll make that change before pushing.
>>
>>> and printNameableList can use a stream and a collector
>>>
>>>    private void printNameableList(List<? extends QualifiedNameable> 
>>> nameables) {
>>> writer.print(nameables.stream().map(QualifiedNameable::getQualifiedName).collect(Collectors.joining(", 
>>> "));
>>
>> I thought of using that style instead and changed some core 
>> reflection code to use streams and collectors earlier in 9 
>> (JDK-8162817: Annotation toString output not reusable for source input).
>>
>> I'll let Jon or Jan weigh in on which style is preferred for javac.
>
> We recently did a pass over javac code to modernize code, so these 
> days, I think streams and collectors are fine. The primary criteria 
> are regard for the bootstrap process, and no large destabilizing 
> changes that might advesely impact forward/backward parts at the 
> beginning of a release cycle.
>
> We can maybe quibble over the formatting: one line, or one line per 
> chained method.  :-)
>

Replaced with for-loop and state variable over names with

+        private void printNameableList(List<? extends 
QualifiedNameable> nameables) {
+                writer.print(nameables.stream().
+ map(QualifiedNameable::getQualifiedName).
+                             collect(Collectors.joining(", ")));
+        }

and verified the output for java.base was the same as before.

-Joe


More information about the compiler-dev mailing list