RFR: 8344706: Compiler Implementation of Compact Source Files and Instance Main Methods [v2]
Stuart Marks
smarks at openjdk.org
Mon Apr 7 18:13:30 UTC 2025
On Sat, 5 Apr 2025 00:55:55 GMT, Luca Kellermann <duke at openjdk.org> wrote:
>> Jan Lahoda has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Use local variable for System.out in print().
>
> src/java.base/share/classes/java/lang/IO.java line 122:
>
>> 120: public static void print(Object obj) {
>> 121: System.out.print(obj);
>> 122: System.out.flush();
>
> Is it worth using a local variable to avoid calling `print` and `flush` on different streams in case `System.out` is reassigned in between?
>
>
> var out = System.out;
> out.print(obj);
> out.flush();
Updated as suggested; thanks @lukellmann .
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24438#discussion_r2031757221
More information about the kulla-dev
mailing list