Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

https://dev.java/learn/packages/ is out of date, doesn't mention import module added in JEP 511 in Java 25 #254

Copy link
Copy link
@willy-b

Description

@willy-b
Issue body actions

Hello dev.java team!

In case it is useful, I am reporting where in this tutorial it may be most helpful to add just a couple of sentences to stay up to date with the new import module feature (JEP 511) that came out in Java 25 ( https://openjdk.org/jeps/511 ).


In the latest version of https://dev.java/learn/packages/ (archived as is at https://web.archive.org/web/20260527153107/https://dev.java/learn/packages/ ),

The choices provided for using public types from other packages are out of date for module imports:

To use a public type that is in a different package, you have three choices:

  1. use the fully qualified name of the type,
  2. import the type, or
  3. import the entire package of which the type is a member.

Now, since JEP 511 in Java 25 ( https://openjdk.org/jeps/511 ),

there is a 4th choice:

[suggested] 4. import the entire module (all exported packages) which exports the package of which the type is a member.

as one can do module level imports, like import module java.base , which as an example,

then has "the same effect as 54 on-demand package imports, one for each of the packages exported by the java.base module. It is as if the source file contains import java.io.* and import java.util.* and so on."

It may also be useful to separately mention that in a modular application, only public types in packages exported or opened by a module are visible outside that module and also provide the reader with a link to the tutorial on modules ( https://dev.java/learn/modules/ ).

Thanks!

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.