Observation: Module imports and java.io.IO

Eirik Bjørsnøs eirbjo at gmail.com
Tue May 14 16:26:02 UTC 2024


Hi,

JEP-477 includes the section "Growing a program", showing how an implicit
class can be grown into an ordinary class by wrapping it in a class
declaration and adding the necessary (no longer implicit) imports:

import static java.io.IO.*;
> import java.util.List;          // alternatively: import module java.base;


The module import of java.base (from JEP-476) strikes me as very elegant in
this context in that it provides the learning programmer access to Java's
basic APIs in a single import. "Give me the basic java stuff", thanks!

The sad thing is that the "basic java stuff" does not seem to include the
static methods in java.io.IO. So the learning programmer still needs to add
"import static java.io.IO.*". This doubles the number of imports needed,
but worse, it introduces the concepts of static imports and wildcard
imports!

I was thinking it would be really nice if "import module java.base" somehow
also included the new IO methods.

Has this interaction between JEP-177 and JEP-476 been discussed in the
expert group?

Thanks,
Eirik.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20240514/f1d37633/attachment.htm>


More information about the amber-dev mailing list