RFR: 8344706: Compiler Implementation of Compact Source Files and Instance Main Methods
Jan Lahoda
jlahoda at openjdk.org
Mon Apr 7 07:05:00 UTC 2025
On Sat, 5 Apr 2025 00:20:29 GMT, Chen Liang <liach at openjdk.org> wrote:
>> This is a PR that implements JEP: Compact Source Files and Instance Main Methods. Changes include:
>> - `java.io.IO` moved to `java.lang.IO`, and no longer uses `System.console()` to implement the methods (thanks to @stuart-marks)
>> - `java. ... .IO` is no longer automatically imported in any compilation unit
>> - the feature is finalized (i.e. no longer requires `--enable-preview`)
>
> src/java.base/share/classes/java/lang/IO.java line 183:
>
>> 181: * @return the internal BufferedReader instance
>> 182: */
>> 183: static synchronized BufferedReader reader() {
>
> Is the lock only inteneded for initialization, i.e. should it apply for simply getting the reader?
I believe there needs to be some barriers (at least `volatile`) even for getting the already initialized reader. And then, given the code here, it is probably fine and less error prone to simply use `synchronized` that something more complex.
But, given we'll hopefully have `@StableValue` soon, maybe we could use that? What do you think @stuart-marks?
Thanks!
> test/jdk/java/io/IO/IO.java line 1:
>
>> 1: /*
>
> Shouldn't the package of this test be moved to java/lang?
Done:
https://github.com/openjdk/jdk/pull/24438/commits/a5d223e14cadeb0e331d66d9030b780651f0cd64
Thanks!
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24438#discussion_r2030575903
PR Review Comment: https://git.openjdk.org/jdk/pull/24438#discussion_r2030576686
More information about the compiler-dev
mailing list