CSR :
|
|
Relates :
|
|
Relates :
|
This is the CSR for the Java Language Specification changes of [JEP 463 Implicitly Declared Classes and instance `main` methods (Second Preview)](https://bugs.openjdk.org/browse/JDK-8315398) Summary ------- Add flexible `main` methods and implicitly declared main classes to the Java language. This is a [preview language feature and API](http://openjdk.java.net/jeps/12). Problem ------- The Java language necessitates the explicit use of some programming-in-the-large constructs such as classes and access control even for the simplest of programs. This makes the language unnecessarily difficult to learn for programming beginners, and adds too much noise to small programs. Solution -------- This change adds two features: 1. flexible `main` methods allow the main entry point to a program to allow different signatures. In particular, they allow a `main` method to have no parameters, they allow a `main` method to have any non-private access, and they allow it to be an instance method. An instance `main` method can be invoked by the launcher if the launched class has a non-private no-args constructor. 2. A Java file that declares one or more methods outside a class declaration is defined to implicitly declare a top-level class. The name of this class is not specified, but in simple implementations of the Java SE Platform, where compilation units are stored in files, the name of this implicitly declared class would typically be the name of the file containing the simple compilation unit minus any extension (such as .java or .jav). Specification ------------- Details of the changes to the Java Language Specification & Java Virtual Machine Specification are attached and are also available at [https://cr.openjdk.org/~gbierman/jep463/latest/](https://cr.openjdk.org/~gbierman/jep463/latest/). Changes described above are only available with `--enable-preview`. No class file changes are required.
|