RFR: 8344706: Compiler Implementation of Compact Source Files and Instance Main Methods
Luca Kellermann
duke at openjdk.org
Mon Apr 7 07:01:34 UTC 2025
On Fri, 4 Apr 2025 07:20:23 GMT, Jan Lahoda <jlahoda 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 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();
src/java.base/share/classes/java/lang/IO.java line 147:
> 145: } catch (IOException ioe) {
> 146: throw new IOError(ioe);
> 147: }
Was `UncheckedIOException` considered? It might be better for beginners to learn throwing exceptions instead of errors.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24438#discussion_r2029603325
PR Review Comment: https://git.openjdk.org/jdk/pull/24438#discussion_r2029604846
More information about the compiler-dev
mailing list