JDK-8329606 : Implement Implicitly Declared Classes and Instance Main Methods (Third Preview)
  • Type: CSR
  • Component: tools
  • Sub-Component: javac
  • Priority: P3
  • Status: Finalized
  • Resolution: Unresolved
  • Fix Versions: 23
  • Submitted: 2024-04-03
  • Updated: 2024-05-16
Related Reports
CSR :  
Description
Summary
-------

We propose to re-preview the Implicitly Declared Classes and Instance Main Methods again. In addition to the current state of the feature, we propose to add implicit imports for `java.base` module (using the proposed Module Imports, JDK-8315129), and a "simple-io" (exact name is TBD) using the separatelly proposed "Simple-IO" class, please see JDK-8305457.

Problem
-------

More experience is needed with the implicitly declared classes and instance main methods.

The current experience from the last round of preview is twofold:

 - it is difficult for the inexperienced users to import manually from various packages
 - it is difficult for the inexperienced users to work with I/O.

Solution
--------

The proposed solution is twofold:

 - re-preview the existing feature for another release, without changes unless otherwise noted.
 - add implicit imports for `java.base` and "simple-io" for the implicitly declared classes. This is similar to the long-term existing implicit import for `java.lang`, but the new implicit imports are only used for the implicitly declared classes. Note this aspect of the solution depends on the proposed Module Imports, JDK-8315129 and "simple-io" class, JDK-8305457, which are related, but not covered by this CSR.

Specification
-------------

The draft JLS and JVMS specifications are attached.

There are no corresponding API changes.

Comments
Updated the spec to reflect the change in name of the adapter class from `java.io.Console.Basic` to `java.io.IO`, and the change in name of the static method from `input` to `readln`.
02-05-2024

Moving to Provisional, not Approved.
04-04-2024